GSAP ScrollTrigger Property ๋ชจ์๐
211202-211204 ๊ณต๋ถํ ๋ด์ฉ
400px
= ์คํฌ๋กค ์์ ํ 400px ๋จ์ด์ง ์์ .start: top center
= ํธ๋ฆฌ๊ฑฐ์ ์๋ถ๋ถ์ด viewport๊ธฐ์ค ์ค๊ฐ์ ๋ฟ์์ ๋ ์์scrollTrigger: {
end: () => `+=${document.querySelector('.square').offsetHeight}`
}
start
์ ๊ฐ์ ๋ฐฉ์์ผ๋ก ์ฌ์ฉ๋จ. ๋๋๋ ์์ ์ ์
๋ ฅํ๋ค.start
์์ ์์ class๊ฐ ์ถ๊ฐ๋๊ณ end
์์ class๊ฐ ์ญ์ ๋๋ค.markers: true
์
๋ ฅ ์, ๊ธฐ๋ณธ ์คํ์ผ๋ก ๋ง์ปค๊ฐ ์์ฑ๋๋ค.scrollTrigger: {
markers: {
startColor: 'yellow',
endColor: 'black',
fontSize: '4rem',
indent: 200
}
}
toggleAction: "onEnter onLeave onEnterBack onLeaveBack"
ScrollTrigger.matchMedia({
// mobile
"(min-width: 320px) and (max-width: 767px)": function() {
gsap.timeline({
scrollTrigger: {
trigger: '.about-section1',
start: `top ${headerHeight}`,
toggleActions: 'restart none none none'
}
}).from(".about-section1 img", {
opacity: 0,
y: -30,
})
}
})
scrub: true
- ์คํฌ๋ฝ์ด ์คํ๋๋คscrub: 3
pin: true
์ ํธ๋ฆฌ๊ฑฐ๊ฐ ๊ณ ์ ๋๋ค.pin: '.selector'
์ ํน์ ์๋ฆฌ๋จผํธ๊ฐ ๊ณ ์ ๋๋ค.pinSpacing: true
์ ๊ณ ์ ๋๋ ์๋ฆฌ๋จผํธ ์๋์ padding์ ์ค์ ์คํฌ๋กค์ด ๋๋ ํ ๋ค์ ์๋ฆฌ๋จผํธ๊ฐ ์ด์ด์ ๋ณด์ผ ์ ์๋๋ก ๋ง๋ค์ด์ค๋ค. pinSpacing: "margin"
์ด๋ ๊ฒ ํ๋ฉด padding ๋์ margin์ ์ค๋ค.const tl = gsap.timeline();
tl.to('.box1', {x: 500, duration: 2})
.to('.box2', {y: 200, duration: 3})
const tl2 = gsap.timeline({
scrollTrigger: {
trigger: '.main',
start: 'top 20%',
end: 'top 80%'
}
})
tl2.to('.div1', {x: 500, duration: 2})
.to('.div2', {y: 200, duration: 3})
ScrollTrigger.create({
trigger: ".header",
start: "top 5%",
toggleClass: {targets: 'nav', className: 'active'}
});