I'm currently working on an animated svg project and I am faced with the task of determining the scroll position within my div element. Previously, I used some code that I found on a tutorial from w3schools
However, what I really need is for the scroll calculation to start when it reaches my specific div element. Below is the code snippet that I have come up with:
var scrollpercent =
(document.body.scrollTop + document.documentElement.scrollTop) /
(document.documentElement.scrollHeight - document.documentElement.clientHeight);
console.log($(".svg-container").scrollTop())
I attempted to utilize svg-container.scrollTop()
, but it consistently returns 0.