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

Method totalTime

src/gsap-core.js:1188–1217  ·  view source on GitHub ↗
(totalTime, suppressEvents)

Source from the content-addressed store, hash-verified

1186 }
1187
1188 totalTime(totalTime, suppressEvents) {
1189 _wake();
1190 if (!arguments.length) {
1191 return this._tTime;
1192 }
1193 let parent = this._dp;
1194 if (parent && parent.smoothChildTiming && this._ts) {
1195 _alignPlayhead(this, totalTime);
1196 !parent._dp || parent.parent || _postAddChecks(parent, this); // edge case: if this is a child of a timeline that already completed, for example, we must re-activate the parent.
1197 //in case any of the ancestor timelines had completed but should now be enabled, we should reset their totalTime() which will also ensure that they're lined up properly and enabled. Skip for animations that are on the root (wasteful). Example: a TimelineLite.exportRoot() is performed when there's a paused tween on the root, the export will not complete until that tween is unpaused, but imagine a child gets restarted later, after all [unpaused] tweens have completed. The start of that child would get pushed out, but one of the ancestors may have completed.
1198 while (parent && parent.parent) {
1199 if (parent.parent._time !== parent._start + (parent._ts >= 0 ? parent._tTime / parent._ts : (parent.totalDuration() - parent._tTime) / -parent._ts)) {
1200 parent.totalTime(parent._tTime, true);
1201 }
1202 parent = parent.parent;
1203 }
1204 if (!this.parent && this._dp.autoRemoveChildren && ((this._ts > 0 && totalTime < this._tDur) || (this._ts < 0 && totalTime > 0) || (!this._tDur && !totalTime) )) { //if the animation doesn't have a parent, put it back into its last parent (recorded as _dp for exactly cases like this). Limit to parents with autoRemoveChildren (like globalTimeline) so that if the user manually removes an animation from a timeline and then alters its playhead, it doesn't get added back in.
1205 _addToTimeline(this._dp, this, this._start - this._delay);
1206 }
1207 }
1208 if (this._tTime !== totalTime || (!this._dur && !suppressEvents) || (this._initted && Math.abs(this._zTime) === _tinyNum) || (!this._initted && this._dur && totalTime) || (!totalTime && !this._initted && (this.add || this._ptLookup))) { // check for _ptLookup on a Tween instance to ensure it has actually finished being instantiated, otherwise if this.reverse() gets called in the Animation constructor, it could trigger a render() here even though the _targets weren't populated, thus when _init() is called there won't be any PropTweens (it'll act like the tween is non-functional)
1209 this._ts || (this._pTime = totalTime); // otherwise, if an animation is paused, then the playhead is moved back to zero, then resumed, it'd revert back to the original time at the pause
1210 //if (!this._lock) { // avoid endless recursion (not sure we need this yet or if it's worth the performance hit)
1211 // this._lock = 1;
1212 _lazySafeRender(this, totalTime, suppressEvents);
1213 // this._lock = 0;
1214 //}
1215 }
1216 return this;
1217 }
1218
1219 time(value, suppressEvents) {
1220 return arguments.length ? this.totalTime((Math.min(this.totalDuration(), value + _elapsedCycleDuration(this)) % (this._dur + this._rDelay)) || (value ? this._dur : 0), suppressEvents) : this._time; // note: if the modulus results in 0, the playhead could be exactly at the end or the beginning, and we always defer to the END with a non-zero value, otherwise if you set the time() to the very end (duration()), it would render at the START!

Callers 8

timeMethod · 0.95
totalProgressMethod · 0.95
progressMethod · 0.95
iterationMethod · 0.95
timeScaleMethod · 0.95
pausedMethod · 0.95
revertMethod · 0.95
seekMethod · 0.95

Calls 7

_wakeFunction · 0.70
_alignPlayheadFunction · 0.70
_postAddChecksFunction · 0.70
_addToTimelineFunction · 0.70
_lazySafeRenderFunction · 0.70
totalDurationMethod · 0.45
totalTimeMethod · 0.45

Tested by

no test coverage detected