checking scroll position with js
let scrollLeft = window.pageXOffset || document.documentElement.scrollLeft, scrollTop = window.pageYOffset || document.documentElement.scrollTop;Code language: JavaScript (javascript)
Here is what the above code is Doing:
1. We’re getting the scroll position of the page.
2. We’re getting the position of the element.
3. We’re subtracting the scroll position from the element position.
4. We’re adding the element’s height to the position.
5. We’re adding the element’s width to the position.
6. We’re returning the position.