label() V4

将特定时间位置与标签名称关联,以便在时间轴内轻松引用。
添加到时间轴后,标签可以用作时间位置

timeline.label(labelName, position);

参数

名称 接受
labelName 字符串
position (可选) 时间位置

返回

时间轴本身

可以与其他时间轴方法链式调用。

label() 代码示例

import { createTimeline } from 'animejs';

const tl = createTimeline()
.label('circle', 0)
.label('square', 500)
.label('triangle', 1000)
.add('.square', {
  x: '17rem',
  duration: 500,
}, 'square')
.add('.circle', {
  x: '13rem',
  duration: 1000,
}, 'circle')
.add('.triangle', {
  x: '15rem',
  rotate: '1turn',
  duration: 500,
}, 'triangle');
<div class="large row">
  <div class="medium pyramid">
    <div class="triangle"></div>
    <div class="square"></div>
    <div class="circle"></div>
  </div>
</div>