To handle hidden and dynamic content with JavaScript, there are two main steps: getting the y position of the element relative to the page and calculating the offset for accurate scroll calculation.
The calculateHiddenY function helps retrieve the y position regardless of whether the elements are hidden or not, allowing correct scroll range and percentage calculations.
To track scroll in increments of 10% for hidden elements, we can use the scroll event listener and remove it when the page is unloaded.
Sending the tracking data to a backend endpoint can be achieved using the sendReportToBackend function, and it's advisable to implement a debounce function to reduce backend report frequency.