smooth-page-scroll
Easy replacement for in-page hash-link scrolling.
Note: This lib requires
window.{request,cancel}AnimationFrame
,history.{push,replace}State
.
Demo
See https://leader22.github.io/smooth-page-scroll
Install
by npm
.
npm i smooth-page-scroll --save
by script
tag.
then,
// for CommonJSvar SmoothPageScroll = ; SmoothPageScroll;
finally,
Go! Destination
Options
You can pass options as install(options)
.
props | type | default | desc |
---|---|---|---|
gapX | number | 40 |
Gap for destination posX. |
gapY | number | 40 |
Gap for destination posY. |
duration | number | 500 |
Duration for scrolling. |
easing | func | t => t*(2-t) |
Easing function for scrolling. |
useHashAsHistory | bool | true |
If true, pushState on hash has changed. |