Socket
Socket
Sign inDemoInstall

scroll

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

scroll

animates the scroll top/left position of an element


Version published
Maintainers
1
Weekly downloads
255,266
decreased by-8.88%

Weekly downloads

Readme

Source

scroll

animates the scroll top/left position of an element (in 340 bytes)

browser support

note: you may need to polyfill requestAnimationFrame in older browsers

install

npm install scroll

use

var scroll = require('scroll')
var page = require('scroll-doc')()
var ease = require('ease-component')

// Basic usage
scroll.left(page, 200)

// Register a callback
scroll.top(page, 200, function (err, scrollTop) {
  console.log(err)
  // { message: "Scroll cancelled" } or
  // { message: "Element already at target scroll position" } or
  // null

  console.log(scrollTop)
  // => The new scrollTop position of the element
  // This is always returned, even when there’s an `err`.
})

// Specify a custom easing function
scroll.left(page, 200, { ease: ease.inBounce })

// Specify a duration in milliseconds (default: 350) and register a callback.
scroll.left(page, 200, { duration: 1000 }, function (err, scrollLeft) {
})

// Cancel a scroll animation
var options = { duration: 1000 }
var cancel = scroll.top(page, 200, options, function (err, scrollTop) {
  console.log(err.message)
  // => Scroll cancelled

  page.removeEventListener('wheel', cancel)
})

page.addEventListener('wheel', cancel)

note: the default easing is inOutSine from component/ease.

obey

MIT

FAQs

Last updated on 06 Mar 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc