MCPcopy
hub / github.com/greensock/GSAP / timeScale

Method timeScale

src/gsap-core.js:1247–1265  ·  view source on GitHub ↗
(value, suppressEvents)

Source from the content-addressed store, hash-verified

1245 // }
1246
1247 timeScale(value, suppressEvents) {
1248 if (!arguments.length) {
1249 return this._rts === -_tinyNum ? 0 : this._rts; // recorded timeScale. Special case: if someone calls reverse() on an animation with timeScale of 0, we assign it -_tinyNum to remember it's reversed.
1250 }
1251 if (this._rts === value) {
1252 return this;
1253 }
1254 let tTime = this.parent && this._ts ? _parentToChildTotalTime(this.parent._time, this) : this._tTime; // make sure to do the parentToChildTotalTime() BEFORE setting the new _ts because the old one must be used in that calculation.
1255
1256 // future addition? Up side: fast and minimal file size. Down side: only works on this animation; if a timeline is reversed, for example, its childrens' onReverse wouldn't get called.
1257 //(+value < 0 && this._rts >= 0) && _callback(this, "onReverse", true);
1258
1259 // prioritize rendering where the parent's playhead lines up instead of this._tTime because there could be a tween that's animating another tween's timeScale in the same rendering loop (same parent), thus if the timeScale tween renders first, it would alter _start BEFORE _tTime was set on that tick (in the rendering loop), effectively freezing it until the timeScale tween finishes.
1260 this._rts = +value || 0;
1261 this._ts = (this._ps || value === -_tinyNum) ? 0 : this._rts; // _ts is the functional timeScale which would be 0 if the animation is paused.
1262 this.totalTime(_clamp(-Math.abs(this._delay), this.totalDuration(), tTime), suppressEvents !== false);
1263 _setEnd(this); // if parent.smoothChildTiming was false, the end time didn't get updated in the _alignPlayhead() method, so do it here.
1264 return _recacheAncestors(this);
1265 }
1266
1267 paused(value) {
1268 if (!arguments.length) {

Callers 15

reversedMethod · 0.95
_addToTimelineFunction · 0.80
gsap-core.jsFile · 0.80
_getGlobalTimeFunction · 0.80
animationFunction · 0.80
onChangeTimeScaleFunction · 0.80
initializeFunction · 0.80
GSDevToolsFunction · 0.80
_addToTimelineFunction · 0.80
renderMethod · 0.80
tweenToMethod · 0.80
totalDurationMethod · 0.80

Calls 6

totalTimeMethod · 0.95
totalDurationMethod · 0.95
_parentToChildTotalTimeFunction · 0.70
_clampFunction · 0.70
_setEndFunction · 0.70
_recacheAncestorsFunction · 0.70

Tested by

no test coverage detected