<script src="/utils/lib/anime.min.js"></script>
anime({ targets: 'div', translateX: 250, rotate: '1turn', backgroundColor: '#FFF', duration: 800, // loop: true, // autoplay: true, // direction: 'alternate', // easing: 'linear' });
<input type="text" class="num">
anime({ targets: '.num', value: [0, 1000], round: 1, easing: 'easeInOutExpo' });
const animNum = anime({ targets: '.num', value: [0, 1000], round: 1, easing: 'easeInOutExpo' }); let btnPlay = document.querySelector('.btn-play'); let btnPause = document.querySelector('.btn-pause'); btnPlay.addEventListener('click', () => { animNum.play(); }); btnPause.addEventListener('click', () => { animNum.pause(); });
anime({ targets: '.rect div', keyframes: [ { translateX: 80 }, { translateY: 170 }, { translateX: -80 }, { translateY: 0 } ], duration: 2000, loop: true })
anime.stagger(value, {grid: [rows, columns]}, from: '')
anime({ targets: '.grid-anime span', scale: [ { value: .1, easing: 'easeOutSine', duration: 500 }, { value: 1, easing: 'easeInOutQuad', duration: 1200 } ], delay: anime.stagger(200, { grid: [14, 9], from: 'center' }), loop: true, });
创建动画 - 指定基本属性
let timelineAnime = anime.timeline({ targets: '.timeline-anime span', easing: 'easeInOutExpo', delay: anime.stagger(200, { grid: [14, 9], from: 'center' }), loop: true, });
添加动画
timelineAnime.add({ rotateZ: 180, translateY: anime.stagger(-10, { grid: [14, 9], from: 'center', axis: 'y' }), translateX: anime.stagger(-10, { grid: [14, 9], from: 'center', axis: 'x' }), }) timelineAnime.add({ borderRadius: 50 }) timelineAnime.add({ scale: 0.2, opacity: 0.2 }) timelineAnime.add({ opacity: 1, scale: [ { value: .1, easing: 'easeOutSine', duration: 100 }, { value: 1, easing: 'easeInOutQuad', duration: 500 } ], delay: anime.stagger(100, { grid: [14, 9], from: 'center' }), }) timelineAnime.add({ rotateZ: 180, translateY: anime.stagger(0, { grid: [14, 9], from: 'center', axis: 'y' }), translateX: anime.stagger(0, { grid: [14, 9], from: 'center', axis: 'x' }), }) timelineAnime.add({ borderRadius: 0 })
let barAnime = () => { anime({ targets: '.bar', translateX: () => anime.random(-1024, 1024), translateY: () => anime.random(-120, 120), scale: () => anime.random(1, 5), easing: 'linear', delay: anime.stagger(10), duration: 3000, complete: barAnime }) } barAnime()