Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
trusktr opened this issue Aug 19, 2015 · 4 comments
Open

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

trusktr opened this issue Aug 19, 2015 · 4 comments
Assignees
Labels

Comments

@trusktr
Copy link
Contributor

trusktr commented Aug 19, 2015

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.

@michaelobriena
Copy link
Member

Definitely a bug.

@michaelobriena
Copy link
Member

@alexanderGugel care to look?

@alexanderGugel alexanderGugel self-assigned this Aug 19, 2015
@alexanderGugel
Copy link
Member

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.

@alexanderGugel
Copy link
Member

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.

alexanderGugel added a commit to alexanderGugel/engine that referenced this issue Aug 20, 2015
Resolves Famous#474

Example:

    var position = new Position(parent0);
    position.set(100, 100, 100, {
        duration: 500,
        curve: 'inOutExpo'
    }, function () {
        position.set(0, 0, 0);
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants