Skater
Skater makes smooth scrolling simple.
It's tiny (1 KB gzipped) and has zero dependencies.
Installation
- npm:
npm install skaterjs
- yarn:
yarn install skaterjs
- jsdelivr: https://cdn.jsdelivr.net/npm/skaterjs
- unpkg: https://unpkg.com/skaterjs
Usage
Smoothly scroll to the #example
element:
Skater also accepts a number or an Element
as the first argument:
Skater returns an object with start
and stop
functions:
skater = skater
Options
Skater takes an optional second argument with customizable options. These are the defaults:
callbackFn
Execute a callback after scrolling:
containerTarget
Scroll inside specified container:
// Elements can also be passed directly
durationFn
Set a custom duration using a function takes one argument that includes x and y scroll distance. This duration overrides durationMs
.
durationMs
Set a custom duration in milliseconds.
easingFn
Custom easing function using the jquery-easing function signature.
offset
Set a scroll position offset from the target. Both x
and y
properties must be defined.
;
scrollDirection
Scroll vertically, horizontally, or both simultaneously:
Browser support
- Chrome 24+
- Firefox 23+
- Safari 6.1+
- IE 10+
- Edge 12+
Browser support using polyfilled build
You can use a polyfilled build, such as dist/skater.polyfilled.js
, to support the following browsers:
- Chrome 4+
- Firefox 4+
- Safari 3.1+
- IE 8+
Contributing
Contributions, issues, and feature requests are welcome. Check out the issues page if you'd like to contribute.
License
Skater is provided under the MIT license.
Credits
Skater is a project by Ivan Malopinsky.