from

定义揭示波动的起始位置。当设置为 'auto' 时,方向会根据文本长度自动解析:文本增长时为 'left',文本缩短时为 'right'

接受

描述
'auto' 根据文本长度变化自动解析为 'left''right'
'left' 从左侧开始揭示
'center'(中心) 从中心开始揭示
'right' 从右侧开始揭示
'random' 以随机顺序揭示字符
数字 从指定的字符索引开始揭示

默认值

'auto'

from 代码示例

import { animate, scrambleText } from 'animejs';

const [ $p ] = utils.$('p');
const buttons = utils.$('button');

const froms = ['right', 'center', 'random'];

function play(from) {
  animate($p, {
    innerHTML: scrambleText({ from }),
  });
}

play(froms[0]);

buttons.forEach(($btn, i) => $btn.addEventListener('click', () => play(froms[i])));
<div class="large row">
  <p class="text-s text-mono">Control where the reveal wave starts from, whether left, center, right, or a specific character index.</p>
</div>
<div class="medium row">
  <fieldset class="controls">
    <button>right</button>
    <button>center</button>
    <button>random</button>
  </fieldset>
</div>