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

Function _timeToProgress

esm/GSDevTools.js:147–183  ·  view source on GitHub ↗
(time, animation, defaultValue, relativeProgress)

Source from the content-addressed store, hash-verified

145 return time;
146},
147 _timeToProgress = function _timeToProgress(time, animation, defaultValue, relativeProgress) {
148 var add, i, a;
149
150 if (_isString(time)) {
151 if (time.charAt(1) === "=") {
152 add = parseInt(time.charAt(0) + "1", 10) * parseFloat(time.substr(2));
153
154 if (add < 0 && relativeProgress === 0) {
155 //if something like inTime:"-=2", we measure it from the END, not the beginning
156 relativeProgress = 100;
157 }
158
159 time = relativeProgress / 100 * animation.duration() + add;
160 } else if (isNaN(time) && animation.labels && animation.labels[time] !== -1) {
161 time = animation.labels[time];
162 } else if (animation === _recordedRoot) {
163 //perhaps they defined an id of an animation, like "myAnimation+=2"
164 i = time.indexOf("=");
165
166 if (i > 0) {
167 add = parseInt(time.charAt(i - 1) + "1", 10) * parseFloat(time.substr(i + 1));
168 time = time.substr(0, i - 1);
169 } else {
170 add = 0;
171 }
172
173 a = gsap.getById(time);
174
175 if (a) {
176 time = _globalizeTime(a, defaultValue / 100 * a.duration()) + add;
177 }
178 }
179 }
180
181 time = isNaN(time) ? defaultValue : parseFloat(time);
182 return Math.min(100, Math.max(0, time / animation.duration() * 100));
183},
184 _addedCSS,
185 _createRootElement = function _createRootElement(element, minimal, css) {
186 if (!_addedCSS) {

Callers 1

initializeFunction · 0.70

Calls 4

durationMethod · 0.80
getByIdMethod · 0.80
_isStringFunction · 0.70
_globalizeTimeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…