Share Posted May 23, 2015 I am trying to gradually speed up the animation while it repeats. Is this possible using timeScale? The line of code I put in there: .fromTo(part1, 4, {timeScale:1}, {timeScale:15, ease:"Power0.easeNone"}); is obviously not doing the trick.. Thanks in advance. See the Pen yNaGWy by deanpien (@deanpien) on CodePen 1 Link to comment Share on other sites More sharing options...
Share Posted May 23, 2015 Thanks for the demo. One option is to call an outside function onRepeat to tween the timeScale http://codepen.io/GreenSock/pen/pJEGWb?editors=001 But I would probably do something like this: var part1 = new TimelineMax() part1.to("#greenBox", 1, {x:550, rotation:360}) .to("#purpleBox", 1, {x:550, rotation:-360}, "+=0.2") var main = new TimelineMax(); main.add(part1.tweenFromTo(0, part1.duration())) .add(part1.tweenFromTo(0, part1.duration()).timeScale(2)) .add(part1.tweenFromTo(0, part1.duration()).timeScale(4)) $("#restart").click(function () { main.restart(); }); http://codepen.io/GreenSock/pen/rVMPGm?editors=001 Basically your main timeline has 3 tweens that scrub through part1's timeline at different speeds. 2 Link to comment Share on other sites More sharing options...
Author Share Posted May 23, 2015 I like the .add option (second pen). Was wondering if I could put a function inside the .add as a possible 3rd solution..? Link to comment Share on other sites More sharing options...
Share Posted May 24, 2015 Hi deanpien in addition to Carl great advise , you can do like this too : part1.to("#greenBox", 1, {x:550, rotation:360}) .to("#purpleBox", 1, {x:550, rotation:-360}, "+=0.2") .add(function(){ part1.timeScale(part1.timeScale()+ 0.5) /* or part1.timeScale(part1.timeScale()*2) */ }) 3 Link to comment Share on other sites More sharing options...
Share Posted December 7, 2018 Hi, I'm reviving this old thread. I had the same problem, so here's a way to tween the timeScale of a timeline using TweenMax. In this way you can also set the ease for the timeScale increase/decrease or have an onComplete callback if you wish. Here's a See the Pen OaKqoq?editors=0010 by anatolbogun (@anatolbogun) on CodePen . function tweenTimeScale( opt ) { const { timeline, duration, from, to, onComplete, onCompleteParams, onCompleteScope } = opt let { ease } = opt if ( !ease ) { ease = Linear.easeNone } const timeScale = { value: from } TweenMax.to( timeScale, duration, { value: to, ease, onComplete, onCompleteParams, onCompleteScope } ) var updateTimeScale = function() { // console.log( 'timeScale:', timeScale.value ) timeline.timeScale( timeScale.value ) if ( timeScale.value !== to ) { window.requestAnimationFrame( updateTimeScale ) } } window.requestAnimationFrame( updateTimeScale ) } Usage is quite straightforward: const tl = TimelineMax() tl.to( obj, 1, { rotation: 360, repeat: -1 } ) // etc. // e.g. slow the timeline to a halt over 3 seconds and pause it at the end tweenTimeScale( { timeline: tl, duration: 3, from: 1, to: 0, ease: Power2.easeOut, // optional onComplete: tl.pause, // optional onCompleteScope: tl, // optional } ) 3 Link to comment Share on other sites More sharing options...
Share Posted December 7, 2018 Hi @Anatol New to GSAP? You can tween the timeScale directly. TweenLite.to(myTimeline, duration, { timeScale: 0 }); Much simpler. See the Pen KbPpjJ by osublake (@osublake) on CodePen 5 Link to comment Share on other sites More sharing options...
Share Posted December 10, 2018 Hi @OSUblake , thanks for your reply and the CodePen. I wonder why I didn't just try it with a timeScale tween in the first place. Well, I tried to tween _timeScale at some point but the result didn't look right obviously. Thanks also for some other useful suggestions in the code. I didn't know about _gsTransform , that's handy. Link to comment Share on other sites More sharing options...
Share Posted December 10, 2018 4 hours ago, Anatol said: I wonder why I didn't just try it with a timeScale tween in the first place. Well, I tried to tween _timeScale at some point but the result didn't look right obviously. Yes, _timeScale is a private backing value that gets set by the .timeScale() method, so it wasn't being updated correctly. It might not be obvious, but the tween is actually calling the .timeScale() method here. It's really not documented anywhere, but you can animate function based getters/setters, which is what the .timeScale() method is. So you can animate any tween/timeline method that gets and sets a number value, like .progress() and .time(). TweenLite.to(myTimeline, duration, { timeScale: 0 // calls myTimeline.timeScale() method }); An old demo showing different different ways to create getters/setters that GSAP can use. Box 4 is how most GSAP methods work. See the Pen 6d42dd35adee8af8ce9c1bcf3f2e6cb2 by osublake (@osublake) on CodePen 1 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