Search.../

scrollTo( )

Scrolls the page to the element using an animation.

Description

The scrollTo() function returns a Promise that is resolved when the animated scroll is complete and the element is now in view.

To scroll to a specific location on the page, see the wix-window scrollTo() function.

Calling the scrollTo() function on an element in a repeated item that is selected from the global scope causes an error.

Syntax

function scrollTo(): Promise<void>

scrollTo Parameters

This function does not take any parameters.

Returns

Fulfilled - When the scroll is complete.

Return Type:

Promise<void>
Mixed in from:$w.FormElement

Was this helpful?

Scroll the page to an element

Code Example

Copy Code
1$w("#myElement").scrollTo();
Scroll the page to an element and log message when done

Code Example

Copy Code
1$w("#myElement").scrollTo()
2 .then( ( ) => {
3 console.log("Done with scroll");
4} );