-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
Tweenable does not seem to be reusable #133
Comments
Hi @tfsJoe, this is an excellent bug report! Thanks for opening it. I just tried to reproduce this issue in CodePen and am seeing the same behavior: https://codepen.io/jeremyckahn/pen/zYdrNZz?editors=1111
Lines 334 to 352 in 520ba43
All it really does it perform some housekeeping around timing and then begin playing with its current I think you can achieve the behavior you want by changing: myTweenable.tween(); To something like: // Assumes newStartingPosition returns updated starting position data
myTweenable.tween({ from: newStartingPosition() }); Shifty's current behavior is perhaps not ideal; it should probably restart completed tweens when a Let me know if this helps! |
Thanks for the quick response. I appreciate the workaround, this will work for me. Of course it is up to you as to whether this issue stays open, but if you do decide not to change it I would at least consider this a defect in the documentation - it should probably mention that the configuration needs to be supplied anew. |
@tfsJoe I had a bit of spare time and I think I found a fix for this issue: b3dc299. It was actually just the removal of some code that I'm not quite sure was for to begin with. 😅 I've put up a pre-release version ( It seems to be working with the sample code you provided: https://codepen.io/jeremyckahn/pen/wvqGWQw Could you give this a look and let me know if it's working the way you expect? If it is, I can release it in |
I pulled it down and used it in my sample, and reviewed the change. With the caveat that I am new to the codebase, this makes sense to me and results in my expected behavior, so it looks good to me! |
In the documentation here, there is an example of configuring a Tweenable, and calling
.tween()
. There is a comment that says:So, I attempted to reuse a Tweenable, by calling .tween() again. However, the result was, for the duration set in the config, the final value is always used in the
render
callback. Here is an example - the green div calledthing
uses a new tween every time, and the red one calledthing2
attempts to reuse a tweenable. Based on the comment in the doc, I would expect the red box to go back to y = 0 and animate through y = 500. Instead, after animating from 0 to 500 the first time, the second time it animates from 500 to 500 and just stays put.I've attached a screenshot of the console, with a pink line drawn through the first and second runs:
The text was updated successfully, but these errors were encountered: