function elementInView(element) {
const rect = element.getBoundingClientRect()
const yInView = rect.top < window.innerHeight && rect.bottom > 0
const xInView = rect.left < window.innerWidth && rect.right > 0
return yInView && xInView
}
注意:本文归作者所有,未经作者允许,不得转载