Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gmrchk/scrl
Page acceleration based scroll animation.
https://github.com/gmrchk/scrl
Last synced: 3 months ago
JSON representation
Page acceleration based scroll animation.
- Host: GitHub
- URL: https://github.com/gmrchk/scrl
- Owner: gmrchk
- License: mit
- Created: 2019-02-25T23:41:49.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-08-09T12:02:23.000Z (over 1 year ago)
- Last Synced: 2024-09-19T20:37:08.735Z (4 months ago)
- Language: JavaScript
- Size: 151 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Scrl
**Page acceleration based scroll animation.** (extracted swup scroll)
* Makes scroll animation smooth but quick.
* Takes care of special cases like scrolling to the bottom of the page instead of suddenly stopping.
* Stops scrolling when mouse wheel is used to avoid jaggy page.
* Provides handlers different events.## Usage
Create instance...
```javascript
import Scrl from 'scrl';
var scrl = new Scrl();
```
and use it.
```javascript
scrl.scrollTo(offset); // offset can be a number of pixel, or an element on the page
```## Options
Scrl accepts several options:
```javascript
const defaults = {
onAlreadyAtPositions: () => {}, // handler called when link leads to the offset page is already at
onCancel: () => {}, // handler called on cancel of animation by mouse scroll
onEnd: () => {}, // handler called on end of animation
onStart: () => {}, // handler called on start of animation
onTick: () => {}, // handler called on every step of animation
friction: .3, // friction of scroll animation
acceleration: .04, // acceleration of scroll animation
}
```