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

ScrollToPlugin onAutoKill called prematurely #182

Closed jmahony closed 7 years ago

jmahony commented 7 years ago

From what I understand onAutoKill should only be called when the tween is interrupted, but it seems to be called when the tween begins.

An example: https://jsfiddle.net/tuhm6rcb/

Is this a bug or am I misunderstanding onAutoKill?

Thanks :)

jmahony commented 7 years ago

I'm an idiot This:

    TweenLite.to(window, 0.66, {
        scrollTo: {
            y: (n - 1) * 1000
        },
        onComplete: function () {
            document.querySelector('#msg').textContent = 'last onComplete fired for section #' + n;
        },
        autoKill: true,
        onAutoKill: function() {
            document.querySelector('#msg').textContent = 'onAutoKill fired for section #' + n;
        }
    });

Should be:

    TweenLite.to(window, 0.66, {
        scrollTo: {
            y: (n - 1) * 1000,
            autoKill: true,
            onAutoKill: function() {
               document.querySelector('#msg').textContent = 'onAutoKill fired for section #' + n;
            }
        },
        onComplete: function () {
            document.querySelector('#msg').textContent = 'last onComplete fired for section #' + n;
        }
    });