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

onStart is not called on individual tweens. #60

Open
cainmartin opened this issue Jun 20, 2017 · 0 comments
Open

onStart is not called on individual tweens. #60

cainmartin opened this issue Jun 20, 2017 · 0 comments

Comments

@cainmartin
Copy link
Collaborator

When creating an individual tween, all callbacks work, with the exception of the onStart.

var obj = { x: 0 };
var testTina = new TINA.Tween(obj, ['x'])
    .to({ x: 10 }, 200) 
    .onStart(function () {
        console.log('Starting');
    })
    .onUpdate(function () {
        console.log(obj.x);
    })
    .onComplete(function() {
        console.log('Completed');
    })
    .start();

Given the above code - 'Starting' is never output to the console.
However, it is possible to get onStart to fire by placing the tween in a timeline.

var timeline = TINA.Timeline();
var obj = { x: 0 };
var testTina = new TINA.Tween(obj, ['x'])
    .to({ x: 10 }, 200) 
    .onStart(function () {
        console.log('Starting');
    });
    timeline.add(testTina, 0);     
    timeline.start();

It is likely this occurs because an individual tween is appears to never be added to the list of _inactivePlayables. A cursory glance suggests that it is only when a tween is removed from the _inactivePlayables list and set to active that the onStart callbacks are fired.

It should be possible to add a fix the Playable.start method to also fire the onStart method.

mjm973 added a commit to mjm973/tina.js that referenced this issue Jul 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant