scroll-animate-to

1.0.4 • Public • Published

scroll-animate-to

A light Javascript library to scroll to the position of element.

DEMO

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

/scroll-animate-to/

    Package Sidebar

    Install

    npm i scroll-animate-to

    Weekly Downloads

    6

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    21 kB

    Total Files

    7

    Last publish

    Collaborators

    • ranjiayu