ele 요소가 뷰포트에 표시되면 다음 함수는 true를 반환합니다.
https://htmldom.dev/check-if-an-element-is-in-the-viewport
const isInViewport = function(ele) {
const rect = ele.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
);
};
등록된 댓글이 없습니다.