I tried other questions but they didn't work as I wanted.
I want to get the scroll percentage of an element (let's say a div) to animate it (e.g. if the user can see the element in full the function would return 100% / 1.0).
How can I achieve this?
I tried other questions but they didn't work as I wanted.
I want to get the scroll percentage of an element (let's say a div) to animate it (e.g. if the user can see the element in full the function would return 100% / 1.0).
How can I achieve this?
You could achieve it with the below formula,
var scrollPercent = (CurrentScrollPosition / (GivenTotalScrollHeightOfTheElement - ContentPostHeight)) * 100;