目录

Scroll

has.pageScrollTo

has.pageScrollTo(Object object)

Scrolls the page to the target position.

Since: 1.0.0

Parameters

The input parameter is an object containing the following fields.

Name

Type

Default Value

Mandatory

Description

scrollTop

number

-

No

Target position (in px) to which the page should be scrolled. This parameter and the selector parameter are mutually exclusive—either one must be provided. If both are present, scrollTop takes precedence.

duration

number

300

No

Duration of the scrolling animation, in milliseconds.

selector

string

-

No

Picker.

offsetTop

number

-

No

Offset distance (in px). This parameter must be used together with the selector parameter to adjust the final scroll position by adding/subtracting the specified offset from the element's position identified by selector.

success

function

-

No

Callback to be invoked when the API call is successful.

fail

function

-

No

Callback to be invoked when the API call fails.

complete

function

-

No

Callback to be invoked when the API call is complete, regardless of success or failure.

Example

has.pageScrollTo({
  scrollTop: 0,
  duration: 300
});