判断dom是否出现在可视区域
function isElementNotInViewport (el) {
if (el) {
let rect = el.getBoundingClientRect();
return (
rect.top >=
(window.innerHeight || document.documentElement.clientHeight) ||
rect.bottom <= 0
);
}
}
热爱前端技术