Package Exports
- scroll-animate-to
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (scroll-animate-to) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
scroll-animate-to
A light Javascript library to scroll to the position of element.
Install
npm i scroll-animate-to
Useage
import ScrollTo from 'scroll-animate-to'
let header = document.getElementById('header')
let scrollIns = new ScrollTo({
target: header,
animationFn: 'easeOut',
duration: 1500
})
scrollIns.scroll()
Or
<script src="/path/to/scroll-animate-to.min.js"></script>
More detail see DEMO
API
new ScrollTo(option)
- @param {Object} option
- @param {HTMLElement} option.container default is window. You can set element which has scroll bar
- @param {HTMLElement} option.target the element scroll to
- @param {Function|string} option.animationFn "easeIn", "easeOut", "easeInOut", "linear". Default is "easeIn". And you can custom the function.
- @param {Function} option.callback callback function
- @param {number} option.duration the scroll cost time, default 1000(ms)
- @param {number} option.offsetX scroll offset from X axis
- @param {number} option.offsetY scroll offset from Y axis
- @param {string} option.axis "axis" would be "x" or "y". Default is "y"
License
MIT