티스토리 뷰
function scroll(){
let scrollTop = window.screenY || window.pageYOffset || document.documentElement.scrollTop;
document.querySelector(".scrollTop span").innerText = Math.round(scrollTop);
// const img = document.querySelector("#section1 .content__item__img")
// img.style.transform = "translateY("+scrollTop/10+"px)"
document.querySelectorAll(".content__item").forEach(item => {
let offset1 = (scrollTop - item.offsetTop) * 0.1;
let offset2 = (scrollTop - item.offsetTop) * 0.15;
const target1 = item.querySelector(".content__item__img");
const target2 = item.querySelector(".content__item__desc");
const target3 = item.querySelector(".content__item__num");
// target1.style.transform = `translateY(${translateY}px)`;
// target2.style.transform = `translateY(${offset2}px)`;
// target3.style.transform = `translateY(${-offset2}px)`;
gsap.to(target1,{duration: .3, y: offset1, ease: "power1.out"});
gsap.to(target2,{duration: .3, y: offset2, ease: "power1.out"});
})
requestAnimationFrame(scroll)
}
scroll();
패럴랙스 효과
01 Section1 단순하게 살아라. 현대인은 쓸데없는 절차와 일 때문에 얼마나 복잡한 삶을 살아가는가? 02 Section2 돈이란 바닷물과도 같다. 그것은 마시면 마실수록 목이 말라진다. 03 Section3 먼저 자신
jiseonpack.github.io
'Script Sample > Parallax Effect' 카테고리의 다른 글
Parallax Effect07 - 리빌 효과 (0) | 2022.03.10 |
---|---|
Parallax Effect06 - 텍스트 효과 (0) | 2022.03.08 |
Parallax Effect04 - 나타나기 (0) | 2022.03.08 |
Parallax Effect03 - 숨김 메뉴 (0) | 2022.03.08 |
Parallax Effect02 - 사이드 메뉴 이동 (0) | 2022.03.08 |
댓글
© 2018 webstoryboy