Scroll Fade Reverse
Identical to the basic scroll fade, but with toggleActions: 'play none none reverse' added. The fourth value 'reverse' means the animation plays backward when the element scrolls back above the trigger point — fading it back out. Each scroll-down replay restarts from the hidden state.
기본 스크롤 페이드와 동일하지만 toggleActions: 'play none none reverse'가 추가됩니다. 네 번째 값 'reverse'는 요소가 트리거 지점 위로 다시 스크롤될 때 애니메이션이 역방향으로 재생됨을 의미합니다. 다시 스크롤하면 숨겨진 상태에서 재시작합니다.
Source Code script.js
gsap.registerPlugin(ScrollTrigger);
gsap.utils.toArray('.fade-item').forEach((el) => {
gsap.to(el, {
opacity: 1,
y: 0,
duration: 0.7,
ease: 'power2.out',
scrollTrigger: {
trigger: el,
start: 'top 85%',
toggleActions: 'play none none reverse',
},
});
});