Open taenykim opened 2 years ago
ํด๋น ๊ฐ๋งํผ ์ด๋ํ๋ ๊ฒ์ด ์๋๋ผ ํด๋น ๊ฐ์ผ๋ก ์ด๋ํ๋ ๊ฒ ISSUE resolve
anime({
targets: ".el.relative-values",
translateX: {
value: "*=2.5", // 100px * 2.5 = '250px'
duration: 1000,
},
width: {
value: "-=20px", // 28 - 20 = '8px'
duration: 1800,
easing: "easeInOutSine",
},
rotate: {
value: "+=2turn", // 0 + 2 = '2turn'
duration: 1800,
easing: "easeInOutSine",
},
direction: "alternate",
});
- ์๋๊ฐ์ผ๋ก value๋ฅผ ์ ์ด์ฃผ๋ฉด ์๋์ ์ผ๋ก ์ ์ด๊ฐ ๊ฐ๋ฅํ๋ค.
var logEl = document.querySelector('.battery-log');
var battery = {
charged: '0%',
cycles: 120
}
anime({
targets: battery,
charged: '100%',
cycles: 130,
round: 1,
easing: 'linear',
update: function() {
logEl.innerHTML = JSON.stringify(battery);
}
});
anime({
targets: ".specific-prop-params-demo",
translateX: {
value: 250,
duration: 800,
},
rotate: {
value: 360,
duration: 1800,
easing: "easeInOutSine",
},
scale: {
value: 2,
duration: 1600,
delay: 1000,
easing: "easeInOutQuart",
},
delay: 3000, // All properties except 'scale' inherit 250ms delay
});
๋ง์ฝ ์ด๋ฐ ํํ์ด๋ฉด ๊ณตํต delay๋ scale ์ธ ๋ชจ๋ ์์ฑ์ ์ ์ฉ๋๊ณ , scale์ 1000์ผ๋ก ๊ฐ์ธ ์์ฑ์ผ๋ก ์ ์ฉ๋๋ค.
anime({
targets: '.function-based-params-demo .el',
translateX: 270,
direction: 'alternate',
loop: true,
delay: function(el, i, l) {
return i * 100;
},
endDelay: function(el, i, l) {
return (l - i) * 100;
}
});
์๋ ๊ฒ ํจ์๋ก๋ ์์ฑ๊ฐ๋ฅ, target๊ณผ, index, total length ์ ์ ๊ทผ์ด ๊ฐ๋ฅํ๋ค
anime({
targets: ".function-based-values-demo .el",
translateX: (el: HTMLElement) => {
return el.getAttribute("data-x");
},
translateY: (el: HTMLElement, i: number) => {
return 50 + -50 * i;
},
scale: (el: HTMLElement, i: number, l: number) => {
return l - i + 0.25;
},
rotate: () => {
return anime.random(-360, 360);
},
borderRadius: () => {
return ["50%", anime.random(10, 35) + "%"];
},
duration: () => {
return anime.random(1200, 1800);
},
delay: () => {
return anime.random(0, 400);
},
direction: "alternate",
loop: true,
});
var colorsExamples = anime.timeline({
endDelay: 1000,
easing: 'easeInOutQuad',
direction: 'alternate',
loop: true
})
.add({ targets: '.color-hex', background: '#FFF' }, 0)
.add({ targets: '.color-rgb', background: 'rgb(255,255,255)' }, 0)
.add({ targets: '.color-hsl', background: 'hsl(0, 100%, 100%)' }, 0)
.add({ targets: '.color-rgba', background: 'rgba(255,255,255, .2)' }, 0)
.add({ targets: '.color-hsla', background: 'hsla(0, 100%, 100%, .2)' }, 0)
.add({ targets: '.colors-demo .el', translateX: 270 }, 0);
.add({
targets: '.offsets-demo .el.circle',
translateX: 250,
}, '-=600') // relative offset
.add({
targets: '.offsets-demo .el.triangle',
translateX: 250,
}, 400); // absolute offset
+=number
or -=number
๋ ์ด์ ์ ๋๋ฉ์ด์
์์ ์๋์ ์ธ ์๊ฐ์ผ๋ก ๋ถ์ฌ๋๊ณ ,number
๋ ์ ๋์ ์ธ ์๊ฐ์ผ๋ก ๋ถ์ฌ๋จ.anime({
targets: '.property-keyframes-demo .el',
translateX: [
{ value: 250, duration: 1000, delay: 500 },
{ value: 0, duration: 1000, delay: 500 }
],
translateY: [
{ value: -40, duration: 500 },
{ value: 40, duration: 500, delay: 1000 },
{ value: 0, duration: 500, delay: 1000 }
],
scaleX: [
{ value: 4, duration: 100, delay: 500, easing: 'easeOutExpo' },
{ value: 1, duration: 900 },
{ value: 4, duration: 100, delay: 500, easing: 'easeOutExpo' },
{ value: 1, duration: 900 }
],
scaleY: [
{ value: [1.75, 1], duration: 500 },
{ value: 2, duration: 50, delay: 1000, easing: 'easeOutExpo' },
{ value: 1, duration: 450 },
{ value: 1.75, duration: 50, delay: 1000, easing: 'easeOutExpo' },
{ value: 1, duration: 450 }
],
easing: 'easeOutElastic(1, .8)',
loop: true
});
anime({
targets: ".staggering-easing-demo .el",
translateX: 270,
delay: anime.stagger(1000, { easing: "easeOutQuad" }),
});
anime({
targets: ".staggering-grid-demo .el",
scale: [
{ value: 2, easing: "easeInOutQuad", duration: 200 },
{ value: 1, easing: "easeInOutQuad", duration: 300 },
],
delay: anime.stagger(200, { grid: [14, 5], from: "center" }),
});
anime({
targets: ".staggering-axis-grid-demo .el",
translateX: anime.stagger(10, { grid: [14, 5], from: "first", axis: "x" }),
translateY: anime.stagger(10, { grid: [14, 5], from: "first", axis: "y" }),
rotateZ: anime.stagger([0, 90], { grid: [14, 5], from: "first", axis: "x" }),
delay: anime.stagger(100, { grid: [14, 5], from: "first" }),
easing: "easeInOutQuad",
duration: 700,
});
const animation = anime({
...
autoplay: false
});
animation.play();
animation.pause();
animation.restart();
animation.reverse();
animation.seek(timeStamp); /* timeStamp๋ก ์๊ฐ์ด๋. animation.duration * percent */
const ani = anime({})
ani.finished.then(() => {
console.log("hey");
});
https://animejs.com/documentation/