티스토리 뷰
document.querySelectorAll(".content__item__desc.reveal").forEach((el,i)=>{
if(!(el.querySelector("span"))){
const text = el.innerText;
el.innerHTML = `<span>${text}</span>`;
}
});
function scroll() { //재귀함수를 이용한 스크롤값 구하기
let scrollTop = window.screenY || window.pageYOffset || document.documentElement.scrollTop;
const reveal = document.querySelectorAll(".reveal");
reveal.forEach(elem => {
let revealOffset = elem.offsetTop + elem.parentElement.offsetTop;
let revealDelay = elem.dataset.delay;
if(scrollTop >= revealOffset - window.innerHeight/2){
if(revealDelay == undefined){
elem.classList.add("show");
} else {
setTimeout(() => {
elem.classList.add("show")
}, revealDelay);
}
}
});
document.querySelector(".scrollTop span").innerText = scrollTop;
requestAnimationFrame(scroll);
}
scroll();
'Script Sample > Parallax Effect' 카테고리의 다른 글
Parallax Effect - 텍스트 효과 (0) | 2022.04.14 |
---|---|
Parallax Effect - 이질감 효과 (0) | 2022.04.14 |
Parallax Effect - 나타나기 효과 (0) | 2022.04.14 |
Parallax Effect - 숨김 메뉴 (0) | 2022.04.14 |
Parallax Effect - (0) | 2022.04.14 |
댓글
© 2018 webstoryboy