补间参数关键帧JS

将多个 补间参数 与特定的 可动画属性关联。

这种语法通过为每个单独的关键帧提供对 easedelaydurationmodifier 参数的访问,允许对动画进行非常精细的控制。

一个关键帧的默认duration等于动画总持续时间除以关键帧总数。

接受

一个数组,包含 补间参数

补间参数关键帧代码示例

import { animate } from 'animejs';

animate('.square', {
  x: [
    { to: '17rem', duration: 700, delay: 400 },
    { to: 0, duration: 700, delay: 800 },
  ],
  y: [
    { to: '-2.5rem', ease: 'out', duration: 400 },
    { to: '2.5rem', duration: 800, delay: 700 },
    { to: 0, ease: 'in', duration: 400, delay: 700 },
  ],
  scale: [
    { to: .5, duration: 700, delay: 400 },
    { to: 1, duration: 700, delay: 800 },
  ],
  rotate: { to: 360, ease: 'linear' },
  duration: 3000,
  ease: 'inOut', // ease applied between each keyframes if no ease defined
  playbackEase: 'ouIn(5)', // ease applied accross all keyframes
  loop: true,
});
<div class="medium row">
  <div class="square"></div>
</div>