๐ฑ ํ๋ด๋ ์ค ํจ๊ณผ : ์ด์ง๊ฐ ํจ๊ณผ ๐ฑ
ํ๋ด๋์ค(parallax)๋ ์๋ฏธ๋ก ์ฌ์ฉ์๊ฐ ์คํฌ๋กค๋ง์ ํ ๋ ๋ฐ์ํ๋ ์ด๋ฒคํธ(๋ฐฐ๊ฒฝ๊ณผ ์์๋ง๋ค ์๋ ๋ฐ ํฌ๊ธฐ์ ์ฐจ์ด๋ฅผ ์ฃผ์ด ์
์ฒด์ ์ผ๋ก ๋๊ปด์ง๊ฒ ํ๋ ํจ๊ณผ ๋ฑ)๋ฅผ ๋งํฉ๋๋ค.
์ด๋ฒ ์๊ฐ์๋ ์คํฌ๋กค์ ๋ด๋ฆด ๋ ๋๋ฒ, ์ด๋ฏธ์ง, ํ
์คํธ์ ๊ฐ ์์น๊ฐ์ ์ค์ฐจ๋ฅผ ์ฃผ์ด์ ๋ค๋ฅด๊ฒ ์ฃผ์ด ์ด์ง๊ฐ์ ์ฃผ๋ ํจ๊ณผ๋ฅผ ์ค์ตํด๋ณด๊ฒ ์ต๋๋ค.๐คฉ
์ถ๊ฐ๋ก ํ์ํ ์์ค๋ GSAP๋ก ์คํฌ๋กค ์ด๋ฒคํธ๋ฅผ ๋ถ๋๋ฝ๊ฒ ์๋ํ๊ธฐ ์ํด์ ์
๋๋ค~! ๊ทธ๋ผ ์ค์ตํ๋ฌ ๊ณ ๊ณ ๋ฆฅ~ ๐ ๐จ
#1. HTML / CSS ์ค์ ํ๊ธฐ
โ๏ธ HTML ๋ณด๊ธฐ
<nav id="parallax__nav" class="show">
<ul>
<li class="active"><a href="#section1">๋ฉ๋ด1</a></li>
<li><a href="#section2">๋ฉ๋ด2</a></li>
<li><a href="#section3">๋ฉ๋ด3</a></li>
<li><a href="#section4">๋ฉ๋ด4</a></li>
<li><a href="#section5">๋ฉ๋ด5</a></li>
<li><a href="#section6">๋ฉ๋ด6</a></li>
<li><a href="#section7">๋ฉ๋ด7</a></li>
<li><a href="#section8">๋ฉ๋ด8</a></li>
<li><a href="#section9">๋ฉ๋ด9</a></li>
</ul>
</nav>
<!-- //parallax__nav -->
<main id="parallax__cont">
<div id="contents">
<section id="section1" class="content__item">
<span class="content__item__num">01</span>
<h1 class="content__item__title">section1</h1>
<figure class="content__item__imgWrap">
<div class="content__item__img"></div>
</figure>
<p class="content__item__desc">
๋ฏธ๋๋ ํ์ฌ ์ฐ๋ฆฌ๊ฐ ๋ฌด์์ ํ๋๊ฐ์ ๋ฌ๋ ค ์๋ค.
</p>
</section>
<!-- //section1 -->
<section id="section2" class="content__item">
<span class="content__item__num">02</span>
<h1 class="content__item__title">section2</h1>
<figure class="content__item__imgWrap">
<div class="content__item__img"></div>
</figure>
<p class="content__item__desc">
์ด์ ๋ก ๋์๊ฐ ์ ์๋ค. ์๋ํ๋ฉด ๋๋ ์ด์ ์๋ ๋ค๋ฅธ ์ฌ๋์ด ๋์๊ธฐ
๋๋ฌธ์ด๋ค.
</p>
</section>
<!-- //section2 -->
<section id="section3" class="content__item">
<span class="content__item__num">03</span>
<h1 class="content__item__title">section3</h1>
<figure class="content__item__imgWrap">
<div class="content__item__img"></div>
</figure>
<p class="content__item__desc">
์ธ์ ๋ ํ์ฌ์ ์ง์คํ ์ ์๋ค๋ฉด ํ๋ณตํ ๊ฒ์ด๋ค.
</p>
</section>
<!-- //section3 -->
<section id="section4" class="content__item">
<span class="content__item__num">04</span>
<h1 class="content__item__title">section4</h1>
<figure class="content__item__imgWrap">
<div class="content__item__img"></div>
</figure>
<p class="content__item__desc">
๋จผ์ ํ ๊ฝ์ ๋จผ์ ์ง๋ค ๋จ๋ณด๋ค ๋จผ์ ๊ณต์ ์ธ์ฐ๋ ค๊ณ ์กฐ๊ธํ ์๋๊ฒ์ด
์๋๋ค.
</p>
</section>
<!-- //section4 -->
<section id="section5" class="content__item">
<span class="content__item__num">05</span>
<h1 class="content__item__title">section5</h1>
<figure class="content__item__imgWrap">
<div class="content__item__img"></div>
</figure>
<p class="content__item__desc">
์ข์ ์ฑ๊ณผ๋ฅผ ์ป์ผ๋ ค๋ฉด ํ ๊ฑธ์ ํ ๊ฑธ์์ด ํ์ฐจ๊ณ ์ถฉ์คํ์ง ์์ผ๋ฉด ์
๋๋ค.
</p>
</section>
<!-- //section5 -->
<section id="section6" class="content__item">
<span class="content__item__num">06</span>
<h1 class="content__item__title">section6</h1>
<figure class="content__item__imgWrap">
<div class="content__item__img"></div>
</figure>
<p class="content__item__desc">
์ฑ๊ณต์ ๋น๊ฒฐ์ ๋จ ํ ๊ฐ์ง, ์ํ ์ ์๋ ์ผ์ ๊ด์ ์ผ๋ก ์ง์คํ๋
๊ฒ์ด๋ค.
</p>
</section>
<!-- //section6 -->
<section id="section7" class="content__item">
<span class="content__item__num">07</span>
<h1 class="content__item__title">section7</h1>
<figure class="content__item__imgWrap">
<div class="content__item__img"></div>
</figure>
<p class="content__item__desc">
๊ฟ์ ๊ณ์ ๊ฐ์งํ๊ณ ์์ผ๋ฉด ๋ฐ๋์ ์คํํ ๋๊ฐ ์จ๋ค.
</p>
</section>
<!-- //section7 -->
<section id="section8" class="content__item">
<span class="content__item__num">08</span>
<h1 class="content__item__title">section8</h1>
<figure class="content__item__imgWrap">
<div class="content__item__img"></div>
</figure>
<p class="content__item__desc">
ํํ ์ฌ๋๋ค์ ๊ธฐํ๋ฅผ ๊ธฐ๋ค๋ฆฌ๊ณ ์์ง๋ง ๊ธฐํ๋ ๊ธฐ๋ค๋ฆฌ๋ ์ฌ๋์๊ฒ ์กํ์ง
์๋ ๋ฒ์ด๋ค.
</p>
</section>
<!-- //section8 -->
<section id="section9" class="content__item">
<span class="content__item__num">09</span>
<h1 class="content__item__title">section9</h1>
<figure class="content__item__imgWrap">
<div class="content__item__img"></div>
</figure>
<p class="content__item__desc">
์ด๋ฏธ๋๋๋ฒ๋ฆฐ ์ผ์ ํํํ๊ธฐ ๋ณด๋ค๋ ํ๊ณ ์ถ์๋ ์ผ๋ค์ ํ์ง๋ชปํ ๊ฒ์
ํํํ๋ผ.
</p>
</section>
<!-- //section9 -->
</div>
</main>
<!-- //main -->
<aside id="parallax__info">
<div class="scroll">scrollTop : <span>0</span>px</div>
</aside>
<!-- //parallax__info -->
html์ ๋ฉ๋ด, ์น์
, ์น์
์ ๋ค์ด๊ฐ ์ฝํ
์ธ (์ด๋ฏธ์ง์ ํ
์คํธ)๋ฑ์ ๋งํฌ์
ํด์ฃผ์๋ฉด ๋ฉ๋๋ค.
์ด ๋ ์น์
์ ๋ค์ด๊ฐ๋ ์ฝํ
์ธ ๋ค์๊ฒ ์ ํ์๋ค์ ๋ถ์ฌํ์ฌ ์คํฌ๋ฆฝํธ์ ์คํ์ผ์ ์ฃผ๋ ๋ฐ ์ด๋ ค์์ด ์๋๋ก ํฉ๋๋ค:)
โ๏ธ CSS ๋ณด๊ธฐ
/* parallax__nav */
#parallax__nav {
position: fixed;
right: 20px;
top: -200px;
z-index: 2000;
background-color: rgba(95, 95, 95, 0.4);
padding: 20px 30px;
border-radius: 50px;
transition: top 0.4s ease;
}
#parallax__nav.show {
top: 20px;
}
#parallax__nav li {
display: inline;
margin: 0 5px;
}
#parallax__nav li a {
display: inline-block;
/* width: 30px; */
height: 30px;
padding: 5px 20px;
text-align: center;
line-height: 30px;
}
#parallax__nav li.active a {
background: #fff;
color: #000;
border-radius: 20px;
box-sizing: content-box;
}
#parallax__cont {
max-width: 1600px;
/* background-color: rgba(255,255,255,0.1); */
width: 98%;
margin: 0 auto;
}
.content__item {
width: 1000px;
max-width: 70vw;
margin: 30vw auto;
/* background-color: rgba(255,255,255,0.1); */
text-align: left;
margin-right: 0;
position: relative;
padding-top: 10vw;
}
.content__item:nth-child(even) {
margin-left: 0;
text-align: right;
}
.content__item__num {
font-size: 35vw;
font-family: "Lato";
font-weight: 100;
position: absolute;
left: -5vw;
top: -16vw;
opacity: 0.07;
z-index: -2;
}
.content__item:nth-child(even) .content__item__num {
right: -5vw;
left: auto;
}
.content__item__title {
font-weight: 400;
text-transform: capitalize; /* ์ฒซ๊ธ์๋ง ๋๋ฌธ์ */
}
.content__item__imgWrap {
width: 100%;
padding-bottom: 56.25%;
background: #000;
position: relative;
overflow: hidden;
z-index: -1;
}
.content__item__img {
position: absolute;
width: 110%;
height: 110%;
left: -5px;
top: -5px;
background-image: url(../assets/img/city_bg02.jpg);
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
filter: saturate(0%);
/* transition: all 1s; */
}
.content__item:nth-child(2) .content__item__img {
background-image: url(../assets/img/city_bg03.jpg);
}
.content__item:nth-child(3) .content__item__img {
background-image: url(../assets/img/city_bg04.jpg);
}
.content__item:nth-child(4) .content__item__img {
background-image: url(../assets/img/city_bg05.jpg);
}
.content__item:nth-child(5) .content__item__img {
background-image: url(../assets/img/Mountian_bg01.jpg);
}
.content__item:nth-child(6) .content__item__img {
background-image: url(../assets/img/Mountian_bg02.jpg);
}
.content__item:nth-child(7) .content__item__img {
background-image: url(../assets/img/Mountian_bg03.jpg);
}
.content__item:nth-child(8) .content__item__img {
background-image: url(../assets/img/Mountian_bg04.jpg);
}
.content__item:nth-child(9) .content__item__img {
background-image: url(../assets/img/Mountian_bg05.jpg);
}
.content__item__desc {
font-size: 4vw;
line-height: 1.4;
margin-top: -5vw;
margin-left: -4vw;
word-break: keep-all;
}
.content__item:nth-child(even) .content__item__desc {
margin-left: auto;
margin-right: -4vw;
}
/* ๋ฐ์ํ */
@media (max-width: 800px) {
#parallax__cont {
margin-top: 70vw;
}
#parallax__nav {
padding: 10px;
right: auto;
left: 10px;
top: 50%;
transform: translateY(-50%);
border-radius: 5px;
background-color: rgba(0, 0, 0, 0.8);
}
#parallax__nav li {
display: block;
margin: 5px;
}
#parallax__nav li a {
font-size: 14px;
padding: 5px;
border-radius: 5px;
height: auto;
line-height: 1;
}
#parallax__nav li.active a {
border-radius: 5px;
}
}
/* ํ๋ด๋ ์ค ์ธํฌ */
#parallax__info {
position: fixed;
left: 20px;
bottom: 20px;
z-index: 2000;
background: rgba(0, 0, 0.4);
color: #fff;
padding: 20px;
border-radius: 10px;
}
#parallax__info li,
.scrollTop {
line-height: 1.4;
}
์น์
์ ์ฝํ
์ธ ์์ ๋ณ์ด ์๋ ํ ๋ฒ์ ๋์ํ๋๋ก ํ๋ ค๋ฉด ๊ฐ ์ฝํ
์ธ ์์๋ค์๊ฒ ์์ฑ์ ๋ถ์ฌํ์ง ์๊ณ ๊ณตํต ์ ํ์์๊ฒ๋ง ์์ฑ์ ๋ถ์ฌํ๋ฉด ๋ฉ๋๋ค.
๋ฐ๋๋ก ๊ฐ ์ฝํ
์ธ ์์๋ณ๋ก ์์ง์ด๊ฒ ํ๊ณ ์ถ๋ค๋ฉด ๊ฐ ์ฝํ
์ธ ์์๋ง๋ค ์๋๋ฉ์ด์
์ ์ค์ ํด์ฃผ๋ฉด ๋ฉ๋๋ค.
#2. JAVASCRIPT : ์คํฌ๋ฆฝํธ๋ก ํ๋ด๋์ค ํจ๊ณผ ์ฃผ๊ธฐ
๋จผ์ ์ ์ฒด์ ์ธ ํ๋ฆ์ ๋ณด๊ณ ์ฃผ์๊ณผ ํจ๊ป ์คํฌ๋ฆฝํธ๊ฐ ์ด๋ป๊ฒ ์๋๋๋์ง ํ์ธํด๋ด ์๋ค! ๐ฅน
์ค๋ ์คํฌ๋ฆฝํธ์์๋ ์ง๋ ์๊ฐ๊ณผ ๊ฐ์ด ์ฌ๊ทํจ์๋ฅผ ์ฌ์ฉํ์ฌ ์คํฌ๋ฆฝํธ๋ฅผ ์์ฑํ์์ต๋๋ค.
์ฆ ์ค๋์ ์คํฌ๋ฆฝํธ ํฌ์ธํธ๋! ์ฌ๊ทํจ์์ ์ด์ง๊ฐ์ ์ฃผ๋๋ก ์ด๋ ๊ฑฐ๋ฆฌ์ ์ค์ฐจ๋ฅผ ๊ตฌํ๋ ์, ๊ทธ๋ฆฌ๊ณ gsap์ ์ด์ฉํ ์คํฌ๋กค ์๋๋ฉ์ด์
๊ตฌํ ์
๋๋ค~!
๊ทธ๋ผ ์ฝ๋๋ณด๋ฌ ์~~ ํด๋ณด์์~๐๐จ (์ฌ๊ทํจ๊ท์ ๋ํ ์ค๋ช
์ ํ๋ด๋ ์ค04๋ฒ์ ์ฐธ๊ณ ํด์ฃผ์ธ์~)
๐ก ์ ์ฒด ์คํฌ๋ฆฝํธ ๋ณด๊ธฐ
//ํจ์ ์ค์
function scroll(){
//01 scrollTop๊ฐ ๊ตฌํ๊ณ ๊ฐ์ ์ ํ ์์์ ์ถ๋ ฅ
let scrollTop = window.pageYOffset || document.documentElement.scrollTop;
document.querySelector("#parallax__info span").innerText = Math.ceil(scrollTop);
//02 ์ด์ง๊ฐ ํจ๊ณผ ์ฃผ๊ธฐ
document.querySelectorAll(".content__item").forEach(item => {
//์ ํ์
//์ ํํ ์ฝํ
์ธ (๋๋ฒ, ์ด๋ฏธ์ง, ํ
์คํธ)๋ค์ ํ๊ฒ(๋ณ์)์๊ฒ ์ค์ ํ๋ค.
const taget1 = item.querySelector(".content__item__img");
const taget2 = item.querySelector(".content__item__desc");
const taget3 = item.querySelector(".content__item__num");
//์ด๋์ํฌ ๊ฑฐ๋ฆฌ (์ค์ฐจ์ฃผ๊ธฐ)
//ํ์ฌ ์คํฌ๋กค ํ ๊ฐ์ด 1000์ผ ๊ฒฝ์ฐ -item.offsetTop(์น์
์ ์์ ์คํฌ๋กค๊ฐ ์์น)๋ฅผ ํ๋ฉด 0์ด ๋์จ๋ค. ์ด๋ ์คํฌ๋กค์ ๋ด๋ฆฌ๋ฉด scrollTop์ ๋ค์ ๋ณธ๋์ ๊ฐ์ผ๋ก ๋์์ค๋ฉฐ ๋ด๋ ธ์ ๋์ ๊ฐ์์ ๋ค์ item.offsetTop์ ๋บ์ ๋ ๋์ค๋ ๊ฐ์ 0.1์ ๊ณฑํ ๊ฒฝ์ฐ ๋์ค๋ ๊ฐ์ด ๋ณ์์๊ฒ ๋์
๋๋ ๊ฒ์ด๋ค.
//scrollTop๊ณผ item.offsetTop๊ฐ์ ๊ฐ๊ธฐ ๋๋ฌธ์ 0์ด ๋์ค๋ ๊ฒ.
//์ฆ scrollTop์ด content__item(์น์
)์ ์์ ์์น ๊ฐ์ ๋๋ฌํ์ ๋ ๊ฐ์ 0์ผ๋ก ๋ง๋ ๋ค ๋ค์ scrollTop์ด ์ด๋ํ ๋ ๋์ค๋ ๊ฐ์ ์ํ๋ ์ค์ฐจ๊ฐ์ ๊ณฑํ์ฌ ๋ฐํ๋๋ ๊ฐ์ ๊ตฌํ๋ค. ๊ทธ ๊ฐ์ด y์ถ์ ์ด๋ ๊ฑฐ๋ฆฌ๊ฐ ๋๋ค.
//๋ค์ content__item(์น์
)์ ๋๋ฌํ ๊ฒฝ์ฐ ๊ฐ์ ๋ค์ 0์ด ๋๋ค.
let offset1 = (scrollTop - item.offsetTop) * 0.1;
let offset2 = (scrollTop - item.offsetTop) * 0.15;
let offset3 = (scrollTop - item.offsetTop) * 0.2;
//03 GSAP
// ์คํฌ๋ฆฝํธ๋ก ์คํ์ผ์ ์ค์ ํ ๊ฒฝ์ฐ : css์คํ์ผ ์ค transform์ ํตํด ์ด๋ฏธ์ง์ ํ
์คํธ์ ๊ฐ ๊ณ ์ ์์น์์ ์์ง์ด๋ ค๋ ๊ฑฐ๋ฆฌ๋ฅผ ์ค์ ํ๋ค. ๊ฐ๊ฐ์ด ์ฝํ
์ธ ๋ค์ ์ด๋ ๊ฑฐ๋ฆฌ๊ฐ ๋ค๋ฅด๋ฏ๋ก ์คํฌ๋กค์ด ์์ง์ผ ๋ ์ด์ง๊ฐ์ ์ค๋ค.
// taget1.style.transform = `translateY(${offset}px)`;
// taget2.style.transform = `translateX(${offset}px)`;
//gsap์ผ๋ก ์คํ์ผ ์ฃผ๊ธฐ : ๋ ๋ง์ ์ ๋๋ฉ์ด์
์์ฑ ์ค์ ์ด ๊ฐ๋ฅํ๋ฉฐ ์์ง์์ด ๋ถ๋๋ฝ๋ค. (ํ ๋ฒ์ ์คํ์ผ์ ์ ์ธํ ์ ์์ด ํธ๋ฆฌ) : ์ฃผ์ํ ์ ์ ๊ผญ gsap์ CDN์ ๊ฐ์ ธ์์ผ ํ๋ค๋ ๊ฒ.
//์คํ์ผ์ ์ค ์์, {duration : ์ง์์๊ฐ, translateX or Y(gsap์์๋ x, y): ์ ํํ ์ถ ๋ฐฉํฅ์ผ๋ก ์ด๋ํ ๊ฐ, ease: ์ ํ ํจ๊ณผ (์์ง์ ์ค์ : ์์๊ณผ ๋์ ์๋ ์กฐ์ ๋ฑ)}
gsap.to(taget1, {duration: .3, y: offset1, ease: "power4.out"});
gsap.to(taget2, {duration: .3, y: offset2});
gsap.to(taget3, {duration: .3, y: offset2, ease: "expo.out"});
});
//04 : 1์ด์ 60๋ฒ ์คํ
//ํจ์๊ฐ ๋ฌดํํ๊ฒ ๋ฐ๋ณต๋์ด๋ ํ ๋ฒ ์์ง์ผ ๋ 60๋ฒ๋ง ์คํ์ด๋ผ๋ ์ ํ์ด ๊ฑธ๋ ค์๊ธฐ ๋๋ฌธ์ ์๋ฒ๊ฐ ๋ค์ด์ด ๋์ง ์๋๋ค.
requestAnimationFrame(scroll);
}
scroll(); //์คํ๋ฌธ
ํต์ฌ ์๋ฐ์คํฌ๋ฆฝํธ ๐
document.querySelectorAll(".content__item").forEach(item => {
let offset1 = (scrollTop - item.offsetTop) * 0.1; //100์ผ ๊ฒฝ์ฐ 10
let offset2 = (scrollTop - item.offsetTop) * 0.15; //100์ผ ๊ฒฝ์ฐ 15
let offset3 = (scrollTop - item.offsetTop) * 0.2; //100์ผ ๊ฒฝ์ฐ 20
});
1. scrollTop์ด item.offsetTop(= content__item.offsetTop)์ ์์ ์์น ๊ฐ์ ๋๋ฌํ์ ๋ ๊ฐ์ 0์ผ๋ก ๋ง๋ ๋ค ๋ค์ scrollTop์ด ์ด๋ํ ๋ ๋์ค๋ ๊ฐ์ ์ํ๋ ์ค์ฐจ๊ฐ์ ๊ณฑํ์ฌ ๋ฐํ๋๋ ๊ฐ์ ๋ณ์์ ๋์
ํฉ๋๋ค.
2. ๋ณ์์ ๋์
๋ ๊ฐ์ด ๋ฐ๋ก ๋ค์์ ์ค์ ํ translateY์ ์ด๋ ๊ฑฐ๋ฆฌ๊ฐ ๋ฉ๋๋ค. ์ฆ 0์์ 100๋งํผ ์ด๋ํ๋ค ๊ฐ์ ํ์ฌ ๊ณฑํ ๊ฐ์ด 0.1์ผ ๋ Y์ถ์ผ๋ก 10px์ ์์ง์ด๊ฒ ๋๋ ๊ฒ์
๋๋ค.
3. ๊ทธ ๋ค ๋ค์ item.offsetTop(= content__item)์ ๋๋ฌํ ๊ฒฝ์ฐ ๊ฐ์ ๋ค์ 0์ด ๋ฉ๋๋ค.
document.querySelectorAll(".content__item").forEach(item => {
gsap.to(taget1, {duration: .3, y: offset1, ease: "power4.out"});
gsap.to(taget2, {duration: .3, y: offset2});
gsap.to(taget3, {duration: .3, y: offset2, ease: "expo.out"});
});
1. gsap์ ์ฌ์ฉํ์ฌ CSS ์์ง์ ์ค์ ์ ํด์ค ๊ฒฝ์ฐ ๊ธฐ๋ณธ ์คํฌ๋ฆฝํธ๋ก ๊ตฌํํ๋ ๊ฒ๋ณด๋ค ๋ ๋ง์ ์์ฑ๊ณผ ๋ถ๋๋ฌ์ด ์์ง์์ ์ค์ ํ ์ ์๊ฒ ๋ฉ๋๋ค.
2. ์ฌ์ฉ ๋ฐฉ๋ฒ์ ์คํ์ผ์ ์ค ์์, {duration : ์ง์์๊ฐ, translateX or Y(gsap์์๋ x, y): ์ถ ๋ฐฉํฅ์ผ๋ก ์ด๋ํ ๊ฐ, ease: ์ ํ ํจ๊ณผ (์์ง์ ์ค์ : ์์๊ณผ ๋์ ์๋ ์กฐ์ ๋ฑ)}์ผ๋ก ์์ฑํ์๋ฉด ๋ฉ๋๋ค.
3. ์ด ๋ translateY์ offset1์ ๋์
ํ๊ธฐ ๋๋ฌธ์ ๋ง์ฝ ์ ์ฒด 100px์ ์์ง์ผ ๊ฒฝ์ฐ translateY๋ 10px์ ์์ง์ด๊ฒ ๋ฉ๋๋ค.
TIP! ์ข ๋ ๋ค์ํ ease๋ฅผ ์ค์ ํ๊ณ ์ถ์ ๊ฒฝ์ฐ GSAP ํํ์ด์ง์ ๋ค์ด๊ฐ์ ํ์ธํ์๋ฉด ๋ฉ๋๋ค! ๋ํ GSAP์ ์ฌ์ฉํ ๊ฒฝ์ฐ ๋ฐ๋์ CDN์ ๊ฐ์ ธ์์ผ ํฉ๋๋ค!!
๐ ์ ๋ฆฌ ๐
2. ๋ค์ ์์ง์ธ scrollTop๊ฐ์ด 700์ผ ๋ ๋ค์ ์น์ 1์ offsetTop๊ฐ์ ๋ปฐ ๊ฒฝ์ฐ 200์ด ๋๋ฉฐ * 0.1์ ํ์ ๋ 20์ ๋ฐํํ๊ฒ ๋ฉ๋๋ค. ์ฆ ์ต์ข ์ ์ผ๋ก translateY์๊ฒ ์ด ๊ฐ์ ๋์ ํ๊ฒ ๋๋ฉด ์คํฌ๋กค์ ๋ด๋ฆด ๋ ํด๋น ์ปจํ ์ธ ๊ฐ 20px์ฉ ๋ด๋ ค๊ฐ๊ฒ ๋ฉ๋๋ค. ์ด๋ ์ด๋ ํจ๊ณผ๋ฅผ ๋ ํฌ๊ฒ ํ๊ณ ์ถ์ ๊ฒฝ์ฐ ๊ณฑํ๋ ๊ฐ์ ๋ ํฌ๊ฒ ์ค์ ํ์๋ฉด ๋ฉ๋๋ค.
3. ๊ทธ ๋ค ๋ค์ ์น์ ๊ฐ์ธ 1000์ ๋์์ ๋ scrollTop๊ฐ์ ๋ค์ 0์ด ๋ฉ๋๋ค. ๋๋ฌธ์ ๊ณ์ํด์ ๋ชจ๋ content__item๋ค์ ์ ๋๋ฉ์ด์ ์ด ์๋๋๋ ๊ฒ ์ ๋๋ค.
'EFFECT' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[EFFECT] ๋ง์ฐ์ค ํจ๊ณผ 04 : ์ด๋ฏธ์ง ํจ๊ณผ (3) | 2022.09.23 |
---|---|
[EFFECT] ๋ง์ฐ์ค ํจ๊ณผ 03 : ์กฐ๋ช ํจ๊ณผ (2) | 2022.09.23 |
[EFFECT] ์ฌ๋ผ์ด๋ ํจ๊ณผ 04 : ๋ฒํผ์ผ๋ก ์ด๋ฏธ์ง ์ด๋์ํค๊ธฐ! (2) | 2022.09.19 |
[EFFECT] ๋ง์ฐ์ค ํจ๊ณผ 02 : ์ปค์ ๋ฐ๋ผ๋ค๋๊ธฐ (2) | 2022.09.19 |
[EFFECT] ํ๋ด๋ ์ค ํจ๊ณผ 04 : ๋ํ๋ด๊ธฐ ํจ๊ณผ (2) | 2022.09.19 |
๋๊ธ