juliangarnier / anime

JavaScript animation engine
https://animejs.com
MIT License
50.4k stars 3.68k forks source link

Is it possible to control the main ticker / raf externally? #847

Open AlvaroHerreroDev opened 1 year ago

AlvaroHerreroDev commented 1 year ago

I wanted to sync the ticker on a Pixi app with anime, so the whole scene could be slowed down for example.

With gsap it can be done this way:

PIXI.ticker.shared.add( (deltaTime) => {            
  gsap.updateRoot(deltaTime);
});

Is there a way to do the same with anime? I see that you can pass the deltaTime to an animation instance, but it would be nice to be able to just do once for all animations like on the gsap example.

juliangarnier commented 1 year ago

This is coming in V4 (finishing writing tests and new documentation right now).

The implementation looks like this:

import { settings, tick } from 'animejs';

// Tells anime.js from not using its main loop
settings.useDefaultMainLoop = false;

// Manually tick anime.js main loop
PIXI.ticker.shared.add(tick);