Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scroll

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scroll

A function that animates an element’s scrollTop or scrollLeft position.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
319K
increased by2.17%
Maintainers
1
Weekly downloads
 
Created
Source

scroll

A function that animates an element’s scrollTop or scrollLeft position.

Browser support

Install

npm install scroll

Usage

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

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

// Register a callback
scroll.top(page, 200, function (error, scrollTop) {
  console.log(error)
  // { 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 `error`.
})

// Specify an easing function (default: 'inOutSine')
scroll.left(page, 200, { ease: 'inBounce' })

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

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

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

page.addEventListener('wheel', cancel)

Note: The easing functions are those specified in component/ease.

License

MIT

Keywords

FAQs

Package last updated on 07 Jun 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc