Scroll To

The scrollTo plugin provides smooth scrolling to specific elements or coordinates.
You can customize the position, easing, and duration of the scroll.


Important: You must first import the plugin before using it.

import { scrollTo } from 'animatry'

Scroll to an Element

Simply provide a CSS selector or DOM element to scroll to:

scrollTo({
y: '#section2',
offsetY: 20,
duration: 1,
ease: 'powerInOut(2)',
})

Scroll to a Pixel Value

You can also scroll to a specific vertical or horizontal pixel position:

scrollTo({
y: 1000,
duration: 1,
})

Configuration Options

Property
Description
x
Horizontal scroll target. Can be a number, selector, or element.
y
Vertical scroll target. Can be a number, selector, or element.
offsetX
Offset in pixels to subtract from the horizontal position.
offsetY
Offset in pixels to subtract from the vertical position.
duration
Animation duration in seconds. Default: 1.
ease
Easing function as string (e.g., "powerInOut").
autokill
Whether scrolling cancels if the user scrolls manually. Default: true.