svelte-scrolling
Описание
Lightweight Svelte plugin to scroll to given elements with smooth animations
Языки
- TypeScript93,7%
- JavaScript6,3%
Svelte Scrolling
Scroll to given elements with smooth animation.
Install
Usage
Actions
scrollTo={reference | options}
This action listens for click (touchstart) events and scrolls to elements with smooth animation. The element to scroll to must be referenced using the action or .
Accepts as parameter only the element reference or all global options:
: Element reference.ref
To set the global options, the property is required
scrollRef={reference}
This action adds a reference to the elements that should scroll.
Accepts as parameter a string with the name to reference the element
Functions
scrollTop(options?)
Scroll to the top of the page
scrollBottom(options?)
Scroll to the end of the page
scrollLeft(options?)
Scroll to the end of left the page
scrollRight(options?)
Scroll to the end of right the page
scrollElement(reference, options?)
Scroll to element with smooth animation.
scrollPosition(position, options?)
Scroll to a position on the page
API
Global Options
| Property | Default | Description |
|---|---|---|
| | Duration (in milliseconds) of the animation. |
| | Offset that should be applied when scrolling. |
| | Easing function to be used when animating. Use any easing from or a custom easing function. |
| | A boolean value that, if true, indicates that the function specified by listener will never call preventDefault(). |
| | A callback function that should be called when scrolling has started. Receives the element, offset, duration and endPosition as a parameter. |
| | A callback function that should be called when scrolling has started. Receives the element, offset, duration and endPosition as a parameter. |
Override global options
License
Copyright (c) 2021-present, Valmisson Grizorte