anime icon indicating copy to clipboard operation
anime copied to clipboard

feature: kill animation instance

Open NickRimer03 opened this issue 5 years ago • 9 comments

First of all it is really the great animation library! Many thanks!

Is your feature request related to a problem? Please describe. I was surprised when kill animation instance possibility was not found. anime.remove(targets) is not the way I'm looking for because of this method doesn't kill the animation at all, it just clears its target objects (rather it clears this target from all possible animations if I understand). So it seems that animation still stays in memory. And if I'll call animation creation for 10 times will there be 10 instances of the animation?

Describe the solution you'd like A some solution to clear created animation from memory. Like this:

function animate({ view, easing = "linear", duration = 1000, start = 0 }) {
  const animeObj = {
    targets: view,
    easing,
    duration,
    complete: (animation) => {
      animation.kill();
    },
    autoplay: false
  };

  const animation = anime(animeObj);
  if (start === 0) {
    animation.play();
  } else {
    animation.seek(start);
    animation.play();
  }
}

If I want to play new animation on object I'll create it again. I don't want to save it in memory with a phantom possibility of reusing it again. No any thoughts about the combination of animation.pause() and anime.remove(targets) will help clear memory and unsubscribe the animation event.

NickRimer03 avatar Mar 28 '19 07:03 NickRimer03

I'm stuck in the same case. I can't remove timeline that makes complete event call multi time. even on removed timeline

namkazt avatar Apr 22 '19 11:04 namkazt

same case, has anyone found a way to destroy an instance?

fengxianhua avatar May 16 '19 02:05 fengxianhua

i guess not. I switch to use greensock https://greensock.com/docs/TweenLite

namkazt avatar May 16 '19 04:05 namkazt

Same case, and I would like to keep using this library, i dont wanna switch to greensock. Has anybody else found a solution ?

thibautflottat avatar Jun 01 '19 08:06 thibautflottat

+1 for this, super high on my list of what I'm looking for in animation libraries. @juliangarnier any thoughts?

AlexVipond avatar Dec 01 '19 07:12 AlexVipond

this is really dampening the performance of https://soundscape.world, and I'm looking into alternatives now as a result :(

mracette avatar Mar 29 '20 16:03 mracette

Thanks for all the great thoughts on this feature - we will look into including it on the next major version (or maybe minor depending on scope)

kn0wn avatar Mar 30 '20 12:03 kn0wn

Any update on this?

fvpDev avatar Aug 30 '22 21:08 fvpDev

It’s planned for the next release. Currently refactoring how the animations work internally and waiting for this part to be fully working and tested before introducing new methods to the API, like kill() or toggle(). Making good progress so far, but I stopped giving dates for release date since it always takes more time than expected.

Meanwhile, doing:

let animation = anime({…});
…
animation.pause();
animation = null;

Might be enough in some cases.

juliangarnier avatar Aug 31 '22 21:08 juliangarnier