I am dynamically creating a VERY large HTML file with as many elements as the browser on any given computer can feasibly generate.
I then need to, as the user scrolls, access the elements of a certain type (let's say div) that are actually within the viewport.
The only way I know how to get a list of the elements visible in the viewport is to loop through all elements and then see if their bounds overlap with the current viewport. The problem with this is that there are so many elements in the document that this process can not complete quickly enough to let the browser scroll.
Is there a faster way to get all elements within the viewport?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With