Reputation: 347
I want to get the element that is not visible in window. Is there a function like document.getElementFromPoint(x,y)
, that works in this situation?
In my particular case I have 2 layers on page, droppable and main one. I have a particular droppable div, I save the droppable div in variable, then I scroll down, the droppable div stops being visible. At that moment I want to be able to get the top element on that droppable div position.
Upvotes: 0
Views: 53
Reputation: 109005
To find an element off the top of the view port: iterate through all elements until you find one where el.getBoundingClientRect().bottom
is negative (see MDN).
A more general solution could apply look for multiple criteria including off the side or bottom by comparing the results to the size of the view port (eg. bounding rectangle's top
being greater than the client size of the Window).
Upvotes: 1