Answer the question
In order to leave comments, you need to log in
Why can Javascript elementfrompoint return different elements?
There is a task, to find the nearest element along the Y axis to a certain point, using the string
$(document).ready(function(){
// что-то еще
var element = document.elementFromPoint(Math.floor(innerWidth/2), 500);
console.log("offset: {" + $(element).offset().top+ " : " + $(element).offset().left + "}");
// что-то еще
})
Answer the question
In order to leave comments, you need to log in
It looks like it's here
if the page is scrolled, then the element will rise above or fall below - its coordinates relative to the window will change.
The answer was actually simple. There was an image on the page that appeared on the page at a slightly different speed, not noticeable to the eye. And if it has not yet appeared, then I got on one element, and if it appeared on another. Perhaps this may be due to any other dynamic elements of the page. I'm not a frontend, so xs.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question