标签:ret idt tom fse inview window document win element
isElementInViewport (el, offset = 0) {
const box = el.getBoundingClientRect(),
top = (box.top >= 0),
left = (box.left >= 0),
bottom = (box.bottom <= (window.innerHeight || document.documentElement.clientHeight) + offset),
right = (box.right <= (window.innerWidth || document.documentElement.clientWidth) + offset)
return (top && left && bottom && right)
}
标签:ret idt tom fse inview window document win element
原文地址:https://www.cnblogs.com/licurry/p/10584018.html