ํด์ธ ์ฌ์ดํธ๋ฅผ ๋ํผ๋ฐ์ค๋ก ์ฐธ๊ณ ํ์ฌ ์ ์ํ ์
์๋ก๋ ๋ทฐํฐ ์น์ฌ์ดํธ
์คํฌ๋กค์ ๋ด๋ฆฌ๊ณ ์ฌ๋ฆผ์ ๋ฐ๋ผ ๋ฐ์ํ๋ ์ด๋ฒคํธ
์์ธํ ๊ธฐ๋ฅ ์ ๋ฆฌ๋ ์ฌ๊ธฐ ๐ https://velog.io/@imyoox/GSAP-ScrollTrigger
<div class="cont-wrap">
<div class="bg"></div>
<div class="group-text inner">
<h2 class="headline">
<div class="text"><span>ONLY</span><span>AT</span></div>
<div class="text lower"><span>YSL</span><span>beauty</span></div>
</h2>
</div>
</div>
gsap.set('.md-headline .text span',{yPercent:100})
intro = gsap.timeline({
scrollTrigger:{
trigger: ".sc-main-visual",
start: "0% 0%",
end: "+=500%",
scrub: 1,
pin: true,
}
})
intro
.to('.headline .text span',{ yPercent:-100, stagger:0.05, opacity:0 })
.addLabel('a')
// ๋ฉ์ธ ์ฌ์ง์ด ์๋ก 10px ์ฌ๋ผ๊ฐ๊ฒ
.to('.sc-main-visual .bg',3,{ yPercent:-10, },'a')
// ๊ฒ์ ๋ฐฐ๊ฒฝ ๋ฑ์ฅ
.to('.sc-slogan.xs',3,{ opacity:1, visibility: 'visible' },'a')
// 4์ค ๋ฌธ์ฅ ์๋์์ ์๋ก ๋ฑ์ฅ
.to('.md-headline .text span',3,{ yPercent:0, stagger:0.05, },'a')
// 4์ค ๋ฌธ์ฅ ์๋ก ์ฌ๋ผ์ง
.to('.md-headline .text span',3,{ delay:1, yPercent:-100, stagger:0.05, })
gsap.set
: GSAP ์คํ ์ ๋ฏธ๋ฆฌ ์
ํ
ํ๋ ๊ฐaddLabel('a')
a๊ฐ ์๋ ์คํฌ๋ฆฝํธ๋ ์์ฐจ๊ฐ ์๋ โ๏ธ๋์์โ๏ธ ํจ๊ป ์๋๋๋ค.
๊ฐ๊ฐ์ ํ์ด์ง๋ฅผ ํ๋ฉด ์๋์ ๋ด๋ ค๋์ ๋ค ์์ฐจ์ ์ผ๋ก ๋ํ๋๊ฒ ํ๋ค.
.sc-page-slide{
position: absolute;
top: 100vh; left: 0;
width: 100%; height: 0;
z-index: 10;
padding: 0;
}
absolute top:100vh
๋ก ์ ํํ ํ๋ฉด ์๋์ ์์น์์ผฐ๋ค..addLabel('a')
...(์๋ต)
.addLabel('b')
.to('.sc-page-slide .page1',3,{yPercent:-100, borderRadius:0 },'b')
.from('.sc-page-slide .page1 .headline',3,{ opacity:0, yPercent:100, },'b')
.to('.sc-page-slide .page2',3,{ yPercent:-100, borderRadius:0 })
.to('.sc-page-slide .page3',3,{ yPercent:-100, borderRadius:0 })
.to('.sc-page-slide .page4',3,{ yPercent:-100, borderRadius:0 })
.to('.sc-page-slide .group-page',{ yPercent:-100, borderRadius: '0 0 50% 50%' })
&.page1{z-index: 1;}
&.page2{z-index: 2;}
&.page3{z-index: 3;}
&.page4{z-index: 4;}
.swiper-slide-active img{
transform: scale(1.2);
border-radius: 600px;
box-shadow: 0px 100px 100px rgb(0 0 0);
}
์ฌ๋ผ์ด๋๊ฐ active ๋์์ ๋
ํฌ๊ธฐ๋ 1.2๋ฐฐ๊ฐ ๋๊ณ , ๋ชจ์๋ฆฌ๋ ๋ ๋ฅ๊ธ๊ฒ, ๊ทธ๋ฆผ์๋ฅผ ์ฃผ์ด ๋๋ณด์ด๋ ๊พธ๋ฐ ์์๋ฅผ ๊ตฌํํ์๋ค.
JavaScript์์ ๋ฐ์ํ ์ฒ๋ฆฌ๋ฅผ ํ ์ ์๋ ํจ์์ด๋ค.
CSS์์ ์ฌ์ฉํ๋ ๋ฏธ๋์ด์ฟผ๋ฆฌ ์กฐ๊ฑด์ ์๋ฐ์คํฌ๋ฆฝํธ์์ ๊ทธ๋๋ก ์ฌ์ฉํ ์ ์๋ค.
gsap.registerPlugin(ScrollTrigger);
ScrollTrigger.matchMedia({
"(min-width: 1280px)": function() {
// 1280px ์ด์์ผ ๋
@content
},
"(min-width: 768px, max-width: 1279px)": function() {
// 768px ์ด์, 1279px ์ดํ์ผ ๋
@content
},
"all": function() {
// ์ ์ฒด ํด์๋์์ ์ ์ฉ
@content
}
});
๊ฐ์ ๋ชจ์
์ ๊ฐ์ง ์์ญ์ด ๋ง์ ๋, ์ผ์ผ์ด ์ ํํ์ง ์๊ณ ํ ๋ฒ์ ์ฃผ๋ ๋ฐฉ๋ฒ
data-scroll ์ด๋ผ๋ data๊ฐ์ ๊ฐ์ ๋ชจ์ ์ด ์ ์ฉ๋๋ ์์ญ์ ๋ชจ๋ ๊ธฐ์ฌํ๋ค.
[data-scroll]{
overflow: hidden;
}
[data-scroll] span{
display: block;
}
CSS ์คํ์ผ ์ง์ ๊ฐ๋ฅ!
document.querySelectorAll('[data-scroll]').forEach(element => {
child=element.children[0];
gsap.from(child,{
scrollTrigger:{
trigger:element,
start:"0% 80%",
end:"100% 100%",
// markers:true,
scrub:1,
},
yPercent:100,
opacity:0,
});
});
child=element.children[0];
ํ๊ฒ์ด data-scroll์ด ์๋๊ณ ๊ทธ ์์์ด๋ฏ๋ก children
์ผ๋ก ํ์ธํ๋ ๋ฐฐ์ด์ด ์ ํ๋๋ค.
ํ๊ฒ์ ๋ฐฐ์ด์ ์ฒซ๋ฒ์งธ๋๊น children[0]
์ผ๋ก ์ ํํด์ฃผ์ด์ผ ํ๋ค.
forEach๋ฌธ์ผ๋ก data-scroll
์ด๋ผ๋ ๊ฐ์ด ์ฐ์ธ ๊ฐ์ฒด์ ๋ชจ๋ ๋ชจ์
์ด ๋ค์ด๊ฐ๊ฒ ํ์๋ค.