ScrollBar Issue

When Scroll Bar is scrolling, at that time how can we find using js what is the element at the topmost position in that window pane only.

When the user scrolls down, the value of element at the time of that at topmost position

I’m trying to figure out which elements of a document are visible as
the user scrolls the Firefox browser. I haven’t written the code yet
but I think I should be able to do it by keeping track of the current
display using the following properties:
window.content.scrollX, window.content.scrollY,
window.content.innerWidth, window.content.innerHeight. – with these 4
I can determine which part of the document is visible.

Then for each element I can figure out its display position using,
offsetWidth, offsetHeight, offsetTop, offsetLeft. This would entail
traversing the DOM and perculating the offset values down to all the

While this would likely work, it seems inefficient. Do you know of any
other ways to determine which elements are actually on the screen?