Socket
Socket
Sign inDemoInstall

scroll-percentage

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    scroll-percentage

get the percentage value of how much the scrollable element has scrolled


Version published
Maintainers
1
Install size
69.7 kB
Created

Readme

Source
yarn add scroll-percentage
import { calculateScrollPercentage } from 'scroll-precentage'

provide the scrollable element as parameter -

calculateScrollPercentage(scrollabaleElement)

like -

calculateScrollPercentage(e.target)

full example -

document.querySeleceot('.scorllable-elem').addEventListener('scroll',e => {
  calculateScrollPercentage(e.target)
})

if the scrollabe element is window, then a second parameter is necessary. the second parameter - height of the element, window is scrolling by -

calculateScrollPercentage(e.target, document.querySelector(someElement).clientHeight)

FAQs

Last updated on 08 Aug 2018

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