Answer the question
In order to leave comments, you need to log in
JavaScript: event - the appearance of an element in the scope. How?
On Facebook, the news feed, when you scroll down the page, loads itself.
It's the same here: nebo-v-almazah.ru/earrings
Something got wrong and I can't figure out how to do it without constant checking through setInterval()
Maybe there is something like this in jQuery?
Answer the question
In order to leave comments, you need to log in
var $win = $(window);
var $marker = $('#marker');
$win.scroll(function() {
if ($win.scrollTop() + $win.height() >= $marker.offset().top) {
$win.unbind('scroll');
// load there
}
});
you can also do this so as not to add the height of the window -
var coords = $("#your_element").getBoundingClientRect();
var windowHeight = document.documentElement.clientHeight;
if (windowHeight >= coords.top)
{
...
}
$(window).scroll(function() {
var h = $(window).scrollTop();
var yourElementHeight= $("#yourElement").offset().top; // координаты высоты верхнего края yourElement
if (h > yourElementHeight) {
//do...
}
//т.е. при высоте прокрутки > чем высота верхнего края yourElementHeight
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question