📜  当 div 滚动到它时显示 - 无论代码示例

📅  最后修改于: 2022-03-11 14:57:35.401000             🧑  作者: Mango

代码示例1
var observer = new IntersectionObserver(function(entries) {
    // isIntersecting is true when element and viewport are overlapping
    // isIntersecting is false when element and viewport don't overlap
    if(entries[0].isIntersecting === true)
        console.log('Element has just become visible in screen');
}, { threshold: [0] });

observer.observe(document.querySelector("#main-container"));