Portfolio BLog: C5log

倍速/逆再生/フレーム範囲指定のコード

const animation = lottie.loadAnimation({
  container: document.querySelector('.lottie'), /* Lottieの入れ物要素を指定する */
  renderer: 'svg',
  loop: true,
  autoplay: true,
  path: 'https://assets5.lottiefiles.com/private_files/lf30_aurflyqv.json'
});
animation.setSpeed(2);  // 2倍速
animation.setSpeed(3);  // 3倍速

animation.setDirection(-1);  // 逆再生
animation.setDirection(1);   // 通常再生

animation.playSegments([1, 40], true);  // 再生範囲を1〜40フレームにする