duration

定义所有动画属性或特定属性的持续时间(以毫秒为单位)。

接受

  • A Number equal to or greater than 0
  • A Function based value that returns a Number equal to or greater than 0

持续时间值大于 1e12 或等于 Infinity 会在内部被限制为 1e12(大约 32 年)。

默认

动画持续时间值(默认 1000)。

要全局更改默认值,请更新 engine.defaults 对象。

import { engine } from 'animejs';
engine.defaults.duration = 500;

持续时间代码示例

import { animate } from 'animejs';

const animation = animate('.square', {
  x: '17rem',
  rotate: {
    to: 360,
    duration: 1500, // Local duration only applied to rotate property
  },
  duration: 3000,  // Global duration applied to all properties
  loop: true,
  alternate: true
});
<div class="medium row">
  <div class="square"></div>
</div>