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)