
px๋ก ์คํฌ๋กค ์ผ๋ง๋ ํ๋์ง ๋ํ๋
์์์ Y์ถ ์์น ๊ฐ(์ฒ์์์น๋ง) ๊ฐ์ ธ์ด
์์์ ํฌ๊ธฐ์ ์์น๋ฅผ ๊ฐ๊ณ ์๋ ๊ฐ์ฒด
์์ฃผ ์ ์ฉํ ์์ด!!


function showValues() {
outputElm.innerHTML = `
์คํฌ๋กค ๋ ์: <strong>${window.scrollY}</strong>
/ offsetTop: <strong>${ilbuniElm.offsetTop}</strong>
/ getBoundingClientRect(): <strong>${ilbuniElm.getBoundingClientRect().top}</strong>
`;
let posY = ilbuniElm.getBoundingClientRect().top;
outputElm.innerHTML = posY;
if (posY < window.innerHeight * 0.2) {
ilbuniElm.classList.add('zoom');
} else {
ilbuniElm.classList.remove('zoom');
}
}
document.addEventListener('scroll', function () {
showValues();
});