位置速记

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

接受

返回
'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>