VitorLuizC/animate

can't stop animation from callback

VitorLuizC opened this issue · 1 comments

Animations can't be stoped from its callbacks.

const animation = animate(() => {
  animation.stop(); // it does not work.
});

animation.start();

When stop is called from callback it cancels AnimationFrame and clean handle, but after that requestAnimationFrame is immediatly assigned to handle and the animation keep running.

Maybe the same issue causes N animations at same time if start is called again.