📜  视口中的 javascript - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:30.843000             🧑  作者: Mango

代码示例1
var isInViewport = function (elem) {
    var bounding = elem.getBoundingClientRect();
    return (
        bounding.top >= 0 &&
        bounding.left >= 0 &&
        bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
        bounding.right <= (window.innerWidth || document.documentElement.clientWidth)
    );
};