greensock / GSAP

GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web
https://gsap.com
19.56k stars 1.72k forks source link

onComplete doesn't get fired #278

Closed intersrc closed 6 years ago

intersrc commented 6 years ago
  const obj = { x: 1, y: 1 };
  TweenLite.to(obj, 1, {
    x: 1,
    onComplete: () => {
      console.log('onComplete'); // This line won't be called
    },
  });
  TweenLite.to(obj, 0.5, {
    y: 2,
  });

I'm using gsap 1.20.4

jackdoyle commented 6 years ago

Interesting edge case - yes, it looks like if you've got a tween that actually isn't tweening anything (in your case, obj.x is 1 and you're tweening it to 1, thus no change) and then you create another tween of that very same object, the default overwriting mode will find the first tween and say "hey, after running my overwrite logic, I found a tween that's not doing anything so kill it". I'll patch that in the next release. The workaround for now is simple - just set overwrite:false on that 2nd tween, or set TweenLite.defaultOverwrite = false.

Thanks for reporting this. Sorry about the hassle.