-
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
automatic animation loop #342
Comments
This sounds fairly handy to reduce boilerplate, and such. I have a few suggestions;
Any thoughts? |
@mikebolt Can you post a sample of code that shows what you're thinking the usage would look like? |
I realize that this issue is old but i thought i let you know that i wrote a Proxy wrapper around tweenjs that does what you're asking for. Tweenjs API stays like it is, so you can call all its methods. Caveats: currently starts a rAF for every tween (it doesn't reuse a global one), and uses Proxy which might have performance implications (although it should be fine really). https://codepen.io/claus/pen/vYGQwNO Maybe it helps someone. |
I think this would indeed make it easier for some cases, while still allowing those who need control to make their own loops. I'm thinking that perhaps
|
Maybe we can overload the tween
.to(...)
.start(true) // Causes its associated Group to use a loop in a breaking change, we can change it to true by default, and people could opt-out: tween
.to(...)
.start(false) // don't use a loop, we'll call `update` manually. |
I think a better API would be to not override start(), and make it an option for the Tween. const tween = new Tween({}, {duration: 1000, autoLoop: true})
.start() // starts the loop (or uses its group's loop if in a group)
// ...later
tween.stop() // stops the loop |
I suggest that we add a 'TWEEN.animate' convenience method. It would set up a simple requestAnimationFrame animation loop.
In the documentation, we just need to tell users to use this method once before starting any tweens.
We might need a shim for Node.js.
The text was updated successfully, but these errors were encountered: