Answer the question
In order to leave comments, you need to log in
What is the right way to implement such JS code?
Hello!
How to check block visibility on scroll?
If the div block came into view, then display it.
$(window).scroll(function () {
if ($('.row').is(':visible')) {
alert("ок")
}
});
Answer the question
In order to leave comments, you need to log in
const onIntersection = (entries) => {
entries.forEach(entry => {
if (entry.intersectionRatio > 0) {
// visible
} else {
// not visible
}
});
};
const observer = new IntersectionObserver(onIntersection);
observer.observe(document.querySelector('#element'));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question