位置简写

通过传递位置名称来定义目标和容器的位置。

接受

返回
'top' 顶部的 y 值
'bottom' 底部的 y 值
'left' 左侧的 x 值
'right' 右侧的 x 值
'center' 中心 x 或 y 值
'start' 等同于 'top''left',取决于轴向
'end' 等同于 'bottom''right',取决于轴向

位置简写代码示例

import { animate, onScroll } from 'animejs';

animate('.square', {
  x: '15rem',
  rotate: '1turn',
  duration: 2000,
  alternate: true,
  loop: true,
  ease: 'inOutQuad',
  autoplay: onScroll({
    container: '.scroll-container',
    enter: 'center top',
    leave: 'center bottom',
    debug: true
  })
});
<div class="scroll-container scroll-y">
  <div class="scroll-content grid square-grid">
    <div class="scroll-section padded">
      <div class="large centered row">
        <div class="label">scroll down</div>
      </div>
    </div>
    <div class="scroll-section padded">
      <div class="large row">
        <div class="square"></div>
      </div>
    </div>
    <div class="scroll-section">
    </div>
  </div>
</div>