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 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
} )