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

scroll-to-element

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scroll-to-element

Smooth scrolling to an element via selector or node reference

  • 2.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
41K
increased by8.36%
Maintainers
1
Weekly downloads
 
Created
Source

scroll-to-element

Smooth scrolls to element of the specified selector or element reference with optional offset, scroll-positon, easing, and duration. Takes into account document height for elements low on the page.

NPM

scrollToElement(selector, <options>)

Valid options:
offset : number

Add an additional offset to the final position. if > 0 then page is moved to the bottom otherwise the page is moved to the top.

align : string

Alignment of the element in the resulting viewport. Can be one of 'top', 'middle' or 'bottom'. Defaulting to 'top'.

ease : string

Easing function defaulting to "out-circ" (view ease for more)

duration : number

Animation duration defaulting to 1000

EXAMPLE

var scrollToElement = require('scroll-to-element');

scrollToElement('#id');

// with options
scrollToElement('.className', {
	offset: 0,
	ease: 'out-bounce',
	duration: 1500
});

// or if you already have a reference to the element
var elem = document.querySelector('.className');
scrollToElement(elem, {
	offset: 0,
	ease: 'out-bounce',
	duration: 1500
});

LICENSE

MIT

Keywords

FAQs

Package last updated on 11 Mar 2019

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