Share Posted April 12, 2017 Hey guys, long time since I've been here. How can I change the duration of a tween while it is tweening? So I have this: TweenMax.to(".masked", 10, {"background-position": "0px 100%"}); And I want while this is playing, to dynamically increase the duration of it, or lessen it. See the Pen jmNQBp by netgfx (@netgfx) on CodePen Link to comment Share on other sites More sharing options...
Share Posted April 12, 2017 HI Michael71 I would think changing the timeScale() would be the easiest thing to do. That's exactly what I did on my recent handwriting demo with a speed control dial. See the Pen MpLVvO by PointC (@PointC) on CodePen Hopefully that helps. Happy tweening. 2 Link to comment Share on other sites More sharing options...
Author Share Posted April 12, 2017 Yes exactly something like this. Can I also get the current speed? so I can gradually decrease it? This is for a loader which I'm not sure when it will finish, so I want to keep making it go slower so it doesn't end, and when it is complete to bump it to the end. Link to comment Share on other sites More sharing options...
Share Posted April 12, 2017 Oh, this is for a loader. I thought there was some user interaction that was causing the change. I don't have much loader knowledge, but I think you'd probably want to link the percentage of page load to the progress of the timeline in that case. Maybe someone else will jump in here with some solid advice. Happy tweening. Link to comment Share on other sites More sharing options...
Author Share Posted April 12, 2017 If you know only this part I'm good to go: Can I also get the current speed? Link to comment Share on other sites More sharing options...
Share Posted April 12, 2017 timeScale works as a getter or setter. You could also use progress or time which also work as getters or setters. var t = yourTween.progress(); // gets current progress var t = yourTween.timeScale(); // gets current timeScale var t = yourTween.time(); //gets current time Happy tweening. 2 Link to comment Share on other sites More sharing options...
Share Posted April 12, 2017 FYI, duration() works as a getter or setter as well: t.duration(newDuration); //sets var d = t.duration(); //gets Also, yes, you can literally tween the timeScale() using another tween: var t = TweenLite.to(...); //your original tween TweenLite.to(t, 1, {timeScale:0.2}); //animates the timeScale to 0.2 over the course of 1 second (slowing it down) Making things appear to slow down can also be achieved with easing, like Power4.easeOut would start out fast and then slow to a crawl. See http://greensock.com/ease-visualizer Does that help? 2 Link to comment Share on other sites More sharing options...
Author Share Posted April 12, 2017 Yes greatly, the .duration() get/set is really useful! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now