@8/24/2022
Frontend에서 JS로 바닥에 스크롤 닿는 이벤트 감지하기
window.onscroll = function () {
console.log(document.body.scrollHeight, window.scrollY, window.innerHeight)
// @var int totalPageHeight
const totalPageHeight = document.body.scrollHeight;
// @var int scrollPoint
const scrollPoint = window.scrollY + window.innerHeight;
// check if we hit the bottom of the page
if (scrollPoint >= totalPageHeight) {
console.log("at the bottom");
}
}
JavaScript
복사