Famous / engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Position#set calls not queuing as expected.

trusktr opened this issue · comments

Instead of doing the following

cardPosition.set(goToPosition[0],goToPosition[1],goToPosition[2]+10, {
    duration: 2000,
    curve: 'inOutExpo'
})
.set(0,0,0) // move everything back

I'm doing

cardPosition.set(goToPosition[0],goToPosition[1],goToPosition[2]+10, {
    duration: 2000,
    curve: 'inOutExpo'
}, function() {
    // move everything back
    cardPosition.set(0,0,0) // <--- IT DOESN'T WORK :(
})

The result is that cardPosition.set(0,0,0) never takes effect.

It seems like the preceding animation might still place at least one more command into the command queue after the call to cardPosition.set(0,0,0).

In order to make it work, I have to do the following:

cardPosition.set(goToPosition[0],goToPosition[1],goToPosition[2]+10, {
    duration: 2000,
    curve: 'inOutExpo'
}, function() {
    Engine.requestUpdateOnNextTick({ onUpdate() {
        // move everything back
        cardPosition.set(0,0,0) // <--- IT WORKS!
    }})
})

This bug might exist with other components if they're all designed the same way, but I haven't checked.

Definitely a bug.

Added testcase for transitionable:

    t.test('set without transition in callback', function (t) {
        time = 0;
        var transitionable = new Transitionable(0);

        transitionable.set(100, { duration: 1000 }, function () {
            transitionable.set(0);
        });

        time = 500;
        t.equal(transitionable.get(), 50);

        time = 1000;
        t.equal(transitionable.get(), 100);

        time = 1000;
        t.equal(transitionable.get(), 0);

        t.end();
    });

Can't reproduce with Transitionable. If this is a bug, it's associated with the Position component that you used.

Will investigate that.

How/when are you getting the Transitionable state? This looks more like an incorrect usage of requestUpdate to me.

Can reproduce. This is a little bit tricky. Will submit PR.
The issue is that Transitionable#isActive #=> false in the above case.

@jd-carroll Thanks for reporting this.