daniel-lundin / snabbt.js

Fast animations with javascript and CSS transforms
http://daniel-lundin.github.io/snabbt.js/
MIT License
5.21k stars 331 forks source link

Chaining broken: previous states are not set to 'from' when changing 'position' and 'scale' #42

Closed korywka closed 9 years ago

korywka commented 9 years ago
        snabbt(_this.cursor, {
            fromPosition: [210, 555, 0],
            position: [150, 190, 0],
            duration: 1000,
            easing: 'ease'
        }).then({
            position: [150, 190, 0],
            scale: CURSOR.pressedScale,
            duration: CURSOR.pressedDuration,
            callback: function() {
                _this.drag.style.visibility = 'visible';
                snabbt(_this.drag, {
                    position: [-100, -30, 0],
                    duration: 800,
                    easing: 'ease'
                });
                snabbt(_this.cursor, {
                    position: [50, 160, 0],
                    scale: CURSOR.pressedScale, // here
                    duration: 800,
                    easing: 'ease',
                    callback: function() {
                    }
                });
            }
        });

we need to duplicate scale: CURSOR.pressedScale, cause it will be set to [1, 1] when position: [50, 160, 0], is set.

daniel-lundin commented 9 years ago

Thanks for the report, I will look into it. Might be that the callback is executed before the saved state is stored..

Just had my first baby, that's the reason for the slow responses.. :)

korywka commented 9 years ago

Congrats! :)

Clean up version here: http://jsfiddle.net/s81ptssk/ Circle scaled back to [1, 1].

daniel-lundin commented 9 years ago

Ah, now I see, great example. Actually the fromScale is set to [5, 5](it starts from scale [5,5] in the second part of the animation) but the end scale defaults to [1, 1] which is why it shrinks back again. Maybe I should change it so that it keeps the scale(and other properties) the same if you don't explicitly set it to something else. I guess that's more convienient. I will give it some thought!

daniel-lundin commented 9 years ago

This is fixed in master, will be out in the next release. (In a few days)

korywka commented 9 years ago

Thanks!