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

smooth-scroll-into-view-if-needed

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smooth-scroll-into-view-if-needed

Ponyfill for smooth scrolling elements into view (if needed!)

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
98K
increased by3.46%
Maintainers
1
Weekly downloads
 
Created
Source

CircleCI Status npm stat npm version gzip size size module formats: umd, cjs, and es semantic-release smooth-scroll-into-view-if-needed

This is an addon to scroll-into-view-if-needed that ponyfills smooth scrolling.

This package requires v2 of scroll-into-view-if-needed, currently in prerelease

Demo

Install

yarn add smooth-scroll-into-view-if-needed scroll-into-view-if-needed@next

Usage

import scrollIntoView from 'smooth-scroll-into-view-if-needed'
const node = document.getElementById('hero')

// If all you want is for all your users to have stuff smooth scroll into view
scrollIntoView(node, { behavior: 'smooth' })

// combine it with any of the other options
scrollIntoView(node, {
  behavior: 'smooth',
  scrollMode: 'if-needed',
  block: 'nearest',
  inline: 'nearest',
})

// It returns a promise that is resolved when the animation is finished
const sequence = async () => {
  const slide = document.getElementById('slide-3')
  // First smooth scroll to hero
  await scrollIntoView(node, { behavior: 'smooth' })
  // Then we scroll to a slide in a slideshow
  return scrollIntoView(slide, { behavior: 'smooth' })
}

Credits

  • smoothscroll for the reference implementation of smooth scrolling.

More documentation will be added

Keywords

FAQs

Package last updated on 29 Apr 2018

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