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

Function _parsePosition

esm/gsap-core.js:577–612  ·  view source on GitHub ↗
(animation, position, percentAnimation)

Source from the content-addressed store, hash-verified

575 totalDuration: _emptyFunc
576},
577 _parsePosition = function _parsePosition(animation, position, percentAnimation) {
578 var labels = animation.labels,
579 recent = animation._recent || _zeroPosition,
580 clippedDuration = animation.duration() >= _bigNum ? recent.endTime(false) : animation._dur,
581 //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.
582 i,
583 offset,
584 isPercent;
585
586 if (_isString(position) && (isNaN(position) || position in labels)) {
587 //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).
588 offset = position.charAt(0);
589 isPercent = position.substr(-1) === "%";
590 i = position.indexOf("=");
591
592 if (offset === "<" || offset === ">") {
593 i >= 0 && (position = position.replace(/=/, ""));
594 return (offset === "<" ? recent._start : recent.endTime(recent._repeat >= 0)) + (parseFloat(position.substr(1)) || 0) * (isPercent ? (i < 0 ? recent : percentAnimation).totalDuration() / 100 : 1);
595 }
596
597 if (i < 0) {
598 position in labels || (labels[position] = clippedDuration);
599 return labels[position];
600 }
601
602 offset = parseFloat(position.charAt(i - 1) + position.substr(i + 1));
603
604 if (isPercent && percentAnimation) {
605 offset = offset / 100 * (_isArray(percentAnimation) ? percentAnimation[0] : percentAnimation).totalDuration();
606 }
607
608 return i > 1 ? _parsePosition(animation, position.substr(0, i - 1), percentAnimation) + offset : clippedDuration + offset;
609 }
610
611 return position == null ? clippedDuration : +position;
612},
613 _createTweenType = function _createTweenType(type, params, timeline) {
614 var isLegacy = _isNumber(params[1]),
615 varsIndex = (isLegacy ? 2 : 1) + (type < 2 ? 0 : 1),

Callers 2

_addToTimelineFunction · 0.70
gsap-core.jsFile · 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…