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

Function _parsePosition

src/gsap-core.js:390–414  ·  view source on GitHub ↗
(animation, position, percentAnimation)

Source from the content-addressed store, hash-verified

388 _onUpdateTotalDuration = animation => (animation instanceof Timeline) ? _uncache(animation) : _setDuration(animation, animation._dur),
389 _zeroPosition = {_start:0, endTime:_emptyFunc, totalDuration:_emptyFunc},
390 _parsePosition = (animation, position, percentAnimation) => {
391 let labels = animation.labels,
392 recent = animation._recent || _zeroPosition,
393 clippedDuration = animation.duration() >= _bigNum ? recent.endTime(false) : animation._dur, //in case there's a child that infinitely repeats, users almost never intend for the insertion point of a new child to be based on a SUPER long value like that so we clip it and assume the most recently-added child's endTime should be used instead.
394 i, offset, isPercent;
395 if (_isString(position) && (isNaN(position) || (position in labels))) { //if the string is a number like "1", check to see if there's a label with that name, otherwise interpret it as a number (absolute value).
396 offset = position.charAt(0);
397 isPercent = position.substr(-1) === "%";
398 i = position.indexOf("=");
399 if (offset === "<" || offset === ">") {
400 i >= 0 && (position = position.replace(/=/, ""));
401 return (offset === "<" ? recent._start : recent.endTime(recent._repeat >= 0)) + (parseFloat(position.substr(1)) || 0) * (isPercent ? (i < 0 ? recent : percentAnimation).totalDuration() / 100 : 1);
402 }
403 if (i < 0) {
404 (position in labels) || (labels[position] = clippedDuration);
405 return labels[position];
406 }
407 offset = parseFloat(position.charAt(i-1) + position.substr(i+1));
408 if (isPercent && percentAnimation) {
409 offset = offset / 100 * (_isArray(percentAnimation) ? percentAnimation[0] : percentAnimation).totalDuration();
410 }
411 return (i > 1) ? _parsePosition(animation, position.substr(0, i-1), percentAnimation) + offset : clippedDuration + offset;
412 }
413 return (position == null) ? clippedDuration : +position;
414 },
415 _createTweenType = (type, params, timeline) => {
416 let isLegacy = _isNumber(params[1]),
417 varsIndex = (isLegacy ? 2 : 1) + (type < 2 ? 0 : 1),

Callers 12

_addToTimelineFunction · 0.70
seekMethod · 0.70
setMethod · 0.70
staggerToMethod · 0.70
addMethod · 0.70
addLabelMethod · 0.70
addPauseMethod · 0.70
removePauseMethod · 0.70
tweenToMethod · 0.70
tweenFromToMethod · 0.70
nextLabelMethod · 0.70
previousLabelMethod · 0.70

Calls 4

durationMethod · 0.80
endTimeMethod · 0.80
_isStringFunction · 0.70
totalDurationMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…