Search.../

scrollTo( )

Scrolls the page to a specific location on the page.

Description

The scrollTo() function returns a Promise that resolves when the current page has been scrolled to a given location on the page.

The x and y parameters determine the top-left pixel that is displayed on screen after the scroll.

Tip: To get the coordinates for scrolling, display the Wix Editor Toolbar. In the Editor, move the cursor to the top-left pixel where you want the page to scroll to. The X and Y axis Position values show the coordinates.

To scroll to a specific element on the page, see the $w.Node scrollTo() function.

Use the options parameter to specify the options to use when scrolling.

Syntax

function scrollTo(x: number, y: number, [options: ScrollToOptions]): Promise<void>

scrollTo Parameters

NAME
TYPE
DESCRIPTION
x
number

The horizontal position, in pixels, to scroll to.

y
number

The vertical position, in pixels, to scroll to.

options
Optional
ScrollToOptions

Scrolling options.

Returns

Fulfilled - When the scroll is complete.

Return Type:

Promise<void>

Was this helpful?

Scroll the page to a location

Copy Code
1import wixWindowFrontend from 'wix-window-frontend';
2
3// ...
4
5wixWindowFrontend.scrollTo(100, 500);
Scroll the page to a location and log a message when done

Copy Code
1import wixWindowFrontend from 'wix-window-frontend';
2
3// ...
4
5wixWindowFrontend.scrollTo(100, 500)
6 .then( ( ) => {
7 console.log("Done with scroll");
8} );
Scroll the page to a location without an animation

Copy Code
1import wixWindowFrontend from 'wix-window-frontend';
2
3// ...
4
5wixWindowFrontend.scrollTo(100, 500, {"scrollAnimation": false});