Search.../

scrollBy( )

Scrolls the page by a given number of pixels.

Description

The scrollBy() function returns a Promise that resolves when the current page has been scrolled by the given number of pixels,

The x and y parameters determine the number of horizontal and vertical pixels to scroll the current page. Negative numbers scroll up or to the left and positive numbers scroll down or to the right.

Syntax

function scrollBy(x: number, y: number): Promise<void>

scrollBy Parameters

NAME
TYPE
DESCRIPTION
x
number

The horizontal offset, in pixels, to scroll by.

y
number

The vertical offset, in pixels, to scroll by.

Returns

Fulfilled - When the scroll is complete.

Return Type:

Promise<void>

Was this helpful?

Scroll the page by a given number of pixels

Copy Code
1import wixWindowFrontend from 'wix-window-frontend';
2
3// ...
4
5wixWindowFrontend.scrollBy(100, 500);
Scroll the page by a given number of pixels and log message when done

Copy Code
1import wixWindowFrontend from 'wix-window-frontend';
2
3// ...
4
5wixWindowFrontend.scrollBy(100, 500)
6 .then( ( ) => {
7 console.log("Done with scroll");
8} );