autoplay

定义动画的播放模式。

当动画被添加到时间轴时,自动播放参数不起作用,并且会被覆盖为 false

接受

布尔值 | onScroll()

  • If set to true the animation plays automatically
  • If set to false the animation has to be manually played
  • If set to onScroll() the animation will starts when the scroll thresholds conditions are met

默认

true

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

import { engine } from 'animejs';
engine.defaults.autoplay = false;

自动播放代码示例

animate('.autoplay-true', {
  x: '17rem',
  autoplay: true, // Default
});

animate('.autoplay-false', {
  x: '17rem',
  autoplay: false,
});
<div class="medium row">
  <div class="circle autoplay-true"></div>
  <div class="padded label">autoplay: true</div>
</div>
<div class="medium row">
  <div class="circle autoplay-false"></div>
  <div class="padded label">autoplay: false</div>
</div>