scrollTo( )


Scrolls the page to a specific location on the page.

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.

Method Declaration
Copy
function scrollTo(
  x: number,
  y: number,
  options: ScrollToOptions,
): Promise<void>;
Method Parameters
xnumberRequired

The horizontal position, in pixels, to scroll to.


ynumberRequired

The vertical position, in pixels, to scroll to.


optionsScrollToOptions

Scrolling options.

JavaScript
import { createClient } from "@wix/sdk"; import { site } from "@wix/site"; import { window as wixWindow } from "@wix/site-window"; const wixClient = createClient({ host: site.host(), modules: { wixWindow }, }); // ... await wixClient.wixWindow.scrollTo(100, 500);
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?