Notice
Recent Posts
Recent Comments
Link
250x250
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- googleicon
- 웹아이콘
- 그누보드반응형
- package.json
- npm install 문제
- maxwidth
- 정적객체
- 플러그인
- 아이콘사용법
- XEIcon
- 이미지반응형
- fontawesome
- 글자들여쓰기
- 의존성문제
- 동적객체
- minwidth
- node 오류
- 단어단위로떨어지기
- owlcarousel
- react npm install
- Git clone
- MediaQuery
- slickslider
- window 정책변경
- node설치
- vscode git clone
- npm start
- git lab clone
- npm install
- legacy-peer
Archives
- Today
- Total
어쩌다 알게 된 ƪ(•̃͡•̃͡ ƪ
[GSAP] ScrollTrigger 사용 패턴 본문
728x90
📌ScrollTrigger 사용 패턴
1. gsap.to() + scrollTrigger ✔ 단일 애니메이션
=> 하나의 애니메이션 사용 (단순한 애니메이션 단일 적용시 사용)
=> 스크롤 시 요소가 한 번에 변화할 때
=> 트리거 요소를 지정 가능
gsap.to(".box", {
x: 300,
duration: 2,
scrollTrigger: {
trigger: ".box",
start: "top center",
end: "bottom center",
scrub: true
}
});
2. gsap.timeline ({ scrollTrigger: {...} }); ✔ 다수 애니메이션
=> 여러 개의 애니메이션을 순차적으로 실행할 때 사용
=> 스크롤에 따라 단계적으로 변화 줄 때
❗ **팁** ❗
=> .to()를 계속 추가하면 여러 애니메이션을 하나의 타임라인에서 연결 가능
=> 순차적으로 실행 ( x 값 이동 후 180도 회전 )
flow_scroll.to(".box", { x: 300, duration: 2 })
.to(".box", { rotation: 180, duration: 1 });
=> 한 번에 실행 ( x 값 이동하면서 동시에 180도 회전 )
flow_scroll.to(".box", { x: 300, rotation: 180, duration: 2 });
let flow_scroll = gsap.timeline({
scrollTrigger: {
trigger: ".box",
start: "top center",
end: "bottom center",
scrub: true
}
});
// 순차적
flow_scroll.to(".box", { x: 300, duration: 2 })
.to(".box", { rotation: 180, duration: 1 });
// 동시적
flow_scroll.to("box", { x: 300, rotation: 180, duration: 2 };
3. ScrollTrigger.create() ✔ 애니메이션 x 스크롤, pin 효과만 o
=> 애니메이션 없이 고정(pin)하거나 감지할 때
=> 애니메이션 없이 스크롤 이벤트만 사용할 때
ScrollTrigger.create({
trigger: ".section",
start: "top top",
end: "bottom top",
pin: true // 스크롤 중 요소를 고정
});
4. gsap.to()에서 pin 적용 ✔ 단일 애니메이션 + 고정
위
x:500
아래
gsap.to(".box", {
x: 500, // 오른쪽으로 이동
duration: 2,
scrollTrigger: {
trigger: ".box_wrap", // .box_wrap에 도달하면 애니메이션 실행
start: "top center",
end: "bottom center",
scrub: true, // 스크롤 속도에 맞춰 애니메이션 실행 (true -> 부드럽게)
pin: true // 스크롤 중 .box를 고정
}
});
=> .box_wrap이 스크롤 될 때 오른쪽으로 이동
=> .box_wrap이 고정(pin) 되었다가 end 지점에서 해제됨
5. gsap.timeline()에서 pin 적용 ✔ 다수 애니메이션 + 고정
let flow_scroll = gsap.timeline({
scrollTrigger: {
trigger: ".section1",
start: "top top",
end: "bottom top",
scrub: 1,
pin: true, // .section1을 스크롤 중 고정
markers: true
}
});
flow_scroll.to(".box", { x: 300, duration: 2 }) // 오른쪽 이동
.to(".box", { rotation: 180, duration: 1 }) // 회전
.to(".box", { scale: 1.5, duration: 1 }); // 크기 확대
=> .section1이 스크롤 중에 고정됨 (pin)
=> .box가 오른쪽으로 이동 -> 회전 -> 크기 확대 순차적으로 애니메이션 실행
6. ScrollTrigger.create()와 gsap.to의 조합 ✔ pin 고정 후 애니메이션 실행
// .section을 스크롤 중 고정
ScrollTrigger.create({
trigger: ".section",
start: "top top",
end: "bottom top",
pin: true
});
// 고정된 상태에서 애니메이션 실행
gsap.to(".box", {
x: 300,
duration: 2,
scrollTrigger: {
trigger: ".box",
start: "top center",
end: "bottom center",
scrub: true
}
});
=> .section이 고정됨(pin)
=> .box가 고정된 .section 안에서 스크롤될 때 이동
728x90
'플러그인, 라이브러리 > 플러그인' 카테고리의 다른 글
| [GSAP] ScrollTrigger 옵션 (0) | 2025.03.27 |
|---|---|
| [GSAP] ScrollTrigger 기본 사용법 (0) | 2025.03.26 |
| [GSAP] Tween (0) | 2025.01.14 |
| [GSAP] ScrollTrigger (0) | 2025.01.14 |
| ( slick slide ) 옵션 정리 / 예제 링크 (4) | 2021.06.12 |
Comments