1.0.4 • Published 7 years ago

scrollto-element v1.0.4

Weekly downloads
6
License
MIT
Repository
github
Last release
7 years ago

scrollto-element

npm version Standard - JavaScript Style Guide

A simple animated scroll to element function.

Install

npm install scrollto-element --save
// or
yarn add scrollto-element

Usage

const scrolltoElement = require('scrollto-element')
// or ES2015+
import scrolltoElement from 'scrollto-element'

Example

import scrolltoElement from 'scrollto-element'

scrolltoElement(document.querySelector('#foobar'))
scrolltoElement(element, 300)

// advanced
scrolltoElement({
  element: document.querySelector('#foobar'),
  offset: -100, // default is 0
  bezier: [0.19, 1, 0.22, 1], // default is [0.19, 1, 0.22, 1]
  duration: 3000, // default is 100
  then () {
    console.log('Finished~')
  }
})

offset means scroll to (target element + offset).
When offset is a positive number, view will scroll through the target.
When offset is a negative number, view will scroll to near the target.

See also

License

MIT

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago