728x90
๋ฐ์ํ
์ฌ๋ผ์ด๋ ์ดํํธ 02. ์ข๋ก ์์ง์ด๊ธฐ
javascript๋ฅผ ์ด์ฉํ์ฌ ์ฌ๋ผ์ด๋ ์ดํํธ๋ฅผ ๋ง๋ค์์ต๋๋ค. ์ด์ฌํ ๊ณต๋ถํ์ธ์!
์ฌ๋ผ์ด๋ ์ดํํธ 02
์๋ฐ์คํฌ๋ฆฝํธ
const sliderInner = document.querySelector(".slider__inner"); //์์ง์ด๋ ์์ญ
const slider = document.querySelectorAll(".slider"); //์ด๋ฏธ์ง
let currentIndex = 0;
sliderInner.style.transition = "all 0.6s";
setInterval(() => {
currentIndex = (currentIndex + 1) % slider.length;
sliderInner.style.transform = "translateX("+ -800 * currentIndex + "px)";
}, 2000);
GSAP
const slider = document.querySelectorAll(".slider");
let currentIndex = 0;
setInterval(() => {
currentIndex = (currentIndex + 1) % slider.length;
gsap.to(".slider__inner",{
duration : 0.6,
x : -800 * currentIndex,
});
}, 2000);
JQuery
let currentIndex = 0;
setInterval(() => {
currentIndex = (currentIndex +1) % $(".slider").length;
// sliderInner.style.transition = "all 0.6s"
// $(".slider__inner").css(
// "transform", "translateX("+ -800 * currentIndex +"px)"
// );
$(".slider__inner").css("position", "relative");
$(".slider__inner").animate({left : -800 * currentIndex},600)
}, 2000);
728x90
๋ฐ์ํ
'์ดํํธ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๋ง์ฐ์ค ์ดํํธ - ๋ง์ฐ์ค ๋ฐ๋ผ๋ค๋๊ธฐ (1) | 2022.09.06 |
---|---|
03. ์ฌ๋ผ์ด๋ ์ดํํธ - ์ข๋ก ์์ง์ด๊ธฐ ์ฐ์ (1) | 2022.09.02 |
03. ์ฌ๋ผ์ด๋ ์ดํํธ - ํธ๋์ง์ ํจ๊ณผ (6) | 2022.08.29 |
ํด์ฆ ์ดํํธ ๊ฐ๊ด์ ์ฌ๋ฌ ๋ฌธ์ 2 (10) | 2022.08.24 |
์์น ์ดํํธ 3 (3) | 2022.08.23 |
๋๊ธ