-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
chained tweens cannot be stopped in onComplete
callback (chained tweens start in the NEXT update after onComplete)
#397
Comments
I think But actually it is called before all the cleaning work. As a result, the tween cannot be added back to the group in its |
The chain function has been problematic for a long time. I'm in favor of making a breaking change to the chain function so that it is more intuitive. So now the question is "How should the chain function work?" I would like to read some suggestions. |
@mikebolt Hello! This issue is from 2017. Besides the TypeScript change and refactorings in general, there has since been new changes to chained tweens (including updates to the tests), as well as some new discussion here in the issues. One example is #406 (comment) Does this particular issue still exist? Is there a live code example? |
The reason for this is because A couple solutions:
|
onComplete
callbackonComplete
callback (chained tweens start in the NEXT update after onComplete)
Unfortunately some things can break in the name of progress. Really sorry about that! We try to have good coverage with out tests, and this edge case managed to sneak by. I will close this as a workaround has been described above. Another workaround is that chained tweens can also be removed by calling const tween1 = new TWEEN.Tween({})
.to({}, 500)
.onComplete(() => {
console.log('complete');
tween1.stop();
tween2.stop();
tween1.chain(); // <-------------- Remove chained tweens
});
const tween2 = new TWEEN.Tween({})
.to({}, 500);
tween1.chain(tween2);
tween2.chain(tween1); |
Create two
tween
s and chain them:In
onComplete
callback, I try to stop both of them, but it does not work and just loops forever.Looking into the code, I find that, in
onComplete
callbacktween2._isPlaying
is set to false, after that, the chainedtween2
is started no matter if it should be stopped, so thestop
does not make a difference to the result.So a workaround is to wrap it in
setTimeout
:Anyway, it's ugly and doesn't make sense.
This has worked before, I think the refactor has broken a lot of things. 😞
The text was updated successfully, but these errors were encountered: