How do you scroll?

Corvid provides several options for controlling page scrolling with code:

Scroll to an element

You can scroll to most page elements.

$w("#myElement").scrollTo();

Site visitors will see the page scrolling (animation).

Scroll to an invisible anchor

If you want to scroll to a specific point on your page that doesn’t have an element, you can add an an anchor to that location and then scroll to it. Site visitors won’t see the anchor.

$w("#myAnchor").scrollTo();

Site visitors will see the page scrolling (animation).

Scroll to a specific position on your page

You can scroll to a specific pixel on your page. The pixel’s position is specified by its X & Y coordinates.

import wixWindow from 'wix-window';
 
// ...
 
wixWindow.scrollTo(100, 500);

You can decide whether site visitors will see the page scrolling by setting the scrollAnimation boolean property. The property defaults to true, scrolling with an animation.

Scroll by a specific number of pixels

You can scroll the page by a given number of pixels. You specify the number of horizontal (x) and vertical (y) pixels to scroll. Movement is relative to the page’s current position.

import wixWindow from 'wix-window';
 
// ...
 
wixWindow.scrollBy(100, 500);

Site visitors will not see the page scrolling (no animation).

1 Like