vendor: 4,933 bytes, lines 1-149
1function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 2 3function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } 4 5/*! 6 * GSAP 3.12.5 7 * https://gsap.com 8 * 9 * @license Copyright 2008-2024, GreenSock. All rights reserved. 10 * Subject to the terms at https://gsap.com/standard-license or for 11 * Club GSAP members, the agreement issued with that membership. 12 * @author: Jack Doyle, [email protected] 13*/ 14 15/* eslint-disable */ 16var _config = { 17 autoSleep: 120, 18 force3D: "auto", 19 nullTargetWarn: 1, 20 units: { 21 lineHeight: "" 22 } 23}, 24 _defaults = { 25 duration: .5, 26 overwrite: false, 27 delay: 0 28}, 29 _suppressOverwrites, 30 _reverting, 31 _context, 32 _bigNum = 1e8, 33 _tinyNum = 1 / _bigNum, 34 _2PI = Math.PI * 2, 35 _HALF_PI = _2PI / 4, 36 _gsID = 0, 37 _sqrt = Math.sqrt, 38 _cos = Math.cos, 39 _sin = Math.sin, 40 _isString = function _isString(value) { 41 return typeof value === "string"; 42}, 43 _isFunction = function _isFunction(value) { 44 return typeof value === "function"; 45}, 46 _isNumber = function _isNumber(value) { 47 return typeof value === "number"; 48}, 49 _isUndefined = function _isUndefined(value) { 50 return typeof value === "undefined"; 51}, 52 _isObject = function _isObject(value) { 53 return typeof value === "object"; 54}, 55 _isNotFalse = function _isNotFalse(value) { 56 return value !== false; 57}, 58 _windowExists = function _windowExists() { 59 return typeof window !== "undefined"; 60}, 61 _isFuncOrString = function _isFuncOrString(value) { 62 return _isFunction(value) || _isString(value); 63}, 64 _isTypedArray = typeof ArrayBuffer === "function" && ArrayBuffer.isView || function () {}, 65 // note: IE10 has ArrayBuffer, but NOT ArrayBuffer.isView(). 66_isArray = Array.isArray, 67 _strictNumExp = /(?:-?\.?\d|\.)+/gi, 68 //only numbers (including negatives and decimals) but NOT relative values. 69_numExp = /[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g, 70 //finds any numbers, including ones that start with += or -=, negative numbers, and ones in scientific notation like 1e-8. 71_numWithUnitExp = /[-+=.]*\d+[.e-]*\d*[a-z%]*/g, 72 _complexStringNumExp = /[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi, 73 //duplicate so that while we're looping through matches from exec(), it doesn't contaminate the lastIndex of _numExp which we use to search for colors too. 74_relExp = /[+-]=-?[.\d]+/, 75 _delimitedValueExp = /[^,'"\[\]\s]+/gi, 76 // previously /[#\-+.]*\b[a-z\d\-=+%.]+/gi but didn't catch special characters. 77_unitExp = /^[+\-=e\s\d]*\d+[.\d]*([a-z]*|%)\s*$/i, 78 _globalTimeline, 79 _win, 80 _coreInitted, 81 _doc, 82 _globals = {}, 83 _installScope = {}, 84 _coreReady, 85 _install = function _install(scope) { 86 return (_installScope = _merge(scope, _globals)) && gsap; 87}, 88 _missingPlugin = function _missingPlugin(property, value) { 89 return console.warn("Invalid property", property, "set to", value, "Missing plugin? gsap.registerPlugin()"); 90}, 91 _warn = function _warn(message, suppress) { 92 return !suppress && console.warn(message); 93}, 94 _addGlobal = function _addGlobal(name, obj) { 95 return name && (_globals[name] = obj) && _installScope && (_installScope[name] = obj) || _globals; 96}, 97 _emptyFunc = function _emptyFunc() { 98 return 0; 99}, 100 _startAtRevertConfig = { 101 suppressEvents: true, 102 isStart: true, 103 kill: false 104}, 105 _revertConfigNoKill = { 106 suppressEvents: true, 107 kill: false 108}, 109 _revertConfig = { 110 suppressEvents: true 111}, 112 _reservedProps = {}, 113 _lazyTweens = [], 114 _lazyLookup = {}, 115 _lastRenderedFrame, 116 _plugins = {}, 117 _effects = {}, 118 _nextGCFrame = 30, 119 _harnessPlugins = [], 120 _callbackNames = "", 121 _harness = function _harness(targets) { 122 var target = targets[0], 123 harnessPlugin, 124 i; 125 _isObject(target) || _isFunction(target) || (targets = [targets]); 126 127 if (!(harnessPlugin = (target._gsap || {}).harness)) { 128 // find the first target with a harness. We assume targets passed into an animation will be of similar type, meaning the same kind of harness can be used for them all (performance optimization) 129 i = _harnessPlugins.length; 130 131 while (i-- && !_harnessPlugins[i].targetTest(target)) {} 132 133 harnessPlugin = _harnessPlugins[i]; 134 } 135 136 i = targets.length; 137 138 while (i--) { 139 targets[i] && (targets[i]._gsap || (targets[i]._gsap = new GSCache(targets[i], harnessPlugin))) || targets.splice(i, 1); 140 } 141 142 return targets; 143}, 144 _getCache = function _getCache(target) { 145 return target._gsap || _harness(toArray(target))[0]._gsap; 146}, 147 _getProperty = function _getProperty(target, property, v) { 148 return (v = target[property]) && _isFunction(v) ? target[property]() : _isUndefined(v) && target.getAttribute && target.getAttribute(property) || v; 149},
vendor: 7,456 bytes, lines 150-365
150 _forEachName = function _forEachName(names, func) { 151 return (names = names.split(",")).forEach(func) || names; 152}, 153 //split a comma-delimited list of names into an array, then run a forEach() function and return the split array (this is just a way to consolidate/shorten some code). 154_round = function _round(value) { 155 return Math.round(value * 100000) / 100000 || 0; 156}, 157 _roundPrecise = function _roundPrecise(value) { 158 return Math.round(value * 10000000) / 10000000 || 0; 159}, 160 // increased precision mostly for timing values. 161_parseRelative = function _parseRelative(start, value) { 162 var operator = value.charAt(0), 163 end = parseFloat(value.substr(2)); 164 start = parseFloat(start); 165 return operator === "+" ? start + end : operator === "-" ? start - end : operator === "*" ? start * end : start / end; 166}, 167 _arrayContainsAny = function _arrayContainsAny(toSearch, toFind) { 168 //searches one array to find matches for any of the items in the toFind array. As soon as one is found, it returns true. It does NOT return all the matches; it's simply a boolean search. 169 var l = toFind.length, 170 i = 0; 171 172 for (; toSearch.indexOf(toFind[i]) < 0 && ++i < l;) {} 173 174 return i < l; 175}, 176 _lazyRender = function _lazyRender() { 177 var l = _lazyTweens.length, 178 a = _lazyTweens.slice(0), 179 i, 180 tween; 181 182 _lazyLookup = {}; 183 _lazyTweens.length = 0; 184 185 for (i = 0; i < l; i++) { 186 tween = a[i]; 187 tween && tween._lazy && (tween.render(tween._lazy[0], tween._lazy[1], true)._lazy = 0); 188 } 189}, 190 _lazySafeRender = function _lazySafeRender(animation, time, suppressEvents, force) { 191 _lazyTweens.length && !_reverting && _lazyRender(); 192 animation.render(time, suppressEvents, force || _reverting && time < 0 && (animation._initted || animation._startAt)); 193 _lazyTweens.length && !_reverting && _lazyRender(); //in case rendering caused any tweens to lazy-init, we should render them because typically when someone calls seek() or time() or progress(), they expect an immediate render. 194}, 195 _numericIfPossible = function _numericIfPossible(value) { 196 var n = parseFloat(value); 197 return (n || n === 0) && (value + "").match(_delimitedValueExp).length < 2 ? n : _isString(value) ? value.trim() : value; 198}, 199 _passThrough = function _passThrough(p) { 200 return p; 201}, 202 _setDefaults = function _setDefaults(obj, defaults) { 203 for (var p in defaults) { 204 p in obj || (obj[p] = defaults[p]); 205 } 206 207 return obj; 208}, 209 _setKeyframeDefaults = function _setKeyframeDefaults(excludeDuration) { 210 return function (obj, defaults) { 211 for (var p in defaults) { 212 p in obj || p === "duration" && excludeDuration || p === "ease" || (obj[p] = defaults[p]); 213 } 214 }; 215}, 216 _merge = function _merge(base, toMerge) { 217 for (var p in toMerge) { 218 base[p] = toMerge[p]; 219 } 220 221 return base; 222}, 223 _mergeDeep = function _mergeDeep(base, toMerge) { 224 for (var p in toMerge) { 225 p !== "__proto__" && p !== "constructor" && p !== "prototype" && (base[p] = _isObject(toMerge[p]) ? _mergeDeep(base[p] || (base[p] = {}), toMerge[p]) : toMerge[p]); 226 } 227 228 return base; 229}, 230 _copyExcluding = function _copyExcluding(obj, excluding) { 231 var copy = {}, 232 p; 233 234 for (p in obj) { 235 p in excluding || (copy[p] = obj[p]); 236 } 237 238 return copy; 239}, 240 _inheritDefaults = function _inheritDefaults(vars) { 241 var parent = vars.parent || _globalTimeline, 242 func = vars.keyframes ? _setKeyframeDefaults(_isArray(vars.keyframes)) : _setDefaults; 243 244 if (_isNotFalse(vars.inherit)) { 245 while (parent) { 246 func(vars, parent.vars.defaults); 247 parent = parent.parent || parent._dp; 248 } 249 } 250 251 return vars; 252}, 253 _arraysMatch = function _arraysMatch(a1, a2) { 254 var i = a1.length, 255 match = i === a2.length; 256 257 while (match && i-- && a1[i] === a2[i]) {} 258 259 return i < 0; 260}, 261 _addLinkedListItem = function _addLinkedListItem(parent, child, firstProp, lastProp, sortBy) { 262 if (firstProp === void 0) { 263 firstProp = "_first"; 264 } 265 266 if (lastProp === void 0) { 267 lastProp = "_last"; 268 } 269 270 var prev = parent[lastProp], 271 t; 272 273 if (sortBy) { 274 t = child[sortBy]; 275 276 while (prev && prev[sortBy] > t) { 277 prev = prev._prev; 278 } 279 } 280 281 if (prev) { 282 child._next = prev._next; 283 prev._next = child; 284 } else { 285 child._next = parent[firstProp]; 286 parent[firstProp] = child; 287 } 288 289 if (child._next) { 290 child._next._prev = child; 291 } else { 292 parent[lastProp] = child; 293 } 294 295 child._prev = prev; 296 child.parent = child._dp = parent; 297 return child; 298}, 299 _removeLinkedListItem = function _removeLinkedListItem(parent, child, firstProp, lastProp) { 300 if (firstProp === void 0) { 301 firstProp = "_first"; 302 } 303 304 if (lastProp === void 0) { 305 lastProp = "_last"; 306 } 307 308 var prev = child._prev, 309 next = child._next; 310 311 if (prev) { 312 prev._next = next; 313 } else if (parent[firstProp] === child) { 314 parent[firstProp] = next; 315 } 316 317 if (next) { 318 next._prev = prev; 319 } else if (parent[lastProp] === child) { 320 parent[lastProp] = prev; 321 } 322 323 child._next = child._prev = child.parent = null; // don't delete the _dp just so we can revert if necessary. But parent should be null to indicate the item isn't in a linked list. 324}, 325 _removeFromParent = function _removeFromParent(child, onlyIfParentHasAutoRemove) { 326 child.parent && (!onlyIfParentHasAutoRemove || child.parent.autoRemoveChildren) && child.parent.remove && child.parent.remove(child); 327 child._act = 0; 328}, 329 _uncache = function _uncache(animation, child) { 330 if (animation && (!child || child._end > animation._dur || child._start < 0)) { 331 // performance optimization: if a child animation is passed in we should only uncache if that child EXTENDS the animation (its end time is beyond the end) 332 var a = animation; 333 334 while (a) { 335 a._dirty = 1; 336 a = a.parent; 337 } 338 } 339 340 return animation; 341}, 342 _recacheAncestors = function _recacheAncestors(animation) { 343 var parent = animation.parent; 344 345 while (parent && parent.parent) { 346 //sometimes we must force a re-sort of all children and update the duration/totalDuration of all ancestor timelines immediately in case, for example, in the middle of a render loop, one tween alters another tween's timeScale which shoves its startTime before 0, forcing the parent timeline to shift around and shiftChildren() which could affect that next tween's render (startTime). Doesn't matter for the root timeline though. 347 parent._dirty = 1; 348 parent.totalDuration(); 349 parent = parent.parent; 350 } 351 352 return animation; 353}, 354 _rewindStartAt = function _rewindStartAt(tween, totalTime, suppressEvents, force) { 355 return tween._startAt && (_reverting ? tween._startAt.revert(_revertConfigNoKill) : tween.vars.immediateRender && !tween.vars.autoRevert || tween._startAt.render(totalTime, true, force)); 356}, 357 _hasNoPausedAncestors = function _hasNoPausedAncestors(animation) { 358 return !animation || animation._ts && _hasNoPausedAncestors(animation.parent); 359}, 360 _elapsedCycleDuration = function _elapsedCycleDuration(animation) { 361 return animation._repeat ? _animationCycle(animation._tTime, animation = animation.duration() + animation._rDelay) * animation : 0; 362}, 363 // feed in the totalTime and cycleDuration and it'll return the cycle (iteration minus 1) and if the playhead is exactly at the very END, it will NOT bump up to the next cycle. 364_animationCycle = function _animationCycle(tTime, cycleDuration) { 365 var whole = Math.floor(tTime /= cycleDuration
vendor: 15,351 bytes, lines 365-665
365); 366 return tTime && whole === tTime ? whole - 1 : whole; 367}, 368 _parentToChildTotalTime = function _parentToChildTotalTime(parentTime, child) { 369 return (parentTime - child._start) * child._ts + (child._ts >= 0 ? 0 : child._dirty ? child.totalDuration() : child._tDur); 370}, 371 _setEnd = function _setEnd(animation) { 372 return animation._end = _roundPrecise(animation._start + (animation._tDur / Math.abs(animation._ts || animation._rts || _tinyNum) || 0)); 373}, 374 _alignPlayhead = function _alignPlayhead(animation, totalTime) { 375 // adjusts the animation's _start and _end according to the provided totalTime (only if the parent's smoothChildTiming is true and the animation isn't paused). It doesn't do any rendering or forcing things back into parent timelines, etc. - that's what totalTime() is for. 376 var parent = animation._dp; 377 378 if (parent && parent.smoothChildTiming && animation._ts) { 379 animation._start = _roundPrecise(parent._time - (animation._ts > 0 ? totalTime / animation._ts : ((animation._dirty ? animation.totalDuration() : animation._tDur) - totalTime) / -animation._ts)); 380 381 _setEnd(animation); 382 383 parent._dirty || _uncache(parent, animation); //for performance improvement. If the parent's cache is already dirty, it already took care of marking the ancestors as dirty too, so skip the function call here. 384 } 385 386 return animation; 387}, 388 389/* 390_totalTimeToTime = (clampedTotalTime, duration, repeat, repeatDelay, yoyo) => { 391 let cycleDuration = duration + repeatDelay, 392 time = _round(clampedTotalTime % cycleDuration); 393 if (time > duration) { 394 time = duration; 395 } 396 return (yoyo && (~~(clampedTotalTime / cycleDuration) & 1)) ? duration - time : time; 397}, 398*/ 399_postAddChecks = function _postAddChecks(timeline, child) { 400 var t; 401 402 if (child._time || !child._dur && child._initted || child._start < timeline._time && (child._dur || !child.add)) { 403 // in case, for example, the _start is moved on a tween that has already rendered, or if it's being inserted into a timeline BEFORE where the playhead is currently. Imagine it's at its end state, then the startTime is moved WAY later (after the end of this timeline), it should render at its beginning. Special case: if it's a timeline (has .add() method) and no duration, we can skip rendering because the user may be populating it AFTER adding it to a parent timeline (unconventional, but possible, and we wouldn't want it to get removed if the parent's autoRemoveChildren is true). 404 t = _parentToChildTotalTime(timeline.rawTime(), child); 405 406 if (!child._dur || _clamp(0, child.totalDuration(), t) - child._tTime > _tinyNum) { 407 child.render(t, true); 408 } 409 } //if the timeline has already ended but the inserted tween/timeline extends the duration, we should enable this timeline again so that it renders properly. We should also align the playhead with the parent timeline's when appropriate. 410 411 412 if (_uncache(timeline, child)._dp && timeline._initted && timeline._time >= timeline._dur && timeline._ts) { 413 //in case any of the ancestors had completed but should now be enabled... 414 if (timeline._dur < timeline.duration()) { 415 t = timeline; 416 417 while (t._dp) { 418 t.rawTime() >= 0 && t.totalTime(t._tTime); //moves the timeline (shifts its startTime) if necessary, and also enables it. If it's currently zero, though, it may not be scheduled to render until later so there's no need to force it to align with the current playhead position. Only move to catch up with the playhead. 419 420 t = t._dp; 421 } 422 } 423 424 timeline._zTime = -_tinyNum; // helps ensure that the next render() will be forced (crossingStart = true in render()), even if the duration hasn't changed (we're adding a child which would need to get rendered). Definitely an edge case. Note: we MUST do this AFTER the loop above where the totalTime() might trigger a render() because this _addToTimeline() method gets called from the Animation constructor, BEFORE tweens even record their targets, etc. so we wouldn't want things to get triggered in the wrong order. 425 } 426}, 427 _addToTimeline = function _addToTimeline(timeline, child, position, skipChecks) { 428 child.parent && _removeFromParent(child); 429 child._start = _roundPrecise((_isNumber(position) ? position : position || timeline !== _globalTimeline ? _parsePosition(timeline, position, child) : timeline._time) + child._delay); 430 child._end = _roundPrecise(child._start + (child.totalDuration() / Math.abs(child.timeScale()) || 0)); 431 432 _addLinkedListItem(timeline, child, "_first", "_last", timeline._sort ? "_start" : 0); 433 434 _isFromOrFromStart(child) || (timeline._recent = child); 435 skipChecks || _postAddChecks(timeline, child); 436 timeline._ts < 0 && _alignPlayhead(timeline, timeline._tTime); // if the timeline is reversed and the new child makes it longer, we may need to adjust the parent's _start (push it back) 437 438 return timeline; 439}, 440 _scrollTrigger = function _scrollTrigger(animation, trigger) { 441 return (_globals.ScrollTrigger || _missingPlugin("scrollTrigger", trigger)) && _globals.ScrollTrigger.create(trigger, animation); 442}, 443 _attemptInitTween = function _attemptInitTween(tween, time, force, suppressEvents, tTime) { 444 _initTween(tween, time, tTime); 445 446 if (!tween._initted) { 447 return 1; 448 } 449 450 if (!force && tween._pt && !_reverting && (tween._dur && tween.vars.lazy !== false || !tween._dur && tween.vars.lazy) && _lastRenderedFrame !== _ticker.frame) { 451 _lazyTweens.push(tween); 452 453 tween._lazy = [tTime, suppressEvents]; 454 return 1; 455 } 456}, 457 _parentPlayheadIsBeforeStart = function _parentPlayheadIsBeforeStart(_ref) { 458 var parent = _ref.parent; 459 return parent && parent._ts && parent._initted && !parent._lock && (parent.rawTime() < 0 || _parentPlayheadIsBeforeStart(parent)); 460}, 461 // check parent's _lock because when a timeline repeats/yoyos and does its artificial wrapping, we shouldn't force the ratio back to 0 462_isFromOrFromStart = function _isFromOrFromStart(_ref2) { 463 var data = _ref2.data; 464 return data === "isFromStart" || data === "isStart"; 465}, 466 _renderZeroDurationTween = function _renderZeroDurationTween(tween, totalTime, suppressEvents, force) { 467 var prevRatio = tween.ratio, 468 ratio = totalTime < 0 || !totalTime && (!tween._start && _parentPlayheadIsBeforeStart(tween) && !(!tween._initted && _isFromOrFromStart(tween)) || (tween._ts < 0 || tween._dp._ts < 0) && !_isFromOrFromStart(tween)) ? 0 : 1, 469 // if the tween or its parent is reversed and the totalTime is 0, we should go to a ratio of 0. Edge case: if a from() or fromTo() stagger tween is placed later in a timeline, the "startAt" zero-duration tween could initially render at a time when the parent timeline's playhead is technically BEFORE where this tween is, so make sure that any "from" and "fromTo" startAt tweens are rendered the first time at a ratio of 1. 470 repeatDelay = tween._rDelay, 471 tTime = 0, 472 pt, 473 iteration, 474 prevIteration; 475 476 if (repeatDelay && tween._repeat) { 477 // in case there's a zero-duration tween that has a repeat with a repeatDelay 478 tTime = _clamp(0, tween._tDur, totalTime); 479 iteration = _animationCycle(tTime, repeatDelay); 480 tween._yoyo && iteration & 1 && (ratio = 1 - ratio); 481 482 if (iteration !== _animationCycle(tween._tTime, repeatDelay)) { 483 // if iteration changed 484 prevRatio = 1 - ratio; 485 tween.vars.repeatRefresh && tween._initted && tween.invalidate(); 486 } 487 } 488 489 if (ratio !== prevRatio || _reverting || force || tween._zTime === _tinyNum || !totalTime && tween._zTime) { 490 if (!tween._initted && _attemptInitTween(tween, totalTime, force, suppressEvents, tTime)) { 491 // if we render the very beginning (time == 0) of a fromTo(), we must force the render (normal tweens wouldn't need to render at a time of 0 when the prevTime was also 0). This is also mandatory to make sure overwriting kicks in immediately. 492 return; 493 } 494 495 prevIteration = tween._zTime; 496 tween._zTime = totalTime || (suppressEvents ? _tinyNum : 0); // when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration tween, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. 497 498 suppressEvents || (suppressEvents = totalTime && !prevIteration); // if it was rendered previously at exactly 0 (_zTime) and now the playhead is moving away, DON'T fire callbacks otherwise they'll seem like duplicates. 499 500 tween.ratio = ratio; 501 tween._from && (ratio = 1 - ratio); 502 tween._time = 0; 503 tween._tTime = tTime; 504 pt = tween._pt; 505 506 while (pt) { 507 pt.r(ratio, pt.d); 508 pt = pt._next; 509 } 510 511 totalTime < 0 && _rewindStartAt(tween, totalTime, suppressEvents, true); 512 tween._onUpdate && !suppressEvents && _callback(tween, "onUpdate"); 513 tTime && tween._repeat && !suppressEvents && tween.parent && _callback(tween, "onRepeat"); 514 515 if ((totalTime >= tween._tDur || totalTime < 0) && tween.ratio === ratio) { 516 ratio && _removeFromParent(tween, 1); 517 518 if (!suppressEvents && !_reverting) { 519 _callback(tween, ratio ? "onComplete" : "onReverseComplete", true); 520 521 tween._prom && tween._prom(); 522 } 523 } 524 } else if (!tween._zTime) { 525 tween._zTime = totalTime; 526 } 527}, 528 _findNextPauseTween = function _findNextPauseTween(animation, prevTime, time) { 529 var child; 530 531 if (time > prevTime) { 532 child = animation._first; 533 534 while (child && child._start <= time) { 535 if (child.data === "isPause" && child._start > prevTime) { 536 return child; 537 } 538 539 child = child._next; 540 } 541 } else { 542 child = animation._last; 543 544 while (child && child._start >= time) { 545 if (child.data === "isPause" && child._start < prevTime) { 546 return child; 547 } 548 549 child = child._prev; 550 } 551 } 552}, 553 _setDuration = function _setDuration(animation, duration, skipUncache, leavePlayhead) { 554 var repeat = animation._repeat, 555 dur = _roundPrecise(duration) || 0, 556 totalProgress = animation._tTime / animation._tDur; 557 totalProgress && !leavePlayhead && (animation._time *= dur / animation._dur); 558 animation._dur = dur; 559 animation._tDur = !repeat ? dur : repeat < 0 ? 1e10 : _roundPrecise(dur * (repeat + 1) + animation._rDelay * repeat); 560 totalProgress > 0 && !leavePlayhead && _alignPlayhead(animation, animation._tTime = animation._tDur * totalProgress); 561 animation.parent && _setEnd(animation); 562 skipUncache || _uncache(animation.parent, animation); 563 return animation; 564}, 565 _onUpdateTotalDuration = function _onUpdateTotalDuration(animation) { 566 return animation instanceof Timeline ? _uncache(animation) : _setDuration(animation, animation._dur); 567}, 568 _zeroPosition = { 569 _start: 0, 570 endTime: _emptyFunc, 571 totalDuration: _emptyFunc 572}, 573 _parsePosition = function _parsePosition(animation, position, percentAnimation) { 574 var labels = animation.labels, 575 recent = animation._recent || _zeroPosition, 576 clippedDuration = animation.duration() >= _bigNum ? recent.endTime(false) : animation._dur, 577 //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. 578 i, 579 offset, 580 isPercent; 581 582 if (_isString(position) && (isNaN(position) || position in labels)) { 583 //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). 584 offset = position.charAt(0); 585 isPercent = position.substr(-1) === "%"; 586 i = position.indexOf("="); 587 588 if (offset === "<" || offset === ">") { 589 i >= 0 && (position = position.replace(/=/, "")); 590 return (offset === "<" ? recent._start : recent.endTime(recent._repeat >= 0)) + (parseFloat(position.substr(1)) || 0) * (isPercent ? (i < 0 ? recent : percentAnimation).totalDuration() / 100 : 1); 591 } 592 593 if (i < 0) { 594 position in labels || (labels[position] = clippedDuration); 595 return labels[position]; 596 } 597 598 offset = parseFloat(position.charAt(i - 1) + position.substr(i + 1)); 599 600 if (isPercent && percentAnimation) { 601 offset = offset / 100 * (_isArray(percentAnimation) ? percentAnimation[0] : percentAnimation).totalDuration(); 602 } 603 604 return i > 1 ? _parsePosition(animation, position.substr(0, i - 1), percentAnimation) + offset : clippedDuration + offset; 605 } 606 607 return position == null ? clippedDuration : +position; 608}, 609 _createTweenType = function _createTweenType(type, params, timeline) { 610 var isLegacy = _isNumber(params[1]), 611 varsIndex = (isLegacy ? 2 : 1) + (type < 2 ? 0 : 1), 612 vars = params[varsIndex], 613 irVars, 614 parent; 615 616 isLegacy && (vars.duration = params[1]); 617 vars.parent = timeline; 618 619 if (type) { 620 irVars = vars; 621 parent = timeline; 622 623 while (parent && !("immediateRender" in irVars)) { 624 // inheritance hasn't happened yet, but someone may have set a default in an ancestor timeline. We could do vars.immediateRender = _isNotFalse(_inheritDefaults(vars).immediateRender) but that'd exact a slight performance penalty because _inheritDefaults() also runs in the Tween constructor. We're paying a small kb price here to gain speed. 625 irVars = parent.vars.defaults || {}; 626 parent = _isNotFalse(parent.vars.inherit) && parent.parent; 627 } 628 629 vars.immediateRender = _isNotFalse(irVars.immediateRender); 630 type < 2 ? vars.runBackwards = 1 : vars.startAt = params[varsIndex - 1]; // "from" vars 631 } 632 633 return new Tween(params[0], vars, params[varsIndex + 1]); 634}, 635 _conditionalReturn = function _conditionalReturn(value, func) { 636 return value || value === 0 ? func(value) : func; 637}, 638 _clamp = function _clamp(min, max, value) { 639 return value < min ? min : value > max ? max : value; 640}, 641 getUnit = function getUnit(value, v) { 642 return !_isString(value) || !(v = _unitExp.exec(value)) ? "" : v[1]; 643}, 644 // note: protect against padded numbers as strings, like "100.100". That shouldn't return "00" as the unit. If it's numeric, return no unit. 645clamp = function clamp(min, max, value) { 646 return _conditionalReturn(value, function (v) { 647 return _clamp(min, max, v); 648 }); 649}, 650 _slice = [].slice, 651 _isArrayLike = function _isArrayLike(value, nonEmpty) { 652 return value && _isObject(value) && "length" in value && (!nonEmpty && !value.length || value.length - 1 in value && _isObject(value[0])) && !value.nodeType && value !== _win; 653}, 654 _flatten = function _flatten(ar, leaveStrings, accumulator) { 655 if (accumulator === void 0) { 656 accumulator = []; 657 } 658 659 return ar.forEach(function (value) { 660 var _accumulator; 661 662 return _isString(value) && !leaveStrings || _isArrayLike(value, 1) ? (_accumulator = accumulator).push.apply(_accumulator, toArray(value)) : accumulator.push(value); 663 }) || accumulator; 664}, 665 //
vendor: 6,500 bytes, lines 665-827
665takes any value and returns an array. If it's a string (and leaveStrings isn't true), it'll use document.querySelectorAll() and convert that to an array. It'll also accept iterables like jQuery objects. 666toArray = function toArray(value, scope, leaveStrings) { 667 return _context && !scope && _context.selector ? _context.selector(value) : _isString(value) && !leaveStrings && (_coreInitted || !_wake()) ? _slice.call((scope || _doc).querySelectorAll(value), 0) : _isArray(value) ? _flatten(value, leaveStrings) : _isArrayLike(value) ? _slice.call(value, 0) : value ? [value] : []; 668}, 669 selector = function selector(value) { 670 value = toArray(value)[0] || _warn("Invalid scope") || {}; 671 return function (v) { 672 var el = value.current || value.nativeElement || value; 673 return toArray(v, el.querySelectorAll ? el : el === value ? _warn("Invalid scope") || _doc.createElement("div") : value); 674 }; 675}, 676 shuffle = function shuffle(a) { 677 return a.sort(function () { 678 return .5 - Math.random(); 679 }); 680}, 681 // alternative that's a bit faster and more reliably diverse but bigger: for (let j, v, i = a.length; i; j = Math.floor(Math.random() * i), v = a[--i], a[i] = a[j], a[j] = v); return a; 682//for distributing values across an array. Can accept a number, a function or (most commonly) a function which can contain the following properties: {base, amount, from, ease, grid, axis, length, each}. Returns a function that expects the following parameters: index, target, array. Recognizes the following 683distribute = function distribute(v) { 684 if (_isFunction(v)) { 685 return v; 686 } 687 688 var vars = _isObject(v) ? v : { 689 each: v 690 }, 691 //n:1 is just to indicate v was a number; we leverage that later to set v according to the length we get. If a number is passed in, we treat it like the old stagger value where 0.1, for example, would mean that things would be distributed with 0.1 between each element in the array rather than a total "amount" that's chunked out among them all. 692 ease = _parseEase(vars.ease), 693 from = vars.from || 0, 694 base = parseFloat(vars.base) || 0, 695 cache = {}, 696 isDecimal = from > 0 && from < 1, 697 ratios = isNaN(from) || isDecimal, 698 axis = vars.axis, 699 ratioX = from, 700 ratioY = from; 701 702 if (_isString(from)) { 703 ratioX = ratioY = { 704 center: .5, 705 edges: .5, 706 end: 1 707 }[from] || 0; 708 } else if (!isDecimal && ratios) { 709 ratioX = from[0]; 710 ratioY = from[1]; 711 } 712 713 return function (i, target, a) { 714 var l = (a || vars).length, 715 distances = cache[l], 716 originX, 717 originY, 718 x, 719 y, 720 d, 721 j, 722 max, 723 min, 724 wrapAt; 725 726 if (!distances) { 727 wrapAt = vars.grid === "auto" ? 0 : (vars.grid || [1, _bigNum])[1]; 728 729 if (!wrapAt) { 730 max = -_bigNum; 731 732 while (max < (max = a[wrapAt++].getBoundingClientRect().left) && wrapAt < l) {} 733 734 wrapAt < l && wrapAt--; 735 } 736 737 distances = cache[l] = []; 738 originX = ratios ? Math.min(wrapAt, l) * ratioX - .5 : from % wrapAt; 739 originY = wrapAt === _bigNum ? 0 : ratios ? l * ratioY / wrapAt - .5 : from / wrapAt | 0; 740 max = 0; 741 min = _bigNum; 742 743 for (j = 0; j < l; j++) { 744 x = j % wrapAt - originX; 745 y = originY - (j / wrapAt | 0); 746 distances[j] = d = !axis ? _sqrt(x * x + y * y) : Math.abs(axis === "y" ? y : x); 747 d > max && (max = d); 748 d < min && (min = d); 749 } 750 751 from === "random" && shuffle(distances); 752 distances.max = max - min; 753 distances.min = min; 754 distances.v = l = (parseFloat(vars.amount) || parseFloat(vars.each) * (wrapAt > l ? l - 1 : !axis ? Math.max(wrapAt, l / wrapAt) : axis === "y" ? l / wrapAt : wrapAt) || 0) * (from === "edges" ? -1 : 1); 755 distances.b = l < 0 ? base - l : base; 756 distances.u = getUnit(vars.amount || vars.each) || 0; //unit 757 758 ease = ease && l < 0 ? _invertEase(ease) : ease; 759 } 760 761 l = (distances[i] - distances.min) / distances.max || 0; 762 return _roundPrecise(distances.b + (ease ? ease(l) : l) * distances.v) + distances.u; //round in order to work around floating point errors 763 }; 764}, 765 _roundModifier = function _roundModifier(v) { 766 //pass in 0.1 get a function that'll round to the nearest tenth, or 5 to round to the closest 5, or 0.001 to the closest 1000th, etc. 767 var p = Math.pow(10, ((v + "").split(".")[1] || "").length); //to avoid floating point math errors (like 24 * 0.1 == 2.4000000000000004), we chop off at a specific number of decimal places (much faster than toFixed()) 768 769 return function (raw) { 770 var n = _roundPrecise(Math.round(parseFloat(raw) / v) * v * p); 771 772 return (n - n % 1) / p + (_isNumber(raw) ? 0 : getUnit(raw)); // n - n % 1 replaces Math.floor() in order to handle negative values properly. For example, Math.floor(-150.00000000000003) is 151! 773 }; 774}, 775 snap = function snap(snapTo, value) { 776 var isArray = _isArray(snapTo), 777 radius, 778 is2D; 779 780 if (!isArray && _isObject(snapTo)) { 781 radius = isArray = snapTo.radius || _bigNum; 782 783 if (snapTo.values) { 784 snapTo = toArray(snapTo.values); 785 786 if (is2D = !_isNumber(snapTo[0])) { 787 radius *= radius; //performance optimization so we don't have to Math.sqrt() in the loop. 788 } 789 } else { 790 snapTo = _roundModifier(snapTo.increment); 791 } 792 } 793 794 return _conditionalReturn(value, !isArray ? _roundModifier(snapTo) : _isFunction(snapTo) ? function (raw) { 795 is2D = snapTo(raw); 796 return Math.abs(is2D - raw) <= radius ? is2D : raw; 797 } : function (raw) { 798 var x = parseFloat(is2D ? raw.x : raw), 799 y = parseFloat(is2D ? raw.y : 0), 800 min = _bigNum, 801 closest = 0, 802 i = snapTo.length, 803 dx, 804 dy; 805 806 while (i--) { 807 if (is2D) { 808 dx = snapTo[i].x - x; 809 dy = snapTo[i].y - y; 810 dx = dx * dx + dy * dy; 811 } else { 812 dx = Math.abs(snapTo[i] - x); 813 } 814 815 if (dx < min) { 816 min = dx; 817 closest = i; 818 } 819 } 820 821 closest = !radius || min <= radius ? snapTo[closest] : raw; 822 return is2D || closest === raw || _isNumber(raw) ? closest : closest + getUnit(raw); 823 }); 824}, 825 random = function random(min, max, roundingIncrement, returnFunction) { 826 return _conditionalReturn(_isArray(min) ? !max : roundingIncrement === true ? !!(roundingIncrement = 0) : !returnFunction, function () { 827 return _isArray(min) ? min[~~(Math.random() * min.length)] : (roundingIncrement = roundingIncrement || 1e
vendor: 2,410 bytes, lines 827-886
827-5) && (returnFunction = roundingIncrement < 1 ? Math.pow(10, (roundingIncrement + "").length - 2) : 1) && Math.floor(Math.round((min - roundingIncrement / 2 + Math.random() * (max - min + roundingIncrement * .99)) / roundingIncrement) * roundingIncrement * returnFunction) / returnFunction; 828 }); 829}, 830 pipe = function pipe() { 831 for (var _len = arguments.length, functions = new Array(_len), _key = 0; _key < _len; _key++) { 832 functions[_key] = arguments[_key]; 833 } 834 835 return function (value) { 836 return functions.reduce(function (v, f) { 837 return f(v); 838 }, value); 839 }; 840}, 841 unitize = function unitize(func, unit) { 842 return function (value) { 843 return func(parseFloat(value)) + (unit || getUnit(value)); 844 }; 845}, 846 normalize = function normalize(min, max, value) { 847 return mapRange(min, max, 0, 1, value); 848}, 849 _wrapArray = function _wrapArray(a, wrapper, value) { 850 return _conditionalReturn(value, function (index) { 851 return a[~~wrapper(index)]; 852 }); 853}, 854 wrap = function wrap(min, max, value) { 855 // NOTE: wrap() CANNOT be an arrow function! A very odd compiling bug causes problems (unrelated to GSAP). 856 var range = max - min; 857 return _isArray(min) ? _wrapArray(min, wrap(0, min.length), max) : _conditionalReturn(value, function (value) { 858 return (range + (value - min) % range) % range + min; 859 }); 860}, 861 wrapYoyo = function wrapYoyo(min, max, value) { 862 var range = max - min, 863 total = range * 2; 864 return _isArray(min) ? _wrapArray(min, wrapYoyo(0, min.length - 1), max) : _conditionalReturn(value, function (value) { 865 value = (total + (value - min) % total) % total || 0; 866 return min + (value > range ? total - value : value); 867 }); 868}, 869 _replaceRandom = function _replaceRandom(value) { 870 //replaces all occurrences of random(...) in a string with the calculated random value. can be a range like random(-100, 100, 5) or an array like random([0, 100, 500]) 871 var prev = 0, 872 s = "", 873 i, 874 nums, 875 end, 876 isArray; 877 878 while (~(i = value.indexOf("random(", prev))) { 879 end = value.indexOf(")", i); 880 isArray = value.charAt(i + 7) === "["; 881 nums = value.substr(i + 7, end - i - 7).match(isArray ? _delimitedValueExp : _strictNumExp); 882 s += value.substr(prev, i - prev) + random(isArray ? nums : +nums[0], isArray ? 0 : +nums[1], +nums[2] || 1e-5); 883 prev = end + 1; 884 } 885 886 return s + value.substr(prev, value.length - prev
vendor: 17,631 bytes, lines 886-1442
886); 887}, 888 mapRange = function mapRange(inMin, inMax, outMin, outMax, value) { 889 var inRange = inMax - inMin, 890 outRange = outMax - outMin; 891 return _conditionalReturn(value, function (value) { 892 return outMin + ((value - inMin) / inRange * outRange || 0); 893 }); 894}, 895 interpolate = function interpolate(start, end, progress, mutate) { 896 var func = isNaN(start + end) ? 0 : function (p) { 897 return (1 - p) * start + p * end; 898 }; 899 900 if (!func) { 901 var isString = _isString(start), 902 master = {}, 903 p, 904 i, 905 interpolators, 906 l, 907 il; 908 909 progress === true && (mutate = 1) && (progress = null); 910 911 if (isString) { 912 start = { 913 p: start 914 }; 915 end = { 916 p: end 917 }; 918 } else if (_isArray(start) && !_isArray(end)) { 919 interpolators = []; 920 l = start.length; 921 il = l - 2; 922 923 for (i = 1; i < l; i++) { 924 interpolators.push(interpolate(start[i - 1], start[i])); //build the interpolators up front as a performance optimization so that when the function is called many times, it can just reuse them. 925 } 926 927 l--; 928 929 func = function func(p) { 930 p *= l; 931 var i = Math.min(il, ~~p); 932 return interpolators[i](p - i); 933 }; 934 935 progress = end; 936 } else if (!mutate) { 937 start = _merge(_isArray(start) ? [] : {}, start); 938 } 939 940 if (!interpolators) { 941 for (p in end) { 942 _addPropTween.call(master, start, p, "get", end[p]); 943 } 944 945 func = function func(p) { 946 return _renderPropTweens(p, master) || (isString ? start.p : start); 947 }; 948 } 949 } 950 951 return _conditionalReturn(progress, func); 952}, 953 _getLabelInDirection = function _getLabelInDirection(timeline, fromTime, backward) { 954 //used for nextLabel() and previousLabel() 955 var labels = timeline.labels, 956 min = _bigNum, 957 p, 958 distance, 959 label; 960 961 for (p in labels) { 962 distance = labels[p] - fromTime; 963 964 if (distance < 0 === !!backward && distance && min > (distance = Math.abs(distance))) { 965 label = p; 966 min = distance; 967 } 968 } 969 970 return label; 971}, 972 _callback = function _callback(animation, type, executeLazyFirst) { 973 var v = animation.vars, 974 callback = v[type], 975 prevContext = _context, 976 context = animation._ctx, 977 params, 978 scope, 979 result; 980 981 if (!callback) { 982 return; 983 } 984 985 params = v[type + "Params"]; 986 scope = v.callbackScope || animation; 987 executeLazyFirst && _lazyTweens.length && _lazyRender(); //in case rendering caused any tweens to lazy-init, we should render them because typically when a timeline finishes, users expect things to have rendered fully. Imagine an onUpdate on a timeline that reports/checks tweened values. 988 989 context && (_context = context); 990 result = params ? callback.apply(scope, params) : callback.call(scope); 991 _context = prevContext; 992 return result; 993}, 994 _interrupt = function _interrupt(animation) { 995 _removeFromParent(animation); 996 997 animation.scrollTrigger && animation.scrollTrigger.kill(!!_reverting); 998 animation.progress() < 1 && _callback(animation, "onInterrupt"); 999 return animation; 1000}, 1001 _quickTween, 1002 _registerPluginQueue = [], 1003 _createPlugin = function _createPlugin(config) { 1004 if (!config) return; 1005 config = !config.name && config["default"] || config; // UMD packaging wraps things oddly, so for example MotionPathHelper becomes {MotionPathHelper:MotionPathHelper, default:MotionPathHelper}. 1006 1007 if (_windowExists() || config.headless) { 1008 // edge case: some build tools may pass in a null/undefined value 1009 var name = config.name, 1010 isFunc = _isFunction(config), 1011 Plugin = name && !isFunc && config.init ? function () { 1012 this._props = []; 1013 } : config, 1014 //in case someone passes in an object that's not a plugin, like CustomEase 1015 instanceDefaults = { 1016 init: _emptyFunc, 1017 render: _renderPropTweens, 1018 add: _addPropTween, 1019 kill: _killPropTweensOf, 1020 modifier: _addPluginModifier, 1021 rawVars: 0 1022 }, 1023 statics = { 1024 targetTest: 0, 1025 get: 0, 1026 getSetter: _getSetter, 1027 aliases: {}, 1028 register: 0 1029 }; 1030 1031 _wake(); 1032 1033 if (config !== Plugin) { 1034 if (_plugins[name]) { 1035 return; 1036 } 1037 1038 _setDefaults(Plugin, _setDefaults(_copyExcluding(config, instanceDefaults), statics)); //static methods 1039 1040 1041 _merge(Plugin.prototype, _merge(instanceDefaults, _copyExcluding(config, statics))); //instance methods 1042 1043 1044 _plugins[Plugin.prop = name] = Plugin; 1045 1046 if (config.targetTest) { 1047 _harnessPlugins.push(Plugin); 1048 1049 _reservedProps[name] = 1; 1050 } 1051 1052 name = (name === "css" ? "CSS" : name.charAt(0).toUpperCase() + name.substr(1)) + "Plugin"; //for the global name. "motionPath" should become MotionPathPlugin 1053 } 1054 1055 _addGlobal(name, Plugin); 1056 1057 config.register && config.register(gsap, Plugin, PropTween); 1058 } else { 1059 _registerPluginQueue.push(config); 1060 } 1061}, 1062 1063/* 1064 * -------------------------------------------------------------------------------------- 1065 * COLORS 1066 * -------------------------------------------------------------------------------------- 1067 */ 1068_255 = 255, 1069 _colorLookup = { 1070 aqua: [0, _255, _255], 1071 lime: [0, _255, 0], 1072 silver: [192, 192, 192], 1073 black: [0, 0, 0], 1074 maroon: [128, 0, 0], 1075 teal: [0, 128, 128], 1076 blue: [0, 0, _255], 1077 navy: [0, 0, 128], 1078 white: [_255, _255, _255], 1079 olive: [128, 128, 0], 1080 yellow: [_255, _255, 0], 1081 orange: [_255, 165, 0], 1082 gray: [128, 128, 128], 1083 purple: [128, 0, 128], 1084 green: [0, 128, 0], 1085 red: [_255, 0, 0], 1086 pink: [_255, 192, 203], 1087 cyan: [0, _255, _255], 1088 transparent: [_255, _255, _255, 0] 1089}, 1090 // possible future idea to replace the hard-coded color name values - put this in the ticker.wake() where we set the _doc: 1091// let ctx = _doc.createElement("canvas").getContext("2d"); 1092// _forEachName("aqua,lime,silver,black,maroon,teal,blue,navy,white,olive,yellow,orange,gray,purple,green,red,pink,cyan", color => {ctx.fillStyle = color; _colorLookup[color] = splitColor(ctx.fillStyle)}); 1093_hue = function _hue(h, m1, m2) { 1094 h += h < 0 ? 1 : h > 1 ? -1 : 0; 1095 return (h * 6 < 1 ? m1 + (m2 - m1) * h * 6 : h < .5 ? m2 : h * 3 < 2 ? m1 + (m2 - m1) * (2 / 3 - h) * 6 : m1) * _255 + .5 | 0; 1096}, 1097 splitColor = function splitColor(v, toHSL, forceAlpha) { 1098 var a = !v ? _colorLookup.black : _isNumber(v) ? [v >> 16, v >> 8 & _255, v & _255] : 0, 1099 r, 1100 g, 1101 b, 1102 h, 1103 s, 1104 l, 1105 max, 1106 min, 1107 d, 1108 wasHSL; 1109 1110 if (!a) { 1111 if (v.substr(-1) === ",") { 1112 //sometimes a trailing comma is included and we should chop it off (typically from a comma-delimited list of values like a textShadow:"2px 2px 2px blue, 5px 5px 5px rgb(255,0,0)" - in this example "blue," has a trailing comma. We could strip it out inside parseComplex() but we'd need to do it to the beginning and ending values plus it wouldn't provide protection from other potential scenarios like if the user passes in a similar value. 1113 v = v.substr(0, v.length - 1); 1114 } 1115 1116 if (_colorLookup[v]) { 1117 a = _colorLookup[v]; 1118 } else if (v.charAt(0) === "#") { 1119 if (v.length < 6) { 1120 //for shorthand like #9F0 or #9F0F (could have alpha) 1121 r = v.charAt(1); 1122 g = v.charAt(2); 1123 b = v.charAt(3); 1124 v = "#" + r + r + g + g + b + b + (v.length === 5 ? v.charAt(4) + v.charAt(4) : ""); 1125 } 1126 1127 if (v.length === 9) { 1128 // hex with alpha, like #fd5e53ff 1129 a = parseInt(v.substr(1, 6), 16); 1130 return [a >> 16, a >> 8 & _255, a & _255, parseInt(v.substr(7), 16) / 255]; 1131 } 1132 1133 v = parseInt(v.substr(1), 16); 1134 a = [v >> 16, v >> 8 & _255, v & _255]; 1135 } else if (v.substr(0, 3) === "hsl") { 1136 a = wasHSL = v.match(_strictNumExp); 1137 1138 if (!toHSL) { 1139 h = +a[0] % 360 / 360; 1140 s = +a[1] / 100; 1141 l = +a[2] / 100; 1142 g = l <= .5 ? l * (s + 1) : l + s - l * s; 1143 r = l * 2 - g; 1144 a.length > 3 && (a[3] *= 1); //cast as number 1145 1146 a[0] = _hue(h + 1 / 3, r, g); 1147 a[1] = _hue(h, r, g); 1148 a[2] = _hue(h - 1 / 3, r, g); 1149 } else if (~v.indexOf("=")) { 1150 //if relative values are found, just return the raw strings with the relative prefixes in place. 1151 a = v.match(_numExp); 1152 forceAlpha && a.length < 4 && (a[3] = 1); 1153 return a; 1154 } 1155 } else { 1156 a = v.match(_strictNumExp) || _colorLookup.transparent; 1157 } 1158 1159 a = a.map(Number); 1160 } 1161 1162 if (toHSL && !wasHSL) { 1163 r = a[0] / _255; 1164 g = a[1] / _255; 1165 b = a[2] / _255; 1166 max = Math.max(r, g, b); 1167 min = Math.min(r, g, b); 1168 l = (max + min) / 2; 1169 1170 if (max === min) { 1171 h = s = 0; 1172 } else { 1173 d = max - min; 1174 s = l > 0.5 ? d / (2 - max - min) : d / (max + min); 1175 h = max === r ? (g - b) / d + (g < b ? 6 : 0) : max === g ? (b - r) / d + 2 : (r - g) / d + 4; 1176 h *= 60; 1177 } 1178 1179 a[0] = ~~(h + .5); 1180 a[1] = ~~(s * 100 + .5); 1181 a[2] = ~~(l * 100 + .5); 1182 } 1183 1184 forceAlpha && a.length < 4 && (a[3] = 1); 1185 return a; 1186}, 1187 _colorOrderData = function _colorOrderData(v) { 1188 // strips out the colors from the string, finds all the numeric slots (with units) and returns an array of those. The Array also has a "c" property which is an Array of the index values where the colors belong. This is to help work around issues where there's a mis-matched order of color/numeric data like drop-shadow(#f00 0px 1px 2px) and drop-shadow(0x 1px 2px #f00). This is basically a helper function used in _formatColors() 1189 var values = [], 1190 c = [], 1191 i = -1; 1192 v.split(_colorExp).forEach(function (v) { 1193 var a = v.match(_numWithUnitExp) || []; 1194 values.push.apply(values, a); 1195 c.push(i += a.length + 1); 1196 }); 1197 values.c = c; 1198 return values; 1199}, 1200 _formatColors = function _formatColors(s, toHSL, orderMatchData) { 1201 var result = "", 1202 colors = (s + result).match(_colorExp), 1203 type = toHSL ? "hsla(" : "rgba(", 1204 i = 0, 1205 c, 1206 shell, 1207 d, 1208 l; 1209 1210 if (!colors) { 1211 return s; 1212 } 1213 1214 colors = colors.map(function (color) { 1215 return (color = splitColor(color, toHSL, 1)) && type + (toHSL ? color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : color.join(",")) + ")"; 1216 }); 1217 1218 if (orderMatchData) { 1219 d = _colorOrderData(s); 1220 c = orderMatchData.c; 1221 1222 if (c.join(result) !== d.c.join(result)) { 1223 shell = s.replace(_colorExp, "1").split(_numWithUnitExp); 1224 l = shell.length - 1; 1225 1226 for (; i < l; i++) { 1227 result += shell[i] + (~c.indexOf(i) ? colors.shift() || type + "0,0,0,0)" : (d.length ? d : colors.length ? colors : orderMatchData).shift()); 1228 } 1229 } 1230 } 1231 1232 if (!shell) { 1233 shell = s.split(_colorExp); 1234 l = shell.length - 1; 1235 1236 for (; i < l; i++) { 1237 result += shell[i] + colors[i]; 1238 } 1239 } 1240 1241 return result + shell[l]; 1242}, 1243 _colorExp = function () { 1244 var s = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3,4}){1,2}\\b", 1245 //we'll dynamically build this Regular Expression to conserve file size. After building it, it will be able to find rgb(), rgba(), # (hexadecimal), and named color values like red, blue, purple, etc., 1246 p; 1247 1248 for (p in _colorLookup) { 1249 s += "|" + p + "\\b"; 1250 } 1251 1252 return new RegExp(s + ")", "gi"); 1253}(), 1254 _hslExp = /hsl[a]?\(/, 1255 _colorStringFilter = function _colorStringFilter(a) { 1256 var combined = a.join(" "), 1257 toHSL; 1258 _colorExp.lastIndex = 0; 1259 1260 if (_colorExp.test(combined)) { 1261 toHSL = _hslExp.test(combined); 1262 a[1] = _formatColors(a[1], toHSL); 1263 a[0] = _formatColors(a[0], toHSL, _colorOrderData(a[1])); // make sure the order of numbers/colors match with the END value. 1264 1265 return true; 1266 } 1267}, 1268 1269/* 1270 * -------------------------------------------------------------------------------------- 1271 * TICKER 1272 * -------------------------------------------------------------------------------------- 1273 */ 1274_tickerActive, 1275 _ticker = function () { 1276 var _getTime = Date.now, 1277 _lagThreshold = 500, 1278 _adjustedLag = 33, 1279 _startTime = _getTime(), 1280 _lastUpdate = _startTime, 1281 _gap = 1000 / 240, 1282 _nextTime = _gap, 1283 _listeners = [], 1284 _id, 1285 _req, 1286 _raf, 1287 _self, 1288 _delta, 1289 _i, 1290 _tick = function _tick(v) { 1291 var elapsed = _getTime() - _lastUpdate, 1292 manual = v === true, 1293 overlap, 1294 dispatch, 1295 time, 1296 frame; 1297 1298 (elapsed > _lagThreshold || elapsed < 0) && (_startTime += elapsed - _adjustedLag); 1299 _lastUpdate += elapsed; 1300 time = _lastUpdate - _startTime; 1301 overlap = time - _nextTime; 1302 1303 if (overlap > 0 || manual) { 1304 frame = ++_self.frame; 1305 _delta = time - _self.time * 1000; 1306 _self.time = time = time / 1000; 1307 _nextTime += overlap + (overlap >= _gap ? 4 : _gap - overlap); 1308 dispatch = 1; 1309 } 1310 1311 manual || (_id = _req(_tick)); //make sure the request is made before we dispatch the "tick" event so that timing is maintained. Otherwise, if processing the "tick" requires a bunch of time (like 15ms) and we're using a setTimeout() that's based on 16.7ms, it'd technically take 31.7ms between frames otherwise. 1312 1313 if (dispatch) { 1314 for (_i = 0; _i < _listeners.length; _i++) { 1315 // use _i and check _listeners.length instead of a variable because a listener could get removed during the loop, and if that happens to an element less than the current index, it'd throw things off in the loop. 1316 _listeners[_i](time, _delta, frame, v); 1317 } 1318 } 1319 }; 1320 1321 _self = { 1322 time: 0, 1323 frame: 0, 1324 tick: function tick() { 1325 _tick(true); 1326 }, 1327 deltaRatio: function deltaRatio(fps) { 1328 return _delta / (1000 / (fps || 60)); 1329 }, 1330 wake: function wake() { 1331 if (_coreReady) { 1332 if (!_coreInitted && _windowExists()) { 1333 _win = _coreInitted = window; 1334 _doc = _win.document || {}; 1335 _globals.gsap = gsap; 1336 (_win.gsapVersions || (_win.gsapVersions = [])).push(gsap.version); 1337 1338 _install(_installScope || _win.GreenSockGlobals || !_win.gsap && _win || {}); 1339 1340 _registerPluginQueue.forEach(_createPlugin); 1341 } 1342 1343 _raf = typeof requestAnimationFrame !== "undefined" && requestAnimationFrame; 1344 _id && _self.sleep(); 1345 1346 _req = _raf || function (f) { 1347 return setTimeout(f, _nextTime - _self.time * 1000 + 1 | 0); 1348 }; 1349 1350 _tickerActive = 1; 1351 1352 _tick(2); 1353 } 1354 }, 1355 sleep: function sleep() { 1356 (_raf ? cancelAnimationFrame : clearTimeout)(_id); 1357 _tickerActive = 0; 1358 _req = _emptyFunc; 1359 }, 1360 lagSmoothing: function lagSmoothing(threshold, adjustedLag) { 1361 _lagThreshold = threshold || Infinity; // zero should be interpreted as basically unlimited 1362 1363 _adjustedLag = Math.min(adjustedLag || 33, _lagThreshold); 1364 }, 1365 fps: function fps(_fps) { 1366 _gap = 1000 / (_fps || 240); 1367 _nextTime = _self.time * 1000 + _gap; 1368 }, 1369 add: function add(callback, once, prioritize) { 1370 var func = once ? function (t, d, f, v) { 1371 callback(t, d, f, v); 1372 1373 _self.remove(func); 1374 } : callback; 1375 1376 _self.remove(callback); 1377 1378 _listeners[prioritize ? "unshift" : "push"](func); 1379 1380 _wake(); 1381 1382 return func; 1383 }, 1384 remove: function remove(callback, i) { 1385 ~(i = _listeners.indexOf(callback)) && _listeners.splice(i, 1) && _i >= i && _i--; 1386 }, 1387 _listeners: _listeners 1388 }; 1389 return _self; 1390}(), 1391 _wake = function _wake() { 1392 return !_tickerActive && _ticker.wake(); 1393}, 1394 //also ensures the core classes are initialized. 1395 1396/* 1397* ------------------------------------------------- 1398* EASING 1399* ------------------------------------------------- 1400*/ 1401_easeMap = {}, 1402 _customEaseExp = /^[\d.\-M][\d.\-,\s]/, 1403 _quotesExp = /["']/g, 1404 _parseObjectInString = function _parseObjectInString(value) { 1405 //takes a string like "{wiggles:10, type:anticipate})" and turns it into a real object. Notice it ends in ")" and includes the {} wrappers. This is because we only use this function for parsing ease configs and prioritized optimization rather than reusability. 1406 var obj = {}, 1407 split = value.substr(1, value.length - 3).split(":"), 1408 key = split[0], 1409 i = 1, 1410 l = split.length, 1411 index, 1412 val, 1413 parsedVal; 1414 1415 for (; i < l; i++) { 1416 val = split[i]; 1417 index = i !== l - 1 ? val.lastIndexOf(",") : val.length; 1418 parsedVal = val.substr(0, index); 1419 obj[key] = isNaN(parsedVal) ? parsedVal.replace(_quotesExp, "").trim() : +parsedVal; 1420 key = val.substr(index + 1).trim(); 1421 } 1422 1423 return obj; 1424}, 1425 _valueInParentheses = function _valueInParentheses(value) { 1426 var open = value.indexOf("(") + 1, 1427 close = value.indexOf(")"), 1428 nested = value.indexOf("(", open); 1429 return value.substring(open, ~nested && nested < close ? value.indexOf(")", close + 1) : close); 1430}, 1431 _configEaseFromString = function _configEaseFromString(name) { 1432 //name can be a string like "elastic.out(1,0.5)", and pass in _easeMap as obj and it'll parse it out and call the actual function like _easeMap.Elastic.easeOut.config(1,0.5). It will also parse custom ease strings as long as CustomEase is loaded and registered (internally as _easeMap._CE). 1433 var split = (name + "").split("("), 1434 ease = _easeMap[split[0]]; 1435 return ease && split.length > 1 && ease.config ? ease.config.apply(null, ~name.indexOf("{") ? [_parseObjectInString(split[1])] : _valueInParentheses(name).split(",").map(_numericIfPossible)) : _easeMap._CE && _customEaseExp.test(name) ? _easeMap._CE("", name) : ease; 1436}, 1437 _invertEase = function _invertEase(ease) { 1438 return function (p) { 1439 return 1 - ease(1 - p); 1440 }; 1441}, 1442
vendor: 4,279 bytes, lines 1442-1570
1442// allow yoyoEase to be set in children and have those affected when the parent/ancestor timeline yoyos. 1443_propagateYoyoEase = function _propagateYoyoEase(timeline, isYoyo) { 1444 var child = timeline._first, 1445 ease; 1446 1447 while (child) { 1448 if (child instanceof Timeline) { 1449 _propagateYoyoEase(child, isYoyo); 1450 } else if (child.vars.yoyoEase && (!child._yoyo || !child._repeat) && child._yoyo !== isYoyo) { 1451 if (child.timeline) { 1452 _propagateYoyoEase(child.timeline, isYoyo); 1453 } else { 1454 ease = child._ease; 1455 child._ease = child._yEase; 1456 child._yEase = ease; 1457 child._yoyo = isYoyo; 1458 } 1459 } 1460 1461 child = child._next; 1462 } 1463}, 1464 _parseEase = function _parseEase(ease, defaultEase) { 1465 return !ease ? defaultEase : (_isFunction(ease) ? ease : _easeMap[ease] || _configEaseFromString(ease)) || defaultEase; 1466}, 1467 _insertEase = function _insertEase(names, easeIn, easeOut, easeInOut) { 1468 if (easeOut === void 0) { 1469 easeOut = function easeOut(p) { 1470 return 1 - easeIn(1 - p); 1471 }; 1472 } 1473 1474 if (easeInOut === void 0) { 1475 easeInOut = function easeInOut(p) { 1476 return p < .5 ? easeIn(p * 2) / 2 : 1 - easeIn((1 - p) * 2) / 2; 1477 }; 1478 } 1479 1480 var ease = { 1481 easeIn: easeIn, 1482 easeOut: easeOut, 1483 easeInOut: easeInOut 1484 }, 1485 lowercaseName; 1486 1487 _forEachName(names, function (name) { 1488 _easeMap[name] = _globals[name] = ease; 1489 _easeMap[lowercaseName = name.toLowerCase()] = easeOut; 1490 1491 for (var p in ease) { 1492 _easeMap[lowercaseName + (p === "easeIn" ? ".in" : p === "easeOut" ? ".out" : ".inOut")] = _easeMap[name + "." + p] = ease[p]; 1493 } 1494 }); 1495 1496 return ease; 1497}, 1498 _easeInOutFromOut = function _easeInOutFromOut(easeOut) { 1499 return function (p) { 1500 return p < .5 ? (1 - easeOut(1 - p * 2)) / 2 : .5 + easeOut((p - .5) * 2) / 2; 1501 }; 1502}, 1503 _configElastic = function _configElastic(type, amplitude, period) { 1504 var p1 = amplitude >= 1 ? amplitude : 1, 1505 //note: if amplitude is < 1, we simply adjust the period for a more natural feel. Otherwise the math doesn't work right and the curve starts at 1. 1506 p2 = (period || (type ? .3 : .45)) / (amplitude < 1 ? amplitude : 1), 1507 p3 = p2 / _2PI * (Math.asin(1 / p1) || 0), 1508 easeOut = function easeOut(p) { 1509 return p === 1 ? 1 : p1 * Math.pow(2, -10 * p) * _sin((p - p3) * p2) + 1; 1510 }, 1511 ease = type === "out" ? easeOut : type === "in" ? function (p) { 1512 return 1 - easeOut(1 - p); 1513 } : _easeInOutFromOut(easeOut); 1514 1515 p2 = _2PI / p2; //precalculate to optimize 1516 1517 ease.config = function (amplitude, period) { 1518 return _configElastic(type, amplitude, period); 1519 }; 1520 1521 return ease; 1522}, 1523 _configBack = function _configBack(type, overshoot) { 1524 if (overshoot === void 0) { 1525 overshoot = 1.70158; 1526 } 1527 1528 var easeOut = function easeOut(p) { 1529 return p ? --p * p * ((overshoot + 1) * p + overshoot) + 1 : 0; 1530 }, 1531 ease = type === "out" ? easeOut : type === "in" ? function (p) { 1532 return 1 - easeOut(1 - p); 1533 } : _easeInOutFromOut(easeOut); 1534 1535 ease.config = function (overshoot) { 1536 return _configBack(type, overshoot); 1537 }; 1538 1539 return ease; 1540}; // a cheaper (kb and cpu) but more mild way to get a parameterized weighted ease by feeding in a value between -1 (easeIn) and 1 (easeOut) where 0 is linear. 1541// _weightedEase = ratio => { 1542// let y = 0.5 + ratio / 2; 1543// return p => (2 * (1 - p) * p * y + p * p); 1544// }, 1545// a stronger (but more expensive kb/cpu) parameterized weighted ease that lets you feed in a value between -1 (easeIn) and 1 (easeOut) where 0 is linear. 1546// _weightedEaseStrong = ratio => { 1547// ratio = .5 + ratio / 2; 1548// let o = 1 / 3 * (ratio < .5 ? ratio : 1 - ratio), 1549// b = ratio - o, 1550// c = ratio + o; 1551// return p => p === 1 ? p : 3 * b * (1 - p) * (1 - p) * p + 3 * c * (1 - p) * p * p + p * p * p; 1552// }; 1553 1554 1555_forEachName("Linear,Quad,Cubic,Quart,Quint,Strong", function (name, i) { 1556 var power = i < 5 ? i + 1 : i; 1557 1558 _insertEase(name + ",Power" + (power - 1), i ? function (p) { 1559 return Math.pow(p, power); 1560 } : function (p) { 1561 return p; 1562 }, function (p) { 1563 return 1 - Math.pow(1 - p, power); 1564 }, function (p) { 1565 return p < .5 ? Math.pow(p * 2, power) / 2 : 1 - Math.pow((1 - p) * 2, power) / 2; 1566 }); 1567}); 1568 1569_easeMap.Linear.easeNone = _easeMap.none = _easeMap.Linear.easeIn; 1570
vendor: 4,129 bytes, lines 1571-1705
1571_insertEase("Elastic", _configElastic("in"), _configElastic("out"), _configElastic()); 1572 1573(function (n, c) { 1574 var n1 = 1 / c, 1575 n2 = 2 * n1, 1576 n3 = 2.5 * n1, 1577 easeOut = function easeOut(p) { 1578 return p < n1 ? n * p * p : p < n2 ? n * Math.pow(p - 1.5 / c, 2) + .75 : p < n3 ? n * (p -= 2.25 / c) * p + .9375 : n * Math.pow(p - 2.625 / c, 2) + .984375; 1579 }; 1580 1581 _insertEase("Bounce", function (p) { 1582 return 1 - easeOut(1 - p); 1583 }, easeOut); 1584})(7.5625, 2.75); 1585 1586_insertEase("Expo", function (p) { 1587 return p ? Math.pow(2, 10 * (p - 1)) : 0; 1588}); 1589 1590_insertEase("Circ", function (p) { 1591 return -(_sqrt(1 - p * p) - 1); 1592}); 1593 1594_insertEase("Sine", function (p) { 1595 return p === 1 ? 1 : -_cos(p * _HALF_PI) + 1; 1596}); 1597 1598_insertEase("Back", _configBack("in"), _configBack("out"), _configBack()); 1599 1600_easeMap.SteppedEase = _easeMap.steps = _globals.SteppedEase = { 1601 config: function config(steps, immediateStart) { 1602 if (steps === void 0) { 1603 steps = 1; 1604 } 1605 1606 var p1 = 1 / steps, 1607 p2 = steps + (immediateStart ? 0 : 1), 1608 p3 = immediateStart ? 1 : 0, 1609 max = 1 - _tinyNum; 1610 return function (p) { 1611 return ((p2 * _clamp(0, max, p) | 0) + p3) * p1; 1612 }; 1613 } 1614}; 1615_defaults.ease = _easeMap["quad.out"]; 1616 1617_forEachName("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt", function (name) { 1618 return _callbackNames += name + "," + name + "Params,"; 1619}); 1620/* 1621 * -------------------------------------------------------------------------------------- 1622 * CACHE 1623 * -------------------------------------------------------------------------------------- 1624 */ 1625 1626 1627export var GSCache = function GSCache(target, harness) { 1628 this.id = _gsID++; 1629 target._gsap = this; 1630 this.target = target; 1631 this.harness = harness; 1632 this.get = harness ? harness.get : _getProperty; 1633 this.set = harness ? harness.getSetter : _getSetter; 1634}; 1635/* 1636 * -------------------------------------------------------------------------------------- 1637 * ANIMATION 1638 * -------------------------------------------------------------------------------------- 1639 */ 1640 1641export var Animation = /*#__PURE__*/function () { 1642 function Animation(vars) { 1643 this.vars = vars; 1644 this._delay = +vars.delay || 0; 1645 1646 if (this._repeat = vars.repeat === Infinity ? -2 : vars.repeat || 0) { 1647 // TODO: repeat: Infinity on a timeline's children must flag that timeline internally and affect its totalDuration, otherwise it'll stop in the negative direction when reaching the start. 1648 this._rDelay = vars.repeatDelay || 0; 1649 this._yoyo = !!vars.yoyo || !!vars.yoyoEase; 1650 } 1651 1652 this._ts = 1; 1653 1654 _setDuration(this, +vars.duration, 1, 1); 1655 1656 this.data = vars.data; 1657 1658 if (_context) { 1659 this._ctx = _context; 1660 1661 _context.data.push(this); 1662 } 1663 1664 _tickerActive || _ticker.wake(); 1665 } 1666 1667 var _proto = Animation.prototype; 1668 1669 _proto.delay = function delay(value) { 1670 if (value || value === 0) { 1671 this.parent && this.parent.smoothChildTiming && this.startTime(this._start + value - this._delay); 1672 this._delay = value; 1673 return this; 1674 } 1675 1676 return this._delay; 1677 }; 1678 1679 _proto.duration = function duration(value) { 1680 return arguments.length ? this.totalDuration(this._repeat > 0 ? value + (value + this._rDelay) * this._repeat : value) : this.totalDuration() && this._dur; 1681 }; 1682 1683 _proto.totalDuration = function totalDuration(value) { 1684 if (!arguments.length) { 1685 return this._tDur; 1686 } 1687 1688 this._dirty = 0; 1689 return _setDuration(this, this._repeat < 0 ? value : (value - this._repeat * this._rDelay) / (this._repeat + 1)); 1690 }; 1691 1692 _proto.totalTime = function totalTime(_totalTime, suppressEvents) { 1693 _wake(); 1694 1695 if (!arguments.length) { 1696 return this._tTime; 1697 } 1698 1699 var parent = this._dp; 1700 1701 if (parent && parent.smoothChildTiming && this._ts) { 1702 _alignPlayhead(this, _totalTime); 1703 1704 !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. 1705 //in case any of the ancestor timelines had completed but should now be enabled, we should reset the
vendor: 9,142 bytes, lines 1705-1856
1705ir 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. 1706 1707 while (parent && parent.parent) { 1708 if (parent.parent._time !== parent._start + (parent._ts >= 0 ? parent._tTime / parent._ts : (parent.totalDuration() - parent._tTime) / -parent._ts)) { 1709 parent.totalTime(parent._tTime, true); 1710 } 1711 1712 parent = parent.parent; 1713 } 1714 1715 if (!this.parent && this._dp.autoRemoveChildren && (this._ts > 0 && _totalTime < this._tDur || this._ts < 0 && _totalTime > 0 || !this._tDur && !_totalTime)) { 1716 //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. 1717 _addToTimeline(this._dp, this, this._start - this._delay); 1718 } 1719 } 1720 1721 if (this._tTime !== _totalTime || !this._dur && !suppressEvents || this._initted && Math.abs(this._zTime) === _tinyNum || !_totalTime && !this._initted && (this.add || this._ptLookup)) { 1722 // 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) 1723 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 1724 //if (!this._lock) { // avoid endless recursion (not sure we need this yet or if it's worth the performance hit) 1725 // this._lock = 1; 1726 1727 _lazySafeRender(this, _totalTime, suppressEvents); // this._lock = 0; 1728 //} 1729 1730 } 1731 1732 return this; 1733 }; 1734 1735 _proto.time = function time(value, suppressEvents) { 1736 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! 1737 }; 1738 1739 _proto.totalProgress = function totalProgress(value, suppressEvents) { 1740 return arguments.length ? this.totalTime(this.totalDuration() * value, suppressEvents) : this.totalDuration() ? Math.min(1, this._tTime / this._tDur) : this.rawTime() > 0 ? 1 : 0; 1741 }; 1742 1743 _proto.progress = function progress(value, suppressEvents) { 1744 return arguments.length ? this.totalTime(this.duration() * (this._yoyo && !(this.iteration() & 1) ? 1 - value : value) + _elapsedCycleDuration(this), suppressEvents) : this.duration() ? Math.min(1, this._time / this._dur) : this.rawTime() > 0 ? 1 : 0; 1745 }; 1746 1747 _proto.iteration = function iteration(value, suppressEvents) { 1748 var cycleDuration = this.duration() + this._rDelay; 1749 1750 return arguments.length ? this.totalTime(this._time + (value - 1) * cycleDuration, suppressEvents) : this._repeat ? _animationCycle(this._tTime, cycleDuration) + 1 : 1; 1751 } // potential future addition: 1752 // isPlayingBackwards() { 1753 // let animation = this, 1754 // orientation = 1; // 1 = forward, -1 = backward 1755 // while (animation) { 1756 // orientation *= animation.reversed() || (animation.repeat() && !(animation.iteration() & 1)) ? -1 : 1; 1757 // animation = animation.parent; 1758 // } 1759 // return orientation < 0; 1760 // } 1761 ; 1762 1763 _proto.timeScale = function timeScale(value, suppressEvents) { 1764 if (!arguments.length) { 1765 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. 1766 } 1767 1768 if (this._rts === value) { 1769 return this; 1770 } 1771 1772 var 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. 1773 // 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. 1774 //(+value < 0 && this._rts >= 0) && _callback(this, "onReverse", true); 1775 // 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. 1776 1777 this._rts = +value || 0; 1778 this._ts = this._ps || value === -_tinyNum ? 0 : this._rts; // _ts is the functional timeScale which would be 0 if the animation is paused. 1779 1780 this.totalTime(_clamp(-Math.abs(this._delay), this._tDur, tTime), suppressEvents !== false); 1781 1782 _setEnd(this); // if parent.smoothChildTiming was false, the end time didn't get updated in the _alignPlayhead() method, so do it here. 1783 1784 1785 return _recacheAncestors(this); 1786 }; 1787 1788 _proto.paused = function paused(value) { 1789 if (!arguments.length) { 1790 return this._ps; 1791 } 1792 1793 if (this._ps !== value) { 1794 this._ps = value; 1795 1796 if (value) { 1797 this._pTime = this._tTime || Math.max(-this._delay, this.rawTime()); // if the pause occurs during the delay phase, make sure that's factored in when resuming. 1798 1799 this._ts = this._act = 0; // _ts is the functional timeScale, so a paused tween would effectively have a timeScale of 0. We record the "real" timeScale as _rts (recorded time scale) 1800 } else { 1801 _wake(); 1802 1803 this._ts = this._rts; //only defer to _pTime (pauseTime) if tTime is zero. Remember, someone could pause() an animation, then scrub the playhead and resume(). If the parent doesn't have smoothChildTiming, we render at the rawTime() because the startTime won't get updated. 1804 1805 this.totalTime(this.parent && !this.parent.smoothChildTiming ? this.rawTime() : this._tTime || this._pTime, this.progress() === 1 && Math.abs(this._zTime) !== _tinyNum && (this._tTime -= _tinyNum)); // edge case: animation.progress(1).pause().play() wouldn't render again because the playhead is already at the end, but the call to totalTime() below will add it back to its parent...and not remove it again (since removing only happens upon rendering at a new time). Offsetting the _tTime slightly is done simply to cause the final render in totalTime() that'll pop it off its timeline (if autoRemoveChildren is true, of course). Check to make sure _zTime isn't -_tinyNum to avoid an edge case where the playhead is pushed to the end but INSIDE a tween/callback, the timeline itself is paused thus halting rendering and leaving a few unrendered. When resuming, it wouldn't render those otherwise. 1806 } 1807 } 1808 1809 return this; 1810 }; 1811 1812 _proto.startTime = function startTime(value) { 1813 if (arguments.length) { 1814 this._start = value; 1815 var parent = this.parent || this._dp; 1816 parent && (parent._sort || !this.parent) && _addToTimeline(parent, this, value - this._delay); 1817 return this; 1818 } 1819 1820 return this._start; 1821 }; 1822 1823 _proto.endTime = function endTime(includeRepeats) { 1824 return this._start + (_isNotFalse(includeRepeats) ? this.totalDuration() : this.duration()) / Math.abs(this._ts || 1); 1825 }; 1826 1827 _proto.rawTime = function rawTime(wrapRepeats) { 1828 var parent = this.parent || this._dp; // _dp = detached parent 1829 1830 return !parent ? this._tTime : wrapRepeats && (!this._ts || this._repeat && this._time && this.totalProgress() < 1) ? this._tTime % (this._dur + this._rDelay) : !this._ts ? this._tTime : _parentToChildTotalTime(parent.rawTime(wrapRepeats), this); 1831 }; 1832 1833 _proto.revert = function revert(config) { 1834 if (config === void 0) { 1835 config = _revertConfig; 1836 } 1837 1838 var prevIsReverting = _reverting; 1839 _reverting = config; 1840 1841 if (this._initted || this._startAt) { 1842 this.timeline && this.timeline.revert(config); 1843 this.totalTime(-0.01, config.suppressEvents); 1844 } 1845 1846 this.data !== "nested" && config.kill !== false && this.kill(); 1847 _reverting = prevIsReverting; 1848 return this; 1849 }; 1850 1851 _proto.globalTime = function globalTime(rawTime) { 1852 var animation = this, 1853 time = arguments.length ? rawTime : animation.rawTime(); 1854 1855 while (animation) { 1856 time = animation._start + time / (Math.abs(animation._ts) || 1
vendor: 2,328 bytes, lines 1856-1930
1856); 1857 animation = animation._dp; 1858 } 1859 1860 return !this.parent && this._sat ? this._sat.globalTime(rawTime) : time; // the _startAt tweens for .fromTo() and .from() that have immediateRender should always be FIRST in the timeline (important for context.revert()). "_sat" stands for _startAtTween, referring to the parent tween that created the _startAt. We must discern if that tween had immediateRender so that we can know whether or not to prioritize it in revert(). 1861 }; 1862 1863 _proto.repeat = function repeat(value) { 1864 if (arguments.length) { 1865 this._repeat = value === Infinity ? -2 : value; 1866 return _onUpdateTotalDuration(this); 1867 } 1868 1869 return this._repeat === -2 ? Infinity : this._repeat; 1870 }; 1871 1872 _proto.repeatDelay = function repeatDelay(value) { 1873 if (arguments.length) { 1874 var time = this._time; 1875 this._rDelay = value; 1876 1877 _onUpdateTotalDuration(this); 1878 1879 return time ? this.time(time) : this; 1880 } 1881 1882 return this._rDelay; 1883 }; 1884 1885 _proto.yoyo = function yoyo(value) { 1886 if (arguments.length) { 1887 this._yoyo = value; 1888 return this; 1889 } 1890 1891 return this._yoyo; 1892 }; 1893 1894 _proto.seek = function seek(position, suppressEvents) { 1895 return this.totalTime(_parsePosition(this, position), _isNotFalse(suppressEvents)); 1896 }; 1897 1898 _proto.restart = function restart(includeDelay, suppressEvents) { 1899 return this.play().totalTime(includeDelay ? -this._delay : 0, _isNotFalse(suppressEvents)); 1900 }; 1901 1902 _proto.play = function play(from, suppressEvents) { 1903 from != null && this.seek(from, suppressEvents); 1904 return this.reversed(false).paused(false); 1905 }; 1906 1907 _proto.reverse = function reverse(from, suppressEvents) { 1908 from != null && this.seek(from || this.totalDuration(), suppressEvents); 1909 return this.reversed(true).paused(false); 1910 }; 1911 1912 _proto.pause = function pause(atTime, suppressEvents) { 1913 atTime != null && this.seek(atTime, suppressEvents); 1914 return this.paused(true); 1915 }; 1916 1917 _proto.resume = function resume() { 1918 return this.paused(false); 1919 }; 1920 1921 _proto.reversed = function reversed(value) { 1922 if (arguments.length) { 1923 !!value !== this.reversed() && this.timeScale(-this._rts || (value ? -_tinyNum : 0)); // in case timeScale is zero, reversing would have no effect so we use _tinyNum. 1924 1925 return this; 1926 } 1927 1928 return this._rts < 0; 1929 }; 1930
vendor: 12,479 bytes, lines 1931-2233
1931 _proto.invalidate = function invalidate() { 1932 this._initted = this._act = 0; 1933 this._zTime = -_tinyNum; 1934 return this; 1935 }; 1936 1937 _proto.isActive = function isActive() { 1938 var parent = this.parent || this._dp, 1939 start = this._start, 1940 rawTime; 1941 return !!(!parent || this._ts && this._initted && parent.isActive() && (rawTime = parent.rawTime(true)) >= start && rawTime < this.endTime(true) - _tinyNum); 1942 }; 1943 1944 _proto.eventCallback = function eventCallback(type, callback, params) { 1945 var vars = this.vars; 1946 1947 if (arguments.length > 1) { 1948 if (!callback) { 1949 delete vars[type]; 1950 } else { 1951 vars[type] = callback; 1952 params && (vars[type + "Params"] = params); 1953 type === "onUpdate" && (this._onUpdate = callback); 1954 } 1955 1956 return this; 1957 } 1958 1959 return vars[type]; 1960 }; 1961 1962 _proto.then = function then(onFulfilled) { 1963 var self = this; 1964 return new Promise(function (resolve) { 1965 var f = _isFunction(onFulfilled) ? onFulfilled : _passThrough, 1966 _resolve = function _resolve() { 1967 var _then = self.then; 1968 self.then = null; // temporarily null the then() method to avoid an infinite loop (see https://github.com/greensock/GSAP/issues/322) 1969 1970 _isFunction(f) && (f = f(self)) && (f.then || f === self) && (self.then = _then); 1971 resolve(f); 1972 self.then = _then; 1973 }; 1974 1975 if (self._initted && self.totalProgress() === 1 && self._ts >= 0 || !self._tTime && self._ts < 0) { 1976 _resolve(); 1977 } else { 1978 self._prom = _resolve; 1979 } 1980 }); 1981 }; 1982 1983 _proto.kill = function kill() { 1984 _interrupt(this); 1985 }; 1986 1987 return Animation; 1988}(); 1989 1990_setDefaults(Animation.prototype, { 1991 _time: 0, 1992 _start: 0, 1993 _end: 0, 1994 _tTime: 0, 1995 _tDur: 0, 1996 _dirty: 0, 1997 _repeat: 0, 1998 _yoyo: false, 1999 parent: null, 2000 _initted: false, 2001 _rDelay: 0, 2002 _ts: 1, 2003 _dp: 0, 2004 ratio: 0, 2005 _zTime: -_tinyNum, 2006 _prom: 0, 2007 _ps: false, 2008 _rts: 1 2009}); 2010/* 2011 * ------------------------------------------------- 2012 * TIMELINE 2013 * ------------------------------------------------- 2014 */ 2015 2016 2017export var Timeline = /*#__PURE__*/function (_Animation) { 2018 _inheritsLoose(Timeline, _Animation); 2019 2020 function Timeline(vars, position) { 2021 var _this; 2022 2023 if (vars === void 0) { 2024 vars = {}; 2025 } 2026 2027 _this = _Animation.call(this, vars) || this; 2028 _this.labels = {}; 2029 _this.smoothChildTiming = !!vars.smoothChildTiming; 2030 _this.autoRemoveChildren = !!vars.autoRemoveChildren; 2031 _this._sort = _isNotFalse(vars.sortChildren); 2032 _globalTimeline && _addToTimeline(vars.parent || _globalTimeline, _assertThisInitialized(_this), position); 2033 vars.reversed && _this.reverse(); 2034 vars.paused && _this.paused(true); 2035 vars.scrollTrigger && _scrollTrigger(_assertThisInitialized(_this), vars.scrollTrigger); 2036 return _this; 2037 } 2038 2039 var _proto2 = Timeline.prototype; 2040 2041 _proto2.to = function to(targets, vars, position) { 2042 _createTweenType(0, arguments, this); 2043 2044 return this; 2045 }; 2046 2047 _proto2.from = function from(targets, vars, position) { 2048 _createTweenType(1, arguments, this); 2049 2050 return this; 2051 }; 2052 2053 _proto2.fromTo = function fromTo(targets, fromVars, toVars, position) { 2054 _createTweenType(2, arguments, this); 2055 2056 return this; 2057 }; 2058 2059 _proto2.set = function set(targets, vars, position) { 2060 vars.duration = 0; 2061 vars.parent = this; 2062 _inheritDefaults(vars).repeatDelay || (vars.repeat = 0); 2063 vars.immediateRender = !!vars.immediateRender; 2064 new Tween(targets, vars, _parsePosition(this, position), 1); 2065 return this; 2066 }; 2067 2068 _proto2.call = function call(callback, params, position) { 2069 return _addToTimeline(this, Tween.delayedCall(0, callback, params), position); 2070 } //ONLY for backward compatibility! Maybe delete? 2071 ; 2072 2073 _proto2.staggerTo = function staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) { 2074 vars.duration = duration; 2075 vars.stagger = vars.stagger || stagger; 2076 vars.onComplete = onCompleteAll; 2077 vars.onCompleteParams = onCompleteAllParams; 2078 vars.parent = this; 2079 new Tween(targets, vars, _parsePosition(this, position)); 2080 return this; 2081 }; 2082 2083 _proto2.staggerFrom = function staggerFrom(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) { 2084 vars.runBackwards = 1; 2085 _inheritDefaults(vars).immediateRender = _isNotFalse(vars.immediateRender); 2086 return this.staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams); 2087 }; 2088 2089 _proto2.staggerFromTo = function staggerFromTo(targets, duration, fromVars, toVars, stagger, position, onCompleteAll, onCompleteAllParams) { 2090 toVars.startAt = fromVars; 2091 _inheritDefaults(toVars).immediateRender = _isNotFalse(toVars.immediateRender); 2092 return this.staggerTo(targets, duration, toVars, stagger, position, onCompleteAll, onCompleteAllParams); 2093 }; 2094 2095 _proto2.render = function render(totalTime, suppressEvents, force) { 2096 var prevTime = this._time, 2097 tDur = this._dirty ? this.totalDuration() : this._tDur, 2098 dur = this._dur, 2099 tTime = totalTime <= 0 ? 0 : _roundPrecise(totalTime), 2100 // if a paused timeline is resumed (or its _start is updated for another reason...which rounds it), that could result in the playhead shifting a **tiny** amount and a zero-duration child at that spot may get rendered at a different ratio, like its totalTime in render() may be 1e-17 instead of 0, for example. 2101 crossingStart = this._zTime < 0 !== totalTime < 0 && (this._initted || !dur), 2102 time, 2103 child, 2104 next, 2105 iteration, 2106 cycleDuration, 2107 prevPaused, 2108 pauseTween, 2109 timeScale, 2110 prevStart, 2111 prevIteration, 2112 yoyo, 2113 isYoyo; 2114 this !== _globalTimeline && tTime > tDur && totalTime >= 0 && (tTime = tDur); 2115 2116 if (tTime !== this._tTime || force || crossingStart) { 2117 if (prevTime !== this._time && dur) { 2118 //if totalDuration() finds a child with a negative startTime and smoothChildTiming is true, things get shifted around internally so we need to adjust the time accordingly. For example, if a tween starts at -30 we must shift EVERYTHING forward 30 seconds and move this timeline's startTime backward by 30 seconds so that things align with the playhead (no jump). 2119 tTime += this._time - prevTime; 2120 totalTime += this._time - prevTime; 2121 } 2122 2123 time = tTime; 2124 prevStart = this._start; 2125 timeScale = this._ts; 2126 prevPaused = !timeScale; 2127 2128 if (crossingStart) { 2129 dur || (prevTime = this._zTime); //when the playhead arrives at EXACTLY time 0 (right on top) of a zero-duration timeline, we need to discern if events are suppressed so that when the playhead moves again (next time), it'll trigger the callback. If events are NOT suppressed, obviously the callback would be triggered in this render. Basically, the callback should fire either when the playhead ARRIVES or LEAVES this exact spot, not both. Imagine doing a timeline.seek(0) and there's a callback that sits at 0. Since events are suppressed on that seek() by default, nothing will fire, but when the playhead moves off of that position, the callback should fire. This behavior is what people intuitively expect. 2130 2131 (totalTime || !suppressEvents) && (this._zTime = totalTime); 2132 } 2133 2134 if (this._repeat) { 2135 //adjust the time for repeats and yoyos 2136 yoyo = this._yoyo; 2137 cycleDuration = dur + this._rDelay; 2138 2139 if (this._repeat < -1 && totalTime < 0) { 2140 return this.totalTime(cycleDuration * 100 + totalTime, suppressEvents, force); 2141 } 2142 2143 time = _roundPrecise(tTime % cycleDuration); //round to avoid floating point errors. (4 % 0.8 should be 0 but some browsers report it as 0.79999999!) 2144 2145 if (tTime === tDur) { 2146 // the tDur === tTime is for edge cases where there's a lengthy decimal on the duration and it may reach the very end but the time is rendered as not-quite-there (remember, tDur is rounded to 4 decimals whereas dur isn't) 2147 iteration = this._repeat; 2148 time = dur; 2149 } else { 2150 iteration = ~~(tTime / cycleDuration); 2151 2152 if (iteration && iteration === tTime / cycleDuration) { 2153 time = dur; 2154 iteration--; 2155 } 2156 2157 time > dur && (time = dur); 2158 } 2159 2160 prevIteration = _animationCycle(this._tTime, cycleDuration); 2161 !prevTime && this._tTime && prevIteration !== iteration && this._tTime - prevIteration * cycleDuration - this._dur <= 0 && (prevIteration = iteration); // edge case - if someone does addPause() at the very beginning of a repeating timeline, that pause is technically at the same spot as the end which causes this._time to get set to 0 when the totalTime would normally place the playhead at the end. See https://gsap.com/forums/topic/23823-closing-nav-animation-not-working-on-ie-and-iphone-6-maybe-other-older-browser/?tab=comments#comment-113005 also, this._tTime - prevIteration * cycleDuration - this._dur <= 0 just checks to make sure it wasn't previously in the "repeatDelay" portion 2162 2163 if (yoyo && iteration & 1) { 2164 time = dur - time; 2165 isYoyo = 1; 2166 } 2167 /* 2168 make sure children at the end/beginning of the timeline are rendered properly. If, for example, 2169 a 3-second long timeline rendered at 2.9 seconds previously, and now renders at 3.2 seconds (which 2170 would get translated to 2.8 seconds if the timeline yoyos or 0.2 seconds if it just repeats), there 2171 could be a callback or a short tween that's at 2.95 or 3 seconds in which wouldn't render. So 2172 we need to push the timeline to the end (and/or beginning depending on its yoyo value). Also we must 2173 ensure that zero-duration tweens at the very beginning or end of the Timeline work. 2174 */ 2175 2176 2177 if (iteration !== prevIteration && !this._lock) { 2178 var rewinding = yoyo && prevIteration & 1, 2179 doesWrap = rewinding === (yoyo && iteration & 1); 2180 iteration < prevIteration && (rewinding = !rewinding); 2181 prevTime = rewinding ? 0 : tTime % dur ? dur : tTime; // if the playhead is landing exactly at the end of an iteration, use that totalTime rather than only the duration, otherwise it'll skip the 2nd render since it's effectively at the same time. 2182 2183 this._lock = 1; 2184 this.render(prevTime || (isYoyo ? 0 : _roundPrecise(iteration * cycleDuration)), suppressEvents, !dur)._lock = 0; 2185 this._tTime = tTime; // if a user gets the iteration() inside the onRepeat, for example, it should be accurate. 2186 2187 !suppressEvents && this.parent && _callback(this, "onRepeat"); 2188 this.vars.repeatRefresh && !isYoyo && (this.invalidate()._lock = 1); 2189 2190 if (prevTime && prevTime !== this._time || prevPaused !== !this._ts || this.vars.onRepeat && !this.parent && !this._act) { 2191 // if prevTime is 0 and we render at the very end, _time will be the end, thus won't match. So in this edge case, prevTime won't match _time but that's okay. If it gets killed in the onRepeat, eject as well. 2192 return this; 2193 } 2194 2195 dur = this._dur; // in case the duration changed in the onRepeat 2196 2197 tDur = this._tDur; 2198 2199 if (doesWrap) { 2200 this._lock = 2; 2201 prevTime = rewinding ? dur : -0.0001; 2202 this.render(prevTime, true); 2203 this.vars.repeatRefresh && !isYoyo && this.invalidate(); 2204 } 2205 2206 this._lock = 0; 2207 2208 if (!this._ts && !prevPaused) { 2209 return this; 2210 } //in order for yoyoEase to work properly when there's a stagger, we must swap out the ease in each sub-tween. 2211 2212 2213 _propagateYoyoEase(this, isYoyo); 2214 } 2215 } 2216 2217 if (this._hasPause && !this._forcing && this._lock < 2) { 2218 pauseTween = _findNextPauseTween(this, _roundPrecise(prevTime), _roundPrecise(time)); 2219 2220 if (pauseTween) { 2221 tTime -= time - (time = pauseTween._start); 2222 } 2223 } 2224 2225 this._tTime = tTime; 2226 this._time = time; 2227 this._act = !timeScale; //as long as it's not paused, force it to be active so that if the user renders independent of the parent timeline, it'll be forced to re-render on the next tick. 2228 2229 if (!this._initted) { 2230 this._onUpdate = this.vars.onUpdate; 2231 this._initted = 1; 2232 this._zTime = totalTime; 2233 prevTime = 0; // upon init, the playhead should always go forward;
vendor: 9,900 bytes, lines 2233-2489
2233 someone could invalidate() a completed timeline and then if they restart(), that would make child tweens render in reverse order which could lock in the wrong starting values if they build on each other, like tl.to(obj, {x: 100}).to(obj, {x: 0}). 2234 } 2235 2236 if (!prevTime && time && !suppressEvents && !iteration) { 2237 _callback(this, "onStart"); 2238 2239 if (this._tTime !== tTime) { 2240 // in case the onStart triggered a render at a different spot, eject. Like if someone did animation.pause(0.5) or something inside the onStart. 2241 return this; 2242 } 2243 } 2244 2245 if (time >= prevTime && totalTime >= 0) { 2246 child = this._first; 2247 2248 while (child) { 2249 next = child._next; 2250 2251 if ((child._act || time >= child._start) && child._ts && pauseTween !== child) { 2252 if (child.parent !== this) { 2253 // an extreme edge case - the child's render could do something like kill() the "next" one in the linked list, or reparent it. In that case we must re-initiate the whole render to be safe. 2254 return this.render(totalTime, suppressEvents, force); 2255 } 2256 2257 child.render(child._ts > 0 ? (time - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (time - child._start) * child._ts, suppressEvents, force); 2258 2259 if (time !== this._time || !this._ts && !prevPaused) { 2260 //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete 2261 pauseTween = 0; 2262 next && (tTime += this._zTime = -_tinyNum); // it didn't finish rendering, so flag zTime as negative so that so that the next time render() is called it'll be forced (to render any remaining children) 2263 2264 break; 2265 } 2266 } 2267 2268 child = next; 2269 } 2270 } else { 2271 child = this._last; 2272 var adjustedTime = totalTime < 0 ? totalTime : time; //when the playhead goes backward beyond the start of this timeline, we must pass that information down to the child animations so that zero-duration tweens know whether to render their starting or ending values. 2273 2274 while (child) { 2275 next = child._prev; 2276 2277 if ((child._act || adjustedTime <= child._end) && child._ts && pauseTween !== child) { 2278 if (child.parent !== this) { 2279 // an extreme edge case - the child's render could do something like kill() the "next" one in the linked list, or reparent it. In that case we must re-initiate the whole render to be safe. 2280 return this.render(totalTime, suppressEvents, force); 2281 } 2282 2283 child.render(child._ts > 0 ? (adjustedTime - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (adjustedTime - child._start) * child._ts, suppressEvents, force || _reverting && (child._initted || child._startAt)); // if reverting, we should always force renders of initted tweens (but remember that .fromTo() or .from() may have a _startAt but not _initted yet). If, for example, a .fromTo() tween with a stagger (which creates an internal timeline) gets reverted BEFORE some of its child tweens render for the first time, it may not properly trigger them to revert. 2284 2285 if (time !== this._time || !this._ts && !prevPaused) { 2286 //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete 2287 pauseTween = 0; 2288 next && (tTime += this._zTime = adjustedTime ? -_tinyNum : _tinyNum); // it didn't finish rendering, so adjust zTime so that so that the next time render() is called it'll be forced (to render any remaining children) 2289 2290 break; 2291 } 2292 } 2293 2294 child = next; 2295 } 2296 } 2297 2298 if (pauseTween && !suppressEvents) { 2299 this.pause(); 2300 pauseTween.render(time >= prevTime ? 0 : -_tinyNum)._zTime = time >= prevTime ? 1 : -1; 2301 2302 if (this._ts) { 2303 //the callback resumed playback! So since we may have held back the playhead due to where the pause is positioned, go ahead and jump to where it's SUPPOSED to be (if no pause happened). 2304 this._start = prevStart; //if the pause was at an earlier time and the user resumed in the callback, it could reposition the timeline (changing its startTime), throwing things off slightly, so we make sure the _start doesn't shift. 2305 2306 _setEnd(this); 2307 2308 return this.render(totalTime, suppressEvents, force); 2309 } 2310 } 2311 2312 this._onUpdate && !suppressEvents && _callback(this, "onUpdate", true); 2313 if (tTime === tDur && this._tTime >= this.totalDuration() || !tTime && prevTime) if (prevStart === this._start || Math.abs(timeScale) !== Math.abs(this._ts)) if (!this._lock) { 2314 // remember, a child's callback may alter this timeline's playhead or timeScale which is why we need to add some of these checks. 2315 (totalTime || !dur) && (tTime === tDur && this._ts > 0 || !tTime && this._ts < 0) && _removeFromParent(this, 1); // don't remove if the timeline is reversed and the playhead isn't at 0, otherwise tl.progress(1).reverse() won't work. Only remove if the playhead is at the end and timeScale is positive, or if the playhead is at 0 and the timeScale is negative. 2316 2317 if (!suppressEvents && !(totalTime < 0 && !prevTime) && (tTime || prevTime || !tDur)) { 2318 _callback(this, tTime === tDur && totalTime >= 0 ? "onComplete" : "onReverseComplete", true); 2319 2320 this._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom(); 2321 } 2322 } 2323 } 2324 2325 return this; 2326 }; 2327 2328 _proto2.add = function add(child, position) { 2329 var _this2 = this; 2330 2331 _isNumber(position) || (position = _parsePosition(this, position, child)); 2332 2333 if (!(child instanceof Animation)) { 2334 if (_isArray(child)) { 2335 child.forEach(function (obj) { 2336 return _this2.add(obj, position); 2337 }); 2338 return this; 2339 } 2340 2341 if (_isString(child)) { 2342 return this.addLabel(child, position); 2343 } 2344 2345 if (_isFunction(child)) { 2346 child = Tween.delayedCall(0, child); 2347 } else { 2348 return this; 2349 } 2350 } 2351 2352 return this !== child ? _addToTimeline(this, child, position) : this; //don't allow a timeline to be added to itself as a child! 2353 }; 2354 2355 _proto2.getChildren = function getChildren(nested, tweens, timelines, ignoreBeforeTime) { 2356 if (nested === void 0) { 2357 nested = true; 2358 } 2359 2360 if (tweens === void 0) { 2361 tweens = true; 2362 } 2363 2364 if (timelines === void 0) { 2365 timelines = true; 2366 } 2367 2368 if (ignoreBeforeTime === void 0) { 2369 ignoreBeforeTime = -_bigNum; 2370 } 2371 2372 var a = [], 2373 child = this._first; 2374 2375 while (child) { 2376 if (child._start >= ignoreBeforeTime) { 2377 if (child instanceof Tween) { 2378 tweens && a.push(child); 2379 } else { 2380 timelines && a.push(child); 2381 nested && a.push.apply(a, child.getChildren(true, tweens, timelines)); 2382 } 2383 } 2384 2385 child = child._next; 2386 } 2387 2388 return a; 2389 }; 2390 2391 _proto2.getById = function getById(id) { 2392 var animations = this.getChildren(1, 1, 1), 2393 i = animations.length; 2394 2395 while (i--) { 2396 if (animations[i].vars.id === id) { 2397 return animations[i]; 2398 } 2399 } 2400 }; 2401 2402 _proto2.remove = function remove(child) { 2403 if (_isString(child)) { 2404 return this.removeLabel(child); 2405 } 2406 2407 if (_isFunction(child)) { 2408 return this.killTweensOf(child); 2409 } 2410 2411 _removeLinkedListItem(this, child); 2412 2413 if (child === this._recent) { 2414 this._recent = this._last; 2415 } 2416 2417 return _uncache(this); 2418 }; 2419 2420 _proto2.totalTime = function totalTime(_totalTime2, suppressEvents) { 2421 if (!arguments.length) { 2422 return this._tTime; 2423 } 2424 2425 this._forcing = 1; 2426 2427 if (!this._dp && this._ts) { 2428 //special case for the global timeline (or any other that has no parent or detached parent). 2429 this._start = _roundPrecise(_ticker.time - (this._ts > 0 ? _totalTime2 / this._ts : (this.totalDuration() - _totalTime2) / -this._ts)); 2430 } 2431 2432 _Animation.prototype.totalTime.call(this, _totalTime2, suppressEvents); 2433 2434 this._forcing = 0; 2435 return this; 2436 }; 2437 2438 _proto2.addLabel = function addLabel(label, position) { 2439 this.labels[label] = _parsePosition(this, position); 2440 return this; 2441 }; 2442 2443 _proto2.removeLabel = function removeLabel(label) { 2444 delete this.labels[label]; 2445 return this; 2446 }; 2447 2448 _proto2.addPause = function addPause(position, callback, params) { 2449 var t = Tween.delayedCall(0, callback || _emptyFunc, params); 2450 t.data = "isPause"; 2451 this._hasPause = 1; 2452 return _addToTimeline(this, t, _parsePosition(this, position)); 2453 }; 2454 2455 _proto2.removePause = function removePause(position) { 2456 var child = this._first; 2457 position = _parsePosition(this, position); 2458 2459 while (child) { 2460 if (child._start === position && child.data === "isPause") { 2461 _removeFromParent(child); 2462 } 2463 2464 child = child._next; 2465 } 2466 }; 2467 2468 _proto2.killTweensOf = function killTweensOf(targets, props, onlyActive) { 2469 var tweens = this.getTweensOf(targets, onlyActive), 2470 i = tweens.length; 2471 2472 while (i--) { 2473 _overwritingTween !== tweens[i] && tweens[i].kill(targets, props); 2474 } 2475 2476 return this; 2477 }; 2478 2479 _proto2.getTweensOf = function getTweensOf(targets, onlyActive) { 2480 var a = [], 2481 parsedTargets = toArray(targets), 2482 child = this._first, 2483 isGlobalTime = _isNumber(onlyActive), 2484 // a number is interpreted as a global time. If the animation spans 2485 children; 2486 2487 while (child) { 2488 if (child instanceof Tween) { 2489 if (_arrayContainsAny(child._targets, parsedTargets) && (isGlobalTime ? (!_overwritingTween || child._initted && child._ts) && child.globalTime(0) <= onlyActive && child.globalTime(child.totalDuration()) > onlyActive : !onlyActive || child.isActive())) {
vendor: 3,291 bytes, lines 2490-2603
2490 // note: if this is for overwriting, it should only be for tweens that aren't paused and are initted. 2491 a.push(child); 2492 } 2493 } else if ((children = child.getTweensOf(parsedTargets, onlyActive)).length) { 2494 a.push.apply(a, children); 2495 } 2496 2497 child = child._next; 2498 } 2499 2500 return a; 2501 } // potential future feature - targets() on timelines 2502 // targets() { 2503 // let result = []; 2504 // this.getChildren(true, true, false).forEach(t => result.push(...t.targets())); 2505 // return result.filter((v, i) => result.indexOf(v) === i); 2506 // } 2507 ; 2508 2509 _proto2.tweenTo = function tweenTo(position, vars) { 2510 vars = vars || {}; 2511 2512 var tl = this, 2513 endTime = _parsePosition(tl, position), 2514 _vars = vars, 2515 startAt = _vars.startAt, 2516 _onStart = _vars.onStart, 2517 onStartParams = _vars.onStartParams, 2518 immediateRender = _vars.immediateRender, 2519 initted, 2520 tween = Tween.to(tl, _setDefaults({ 2521 ease: vars.ease || "none", 2522 lazy: false, 2523 immediateRender: false, 2524 time: endTime, 2525 overwrite: "auto", 2526 duration: vars.duration || Math.abs((endTime - (startAt && "time" in startAt ? startAt.time : tl._time)) / tl.timeScale()) || _tinyNum, 2527 onStart: function onStart() { 2528 tl.pause(); 2529 2530 if (!initted) { 2531 var duration = vars.duration || Math.abs((endTime - (startAt && "time" in startAt ? startAt.time : tl._time)) / tl.timeScale()); 2532 tween._dur !== duration && _setDuration(tween, duration, 0, 1).render(tween._time, true, true); 2533 initted = 1; 2534 } 2535 2536 _onStart && _onStart.apply(tween, onStartParams || []); //in case the user had an onStart in the vars - we don't want to overwrite it. 2537 } 2538 }, vars)); 2539 2540 return immediateRender ? tween.render(0) : tween; 2541 }; 2542 2543 _proto2.tweenFromTo = function tweenFromTo(fromPosition, toPosition, vars) { 2544 return this.tweenTo(toPosition, _setDefaults({ 2545 startAt: { 2546 time: _parsePosition(this, fromPosition) 2547 } 2548 }, vars)); 2549 }; 2550 2551 _proto2.recent = function recent() { 2552 return this._recent; 2553 }; 2554 2555 _proto2.nextLabel = function nextLabel(afterTime) { 2556 if (afterTime === void 0) { 2557 afterTime = this._time; 2558 } 2559 2560 return _getLabelInDirection(this, _parsePosition(this, afterTime)); 2561 }; 2562 2563 _proto2.previousLabel = function previousLabel(beforeTime) { 2564 if (beforeTime === void 0) { 2565 beforeTime = this._time; 2566 } 2567 2568 return _getLabelInDirection(this, _parsePosition(this, beforeTime), 1); 2569 }; 2570 2571 _proto2.currentLabel = function currentLabel(value) { 2572 return arguments.length ? this.seek(value, true) : this.previousLabel(this._time + _tinyNum); 2573 }; 2574 2575 _proto2.shiftChildren = function shiftChildren(amount, adjustLabels, ignoreBeforeTime) { 2576 if (ignoreBeforeTime === void 0) { 2577 ignoreBeforeTime = 0; 2578 } 2579 2580 var child = this._first, 2581 labels = this.labels, 2582 p; 2583 2584 while (child) { 2585 if (child._start >= ignoreBeforeTime) { 2586 child._start += amount; 2587 child._end += amount; 2588 } 2589 2590 child = child._next; 2591 } 2592 2593 if (adjustLabels) { 2594 for (p in labels) { 2595 if (labels[p] >= ignoreBeforeTime) { 2596 labels[p] += amount; 2597 } 2598 } 2599 } 2600 2601 return _uncache(this); 2602 }; 2603
vendor: 2,164 bytes, lines 2604-2672
2604 _proto2.invalidate = function invalidate(soft) { 2605 var child = this._first; 2606 this._lock = 0; 2607 2608 while (child) { 2609 child.invalidate(soft); 2610 child = child._next; 2611 } 2612 2613 return _Animation.prototype.invalidate.call(this, soft); 2614 }; 2615 2616 _proto2.clear = function clear(includeLabels) { 2617 if (includeLabels === void 0) { 2618 includeLabels = true; 2619 } 2620 2621 var child = this._first, 2622 next; 2623 2624 while (child) { 2625 next = child._next; 2626 this.remove(child); 2627 child = next; 2628 } 2629 2630 this._dp && (this._time = this._tTime = this._pTime = 0); 2631 includeLabels && (this.labels = {}); 2632 return _uncache(this); 2633 }; 2634 2635 _proto2.totalDuration = function totalDuration(value) { 2636 var max = 0, 2637 self = this, 2638 child = self._last, 2639 prevStart = _bigNum, 2640 prev, 2641 start, 2642 parent; 2643 2644 if (arguments.length) { 2645 return self.timeScale((self._repeat < 0 ? self.duration() : self.totalDuration()) / (self.reversed() ? -value : value)); 2646 } 2647 2648 if (self._dirty) { 2649 parent = self.parent; 2650 2651 while (child) { 2652 prev = child._prev; //record it here in case the tween changes position in the sequence... 2653 2654 child._dirty && child.totalDuration(); //could change the tween._startTime, so make sure the animation's cache is clean before analyzing it. 2655 2656 start = child._start; 2657 2658 if (start > prevStart && self._sort && child._ts && !self._lock) { 2659 //in case one of the tweens shifted out of order, it needs to be re-inserted into the correct position in the sequence 2660 self._lock = 1; //prevent endless recursive calls - there are methods that get triggered that check duration/totalDuration when we add(). 2661 2662 _addToTimeline(self, child, start - child._delay, 1)._lock = 0; 2663 } else { 2664 prevStart = start; 2665 } 2666 2667 if (start < 0 && child._ts) { 2668 //children aren't allowed to have negative startTimes unless smoothChildTiming is true, so adjust here if one is found. 2669 max -= start; 2670 2671 if (!parent && !self._dp || parent && parent.smoothChildTiming) { 2672 self._start += start / self._ts
vendor: 8,055 bytes, lines 2672-2884
2672; 2673 self._time -= start; 2674 self._tTime -= start; 2675 } 2676 2677 self.shiftChildren(-start, false, -1e999); 2678 prevStart = 0; 2679 } 2680 2681 child._end > max && child._ts && (max = child._end); 2682 child = prev; 2683 } 2684 2685 _setDuration(self, self === _globalTimeline && self._time > max ? self._time : max, 1, 1); 2686 2687 self._dirty = 0; 2688 } 2689 2690 return self._tDur; 2691 }; 2692 2693 Timeline.updateRoot = function updateRoot(time) { 2694 if (_globalTimeline._ts) { 2695 _lazySafeRender(_globalTimeline, _parentToChildTotalTime(time, _globalTimeline)); 2696 2697 _lastRenderedFrame = _ticker.frame; 2698 } 2699 2700 if (_ticker.frame >= _nextGCFrame) { 2701 _nextGCFrame += _config.autoSleep || 120; 2702 var child = _globalTimeline._first; 2703 if (!child || !child._ts) if (_config.autoSleep && _ticker._listeners.length < 2) { 2704 while (child && !child._ts) { 2705 child = child._next; 2706 } 2707 2708 child || _ticker.sleep(); 2709 } 2710 } 2711 }; 2712 2713 return Timeline; 2714}(Animation); 2715 2716_setDefaults(Timeline.prototype, { 2717 _lock: 0, 2718 _hasPause: 0, 2719 _forcing: 0 2720}); 2721 2722var _addComplexStringPropTween = function _addComplexStringPropTween(target, prop, start, end, setter, stringFilter, funcParam) { 2723 //note: we call _addComplexStringPropTween.call(tweenInstance...) to ensure that it's scoped properly. We may call it from within a plugin too, thus "this" would refer to the plugin. 2724 var pt = new PropTween(this._pt, target, prop, 0, 1, _renderComplexString, null, setter), 2725 index = 0, 2726 matchIndex = 0, 2727 result, 2728 startNums, 2729 color, 2730 endNum, 2731 chunk, 2732 startNum, 2733 hasRandom, 2734 a; 2735 pt.b = start; 2736 pt.e = end; 2737 start += ""; //ensure values are strings 2738 2739 end += ""; 2740 2741 if (hasRandom = ~end.indexOf("random(")) { 2742 end = _replaceRandom(end); 2743 } 2744 2745 if (stringFilter) { 2746 a = [start, end]; 2747 stringFilter(a, target, prop); //pass an array with the starting and ending values and let the filter do whatever it needs to the values. 2748 2749 start = a[0]; 2750 end = a[1]; 2751 } 2752 2753 startNums = start.match(_complexStringNumExp) || []; 2754 2755 while (result = _complexStringNumExp.exec(end)) { 2756 endNum = result[0]; 2757 chunk = end.substring(index, result.index); 2758 2759 if (color) { 2760 color = (color + 1) % 5; 2761 } else if (chunk.substr(-5) === "rgba(") { 2762 color = 1; 2763 } 2764 2765 if (endNum !== startNums[matchIndex++]) { 2766 startNum = parseFloat(startNums[matchIndex - 1]) || 0; //these nested PropTweens are handled in a special way - we'll never actually call a render or setter method on them. We'll just loop through them in the parent complex string PropTween's render method. 2767 2768 pt._pt = { 2769 _next: pt._pt, 2770 p: chunk || matchIndex === 1 ? chunk : ",", 2771 //note: SVG spec allows omission of comma/space when a negative sign is wedged between two numbers, like 2.5-5.3 instead of 2.5,-5.3 but when tweening, the negative value may switch to positive, so we insert the comma just in case. 2772 s: startNum, 2773 c: endNum.charAt(1) === "=" ? _parseRelative(startNum, endNum) - startNum : parseFloat(endNum) - startNum, 2774 m: color && color < 4 ? Math.round : 0 2775 }; 2776 index = _complexStringNumExp.lastIndex; 2777 } 2778 } 2779 2780 pt.c = index < end.length ? end.substring(index, end.length) : ""; //we use the "c" of the PropTween to store the final part of the string (after the last number) 2781 2782 pt.fp = funcParam; 2783 2784 if (_relExp.test(end) || hasRandom) { 2785 pt.e = 0; //if the end string contains relative values or dynamic random(...) values, delete the end it so that on the final render we don't actually set it to the string with += or -= characters (forces it to use the calculated value). 2786 } 2787 2788 this._pt = pt; //start the linked list with this new PropTween. Remember, we call _addComplexStringPropTween.call(tweenInstance...) to ensure that it's scoped properly. We may call it from within a plugin too, thus "this" would refer to the plugin. 2789 2790 return pt; 2791}, 2792 _addPropTween = function _addPropTween(target, prop, start, end, index, targets, modifier, stringFilter, funcParam, optional) { 2793 _isFunction(end) && (end = end(index || 0, target, targets)); 2794 var currentValue = target[prop], 2795 parsedStart = start !== "get" ? start : !_isFunction(currentValue) ? currentValue : funcParam ? target[prop.indexOf("set") || !_isFunction(target["get" + prop.substr(3)]) ? prop : "get" + prop.substr(3)](funcParam) : target[prop](), 2796 setter = !_isFunction(currentValue) ? _setterPlain : funcParam ? _setterFuncWithParam : _setterFunc, 2797 pt; 2798 2799 if (_isString(end)) { 2800 if (~end.indexOf("random(")) { 2801 end = _replaceRandom(end); 2802 } 2803 2804 if (end.charAt(1) === "=") { 2805 pt = _parseRelative(parsedStart, end) + (getUnit(parsedStart) || 0); 2806 2807 if (pt || pt === 0) { 2808 // to avoid isNaN, like if someone passes in a value like "!= whatever" 2809 end = pt; 2810 } 2811 } 2812 } 2813 2814 if (!optional || parsedStart !== end || _forceAllPropTweens) { 2815 if (!isNaN(parsedStart * end) && end !== "") { 2816 // fun fact: any number multiplied by "" is evaluated as the number 0! 2817 pt = new PropTween(this._pt, target, prop, +parsedStart || 0, end - (parsedStart || 0), typeof currentValue === "boolean" ? _renderBoolean : _renderPlain, 0, setter); 2818 funcParam && (pt.fp = funcParam); 2819 modifier && pt.modifier(modifier, this, target); 2820 return this._pt = pt; 2821 } 2822 2823 !currentValue && !(prop in target) && _missingPlugin(prop, end); 2824 return _addComplexStringPropTween.call(this, target, prop, parsedStart, end, setter, stringFilter || _config.stringFilter, funcParam); 2825 } 2826}, 2827 //creates a copy of the vars object and processes any function-based values (putting the resulting values directly into the copy) as well as strings with "random()" in them. It does NOT process relative values. 2828_processVars = function _processVars(vars, index, target, targets, tween) { 2829 _isFunction(vars) && (vars = _parseFuncOrString(vars, tween, index, target, targets)); 2830 2831 if (!_isObject(vars) || vars.style && vars.nodeType || _isArray(vars) || _isTypedArray(vars)) { 2832 return _isString(vars) ? _parseFuncOrString(vars, tween, index, target, targets) : vars; 2833 } 2834 2835 var copy = {}, 2836 p; 2837 2838 for (p in vars) { 2839 copy[p] = _parseFuncOrString(vars[p], tween, index, target, targets); 2840 } 2841 2842 return copy; 2843}, 2844 _checkPlugin = function _checkPlugin(property, vars, tween, index, target, targets) { 2845 var plugin, pt, ptLookup, i; 2846 2847 if (_plugins[property] && (plugin = new _plugins[property]()).init(target, plugin.rawVars ? vars[property] : _processVars(vars[property], index, target, targets, tween), tween, index, targets) !== false) { 2848 tween._pt = pt = new PropTween(tween._pt, target, property, 0, 1, plugin.render, plugin, 0, plugin.priority); 2849 2850 if (tween !== _quickTween) { 2851 ptLookup = tween._ptLookup[tween._targets.indexOf(target)]; //note: we can't use tween._ptLookup[index] because for staggered tweens, the index from the fullTargets array won't match what it is in each individual tween that spawns from the stagger. 2852 2853 i = plugin._props.length; 2854 2855 while (i--) { 2856 ptLookup[plugin._props[i]] = pt; 2857 } 2858 } 2859 } 2860 2861 return plugin; 2862}, 2863 _overwritingTween, 2864 //store a reference temporarily so we can avoid overwriting itself. 2865_forceAllPropTweens, 2866 _initTween = function _initTween(tween, time, tTime) { 2867 var vars = tween.vars, 2868 ease = vars.ease, 2869 startAt = vars.startAt, 2870 immediateRender = vars.immediateRender, 2871 lazy = vars.lazy, 2872 onUpdate = vars.onUpdate, 2873 runBackwards = vars.runBackwards, 2874 yoyoEase = vars.yoyoEase, 2875 keyframes = vars.keyframes, 2876 autoRevert = vars.autoRevert, 2877 dur = tween._dur, 2878 prevStartAt = tween._startAt, 2879 targets = tween._targets, 2880 parent = tween.parent, 2881 fullTargets = parent && parent.data === "nested" ? parent.vars.targets : targets, 2882 autoOverwrite = tween._overwrite === "auto" && !_suppressOverwrites, 2883 tl = tween.timeline, 2884
vendor: 3,914 bytes, lines 2884-2956
2884cleanVars, 2885 i, 2886 p, 2887 pt, 2888 target, 2889 hasPriority, 2890 gsData, 2891 harness, 2892 plugin, 2893 ptLookup, 2894 index, 2895 harnessVars, 2896 overwritten; 2897 tl && (!keyframes || !ease) && (ease = "none"); 2898 tween._ease = _parseEase(ease, _defaults.ease); 2899 tween._yEase = yoyoEase ? _invertEase(_parseEase(yoyoEase === true ? ease : yoyoEase, _defaults.ease)) : 0; 2900 2901 if (yoyoEase && tween._yoyo && !tween._repeat) { 2902 //there must have been a parent timeline with yoyo:true that is currently in its yoyo phase, so flip the eases. 2903 yoyoEase = tween._yEase; 2904 tween._yEase = tween._ease; 2905 tween._ease = yoyoEase; 2906 } 2907 2908 tween._from = !tl && !!vars.runBackwards; //nested timelines should never run backwards - the backwards-ness is in the child tweens. 2909 2910 if (!tl || keyframes && !vars.stagger) { 2911 //if there's an internal timeline, skip all the parsing because we passed that task down the chain. 2912 harness = targets[0] ? _getCache(targets[0]).harness : 0; 2913 harnessVars = harness && vars[harness.prop]; //someone may need to specify CSS-specific values AND non-CSS values, like if the element has an "x" property plus it's a standard DOM element. We allow people to distinguish by wrapping plugin-specific stuff in a css:{} object for example. 2914 2915 cleanVars = _copyExcluding(vars, _reservedProps); 2916 2917 if (prevStartAt) { 2918 prevStartAt._zTime < 0 && prevStartAt.progress(1); // in case it's a lazy startAt that hasn't rendered yet. 2919 2920 time < 0 && runBackwards && immediateRender && !autoRevert ? prevStartAt.render(-1, true) : prevStartAt.revert(runBackwards && dur ? _revertConfigNoKill : _startAtRevertConfig); // if it's a "startAt" (not "from()" or runBackwards: true), we only need to do a shallow revert (keep transforms cached in CSSPlugin) 2921 // don't just _removeFromParent(prevStartAt.render(-1, true)) because that'll leave inline styles. We're creating a new _startAt for "startAt" tweens that re-capture things to ensure that if the pre-tween values changed since the tween was created, they're recorded. 2922 2923 prevStartAt._lazy = 0; 2924 } 2925 2926 if (startAt) { 2927 _removeFromParent(tween._startAt = Tween.set(targets, _setDefaults({ 2928 data: "isStart", 2929 overwrite: false, 2930 parent: parent, 2931 immediateRender: true, 2932 lazy: !prevStartAt && _isNotFalse(lazy), 2933 startAt: null, 2934 delay: 0, 2935 onUpdate: onUpdate && function () { 2936 return _callback(tween, "onUpdate"); 2937 }, 2938 stagger: 0 2939 }, startAt))); //copy the properties/values into a new object to avoid collisions, like var to = {x:0}, from = {x:500}; timeline.fromTo(e, from, to).fromTo(e, to, from); 2940 2941 2942 tween._startAt._dp = 0; // don't allow it to get put back into root timeline! Like when revert() is called and totalTime() gets set. 2943 2944 tween._startAt._sat = tween; // used in globalTime(). _sat stands for _startAtTween 2945 2946 time < 0 && (_reverting || !immediateRender && !autoRevert) && tween._startAt.revert(_revertConfigNoKill); // rare edge case, like if a render is forced in the negative direction of a non-initted tween. 2947 2948 if (immediateRender) { 2949 if (dur && time <= 0 && tTime <= 0) { 2950 // check tTime here because in the case of a yoyo tween whose playhead gets pushed to the end like tween.progress(1), we should allow it through so that the onComplete gets fired properly. 2951 time && (tween._zTime = time); 2952 return; //we skip initialization here so that overwriting doesn't occur until the tween actually begins. Otherwise, if you create several immediateRender:true tweens of the same target/properties to drop into a Timeline, the last one created would overwrite the first ones because they didn't get placed into the timeline yet before the first render occurs and kicks in overwriting. 2953 } 2954 } 2955 } else if (runBackwards && dur) { 2956 //
vendor: 7,258 bytes, lines 2956-3081
2956from() tweens must be handled uniquely: their beginning values must be rendered but we don't want overwriting to occur yet (when time is still 0). Wait until the tween actually begins before doing all the routines like overwriting. At that time, we should render at the END of the tween to ensure that things initialize correctly (remember, from() tweens go backwards) 2957 if (!prevStartAt) { 2958 time && (immediateRender = false); //in rare cases (like if a from() tween runs and then is invalidate()-ed), immediateRender could be true but the initial forced-render gets skipped, so there's no need to force the render in this context when the _time is greater than 0 2959 2960 p = _setDefaults({ 2961 overwrite: false, 2962 data: "isFromStart", 2963 //we tag the tween with as "isFromStart" so that if [inside a plugin] we need to only do something at the very END of a tween, we have a way of identifying this tween as merely the one that's setting the beginning values for a "from()" tween. For example, clearProps in CSSPlugin should only get applied at the very END of a tween and without this tag, from(...{height:100, clearProps:"height", delay:1}) would wipe the height at the beginning of the tween and after 1 second, it'd kick back in. 2964 lazy: immediateRender && !prevStartAt && _isNotFalse(lazy), 2965 immediateRender: immediateRender, 2966 //zero-duration tweens render immediately by default, but if we're not specifically instructed to render this tween immediately, we should skip this and merely _init() to record the starting values (rendering them immediately would push them to completion which is wasteful in that case - we'd have to render(-1) immediately after) 2967 stagger: 0, 2968 parent: parent //ensures that nested tweens that had a stagger are handled properly, like gsap.from(".class", {y: gsap.utils.wrap([-100,100]), stagger: 0.5}) 2969 2970 }, cleanVars); 2971 harnessVars && (p[harness.prop] = harnessVars); // in case someone does something like .from(..., {css:{}}) 2972 2973 _removeFromParent(tween._startAt = Tween.set(targets, p)); 2974 2975 tween._startAt._dp = 0; // don't allow it to get put back into root timeline! 2976 2977 tween._startAt._sat = tween; // used in globalTime() 2978 2979 time < 0 && (_reverting ? tween._startAt.revert(_revertConfigNoKill) : tween._startAt.render(-1, true)); 2980 tween._zTime = time; 2981 2982 if (!immediateRender) { 2983 _initTween(tween._startAt, _tinyNum, _tinyNum); //ensures that the initial values are recorded 2984 2985 } else if (!time) { 2986 return; 2987 } 2988 } 2989 } 2990 2991 tween._pt = tween._ptCache = 0; 2992 lazy = dur && _isNotFalse(lazy) || lazy && !dur; 2993 2994 for (i = 0; i < targets.length; i++) { 2995 target = targets[i]; 2996 gsData = target._gsap || _harness(targets)[i]._gsap; 2997 tween._ptLookup[i] = ptLookup = {}; 2998 _lazyLookup[gsData.id] && _lazyTweens.length && _lazyRender(); //if other tweens of the same target have recently initted but haven't rendered yet, we've got to force the render so that the starting values are correct (imagine populating a timeline with a bunch of sequential tweens and then jumping to the end) 2999 3000 index = fullTargets === targets ? i : fullTargets.indexOf(target); 3001 3002 if (harness && (plugin = new harness()).init(target, harnessVars || cleanVars, tween, index, fullTargets) !== false) { 3003 tween._pt = pt = new PropTween(tween._pt, target, plugin.name, 0, 1, plugin.render, plugin, 0, plugin.priority); 3004 3005 plugin._props.forEach(function (name) { 3006 ptLookup[name] = pt; 3007 }); 3008 3009 plugin.priority && (hasPriority = 1); 3010 } 3011 3012 if (!harness || harnessVars) { 3013 for (p in cleanVars) { 3014 if (_plugins[p] && (plugin = _checkPlugin(p, cleanVars, tween, index, target, fullTargets))) { 3015 plugin.priority && (hasPriority = 1); 3016 } else { 3017 ptLookup[p] = pt = _addPropTween.call(tween, target, p, "get", cleanVars[p], index, fullTargets, 0, vars.stringFilter); 3018 } 3019 } 3020 } 3021 3022 tween._op && tween._op[i] && tween.kill(target, tween._op[i]); 3023 3024 if (autoOverwrite && tween._pt) { 3025 _overwritingTween = tween; 3026 3027 _globalTimeline.killTweensOf(target, ptLookup, tween.globalTime(time)); // make sure the overwriting doesn't overwrite THIS tween!!! 3028 3029 3030 overwritten = !tween.parent; 3031 _overwritingTween = 0; 3032 } 3033 3034 tween._pt && lazy && (_lazyLookup[gsData.id] = 1); 3035 } 3036 3037 hasPriority && _sortPropTweensByPriority(tween); 3038 tween._onInit && tween._onInit(tween); //plugins like RoundProps must wait until ALL of the PropTweens are instantiated. In the plugin's init() function, it sets the _onInit on the tween instance. May not be pretty/intuitive, but it's fast and keeps file size down. 3039 } 3040 3041 tween._onUpdate = onUpdate; 3042 tween._initted = (!tween._op || tween._pt) && !overwritten; // if overwrittenProps resulted in the entire tween being killed, do NOT flag it as initted or else it may render for one tick. 3043 3044 keyframes && time <= 0 && tl.render(_bigNum, true, true); // if there's a 0% keyframe, it'll render in the "before" state for any staggered/delayed animations thus when the following tween initializes, it'll use the "before" state instead of the "after" state as the initial values. 3045}, 3046 _updatePropTweens = function _updatePropTweens(tween, property, value, start, startIsRelative, ratio, time, skipRecursion) { 3047 var ptCache = (tween._pt && tween._ptCache || (tween._ptCache = {}))[property], 3048 pt, 3049 rootPT, 3050 lookup, 3051 i; 3052 3053 if (!ptCache) { 3054 ptCache = tween._ptCache[property] = []; 3055 lookup = tween._ptLookup; 3056 i = tween._targets.length; 3057 3058 while (i--) { 3059 pt = lookup[i][property]; 3060 3061 if (pt && pt.d && pt.d._pt) { 3062 // it's a plugin, so find the nested PropTween 3063 pt = pt.d._pt; 3064 3065 while (pt && pt.p !== property && pt.fp !== property) { 3066 // "fp" is functionParam for things like setting CSS variables which require .setProperty("--var-name", value) 3067 pt = pt._next; 3068 } 3069 } 3070 3071 if (!pt) { 3072 // there is no PropTween associated with that property, so we must FORCE one to be created and ditch out of this 3073 // if the tween has other properties that already rendered at new positions, we'd normally have to rewind to put them back like tween.render(0, true) before forcing an _initTween(), but that can create another edge case like tweening a timeline's progress would trigger onUpdates to fire which could move other things around. It's better to just inform users that .resetTo() should ONLY be used for tweens that already have that property. For example, you can't gsap.to(...{ y: 0 }) and then tween.restTo("x", 200) for example. 3074 _forceAllPropTweens = 1; // otherwise, when we _addPropTween() and it finds no change between the start and end values, it skips creating a PropTween (for efficiency...why tween when there's no difference?) but in this case we NEED that PropTween created so we can edit it. 3075 3076 tween.vars[property] = "+=0"; 3077 3078 _initTween(tween, time); 3079 3080 _forceAllPropTweens = 0; 3081 return skipRecursion ? _warn(property + " not eligible for reset
vendor: 1,895 bytes, lines 3081-3136
3081") : 1; // if someone tries to do a quickTo() on a special property like borderRadius which must get split into 4 different properties, that's not eligible for .resetTo(). 3082 } 3083 3084 ptCache.push(pt); 3085 } 3086 } 3087 3088 i = ptCache.length; 3089 3090 while (i--) { 3091 rootPT = ptCache[i]; 3092 pt = rootPT._pt || rootPT; // complex values may have nested PropTweens. We only accommodate the FIRST value. 3093 3094 pt.s = (start || start === 0) && !startIsRelative ? start : pt.s + (start || 0) + ratio * pt.c; 3095 pt.c = value - pt.s; 3096 rootPT.e && (rootPT.e = _round(value) + getUnit(rootPT.e)); // mainly for CSSPlugin (end value) 3097 3098 rootPT.b && (rootPT.b = pt.s + getUnit(rootPT.b)); // (beginning value) 3099 } 3100}, 3101 _addAliasesToVars = function _addAliasesToVars(targets, vars) { 3102 var harness = targets[0] ? _getCache(targets[0]).harness : 0, 3103 propertyAliases = harness && harness.aliases, 3104 copy, 3105 p, 3106 i, 3107 aliases; 3108 3109 if (!propertyAliases) { 3110 return vars; 3111 } 3112 3113 copy = _merge({}, vars); 3114 3115 for (p in propertyAliases) { 3116 if (p in copy) { 3117 aliases = propertyAliases[p].split(","); 3118 i = aliases.length; 3119 3120 while (i--) { 3121 copy[aliases[i]] = copy[p]; 3122 } 3123 } 3124 } 3125 3126 return copy; 3127}, 3128 // parses multiple formats, like {"0%": {x: 100}, {"50%": {x: -20}} and { x: {"0%": 100, "50%": -20} }, and an "ease" can be set on any object. We populate an "allProps" object with an Array for each property, like {x: [{}, {}], y:[{}, {}]} with data for each property tween. The objects have a "t" (time), "v", (value), and "e" (ease) property. This allows us to piece together a timeline later. 3129_parseKeyframe = function _parseKeyframe(prop, obj, allProps, easeEach) { 3130 var ease = obj.ease || easeEach || "power1.inOut", 3131 p, 3132 a; 3133 3134 if (_isArray(obj)) { 3135 a = allProps[prop] || (allProps[prop] = []); // t = time (out of 100), v = value, e = ease 3136
vendor: 4,638 bytes, lines 3137-3246
3137 obj.forEach(function (value, i) { 3138 return a.push({ 3139 t: i / (obj.length - 1) * 100, 3140 v: value, 3141 e: ease 3142 }); 3143 }); 3144 } else { 3145 for (p in obj) { 3146 a = allProps[p] || (allProps[p] = []); 3147 p === "ease" || a.push({ 3148 t: parseFloat(prop), 3149 v: obj[p], 3150 e: ease 3151 }); 3152 } 3153 } 3154}, 3155 _parseFuncOrString = function _parseFuncOrString(value, tween, i, target, targets) { 3156 return _isFunction(value) ? value.call(tween, i, target, targets) : _isString(value) && ~value.indexOf("random(") ? _replaceRandom(value) : value; 3157}, 3158 _staggerTweenProps = _callbackNames + "repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase,autoRevert", 3159 _staggerPropsToSkip = {}; 3160 3161_forEachName(_staggerTweenProps + ",id,stagger,delay,duration,paused,scrollTrigger", function (name) { 3162 return _staggerPropsToSkip[name] = 1; 3163}); 3164/* 3165 * -------------------------------------------------------------------------------------- 3166 * TWEEN 3167 * -------------------------------------------------------------------------------------- 3168 */ 3169 3170 3171export var Tween = /*#__PURE__*/function (_Animation2) { 3172 _inheritsLoose(Tween, _Animation2); 3173 3174 function Tween(targets, vars, position, skipInherit) { 3175 var _this3; 3176 3177 if (typeof vars === "number") { 3178 position.duration = vars; 3179 vars = position; 3180 position = null; 3181 } 3182 3183 _this3 = _Animation2.call(this, skipInherit ? vars : _inheritDefaults(vars)) || this; 3184 var _this3$vars = _this3.vars, 3185 duration = _this3$vars.duration, 3186 delay = _this3$vars.delay, 3187 immediateRender = _this3$vars.immediateRender, 3188 stagger = _this3$vars.stagger, 3189 overwrite = _this3$vars.overwrite, 3190 keyframes = _this3$vars.keyframes, 3191 defaults = _this3$vars.defaults, 3192 scrollTrigger = _this3$vars.scrollTrigger, 3193 yoyoEase = _this3$vars.yoyoEase, 3194 parent = vars.parent || _globalTimeline, 3195 parsedTargets = (_isArray(targets) || _isTypedArray(targets) ? _isNumber(targets[0]) : "length" in vars) ? [targets] : toArray(targets), 3196 tl, 3197 i, 3198 copy, 3199 l, 3200 p, 3201 curTarget, 3202 staggerFunc, 3203 staggerVarsToMerge; 3204 _this3._targets = parsedTargets.length ? _harness(parsedTargets) : _warn("GSAP target " + targets + " not found. https://gsap.com", !_config.nullTargetWarn) || []; 3205 _this3._ptLookup = []; //PropTween lookup. An array containing an object for each target, having keys for each tweening property 3206 3207 _this3._overwrite = overwrite; 3208 3209 if (keyframes || stagger || _isFuncOrString(duration) || _isFuncOrString(delay)) { 3210 vars = _this3.vars; 3211 tl = _this3.timeline = new Timeline({ 3212 data: "nested", 3213 defaults: defaults || {}, 3214 targets: parent && parent.data === "nested" ? parent.vars.targets : parsedTargets 3215 }); // we need to store the targets because for staggers and keyframes, we end up creating an individual tween for each but function-based values need to know the index and the whole Array of targets. 3216 3217 tl.kill(); 3218 tl.parent = tl._dp = _assertThisInitialized(_this3); 3219 tl._start = 0; 3220 3221 if (stagger || _isFuncOrString(duration) || _isFuncOrString(delay)) { 3222 l = parsedTargets.length; 3223 staggerFunc = stagger && distribute(stagger); 3224 3225 if (_isObject(stagger)) { 3226 //users can pass in callbacks like onStart/onComplete in the stagger object. These should fire with each individual tween. 3227 for (p in stagger) { 3228 if (~_staggerTweenProps.indexOf(p)) { 3229 staggerVarsToMerge || (staggerVarsToMerge = {}); 3230 staggerVarsToMerge[p] = stagger[p]; 3231 } 3232 } 3233 } 3234 3235 for (i = 0; i < l; i++) { 3236 copy = _copyExcluding(vars, _staggerPropsToSkip); 3237 copy.stagger = 0; 3238 yoyoEase && (copy.yoyoEase = yoyoEase); 3239 staggerVarsToMerge && _merge(copy, staggerVarsToMerge); 3240 curTarget = parsedTargets[i]; //don't just copy duration or delay because if they're a string or function, we'd end up in an infinite loop because _isFuncOrString() would evaluate as true in the child tweens, entering this loop, etc. So we parse the value straight from vars and default to 0. 3241 3242 copy.duration = +_parseFuncOrString(duration, _assertThisInitialized(_this3), i, curTarget, parsedTargets); 3243 copy.delay = (+_parseFuncOrString(delay, _assertThisInitialized(_this3), i, curTarget, parsedTargets) || 0) - _this3._delay; 3244 3245 if (!stagger && l === 1 && copy.delay) { 3246 // if someone does delay:"random(1, 5)", repeat:-1, for example, the delay
vendor: 10,315 bytes, lines 3246-3488
3246shouldn't be inside the repeat. 3247 _this3._delay = delay = copy.delay; 3248 _this3._start += delay; 3249 copy.delay = 0; 3250 } 3251 3252 tl.to(curTarget, copy, staggerFunc ? staggerFunc(i, curTarget, parsedTargets) : 0); 3253 tl._ease = _easeMap.none; 3254 } 3255 3256 tl.duration() ? duration = delay = 0 : _this3.timeline = 0; // if the timeline's duration is 0, we don't need a timeline internally! 3257 } else if (keyframes) { 3258 _inheritDefaults(_setDefaults(tl.vars.defaults, { 3259 ease: "none" 3260 })); 3261 3262 tl._ease = _parseEase(keyframes.ease || vars.ease || "none"); 3263 var time = 0, 3264 a, 3265 kf, 3266 v; 3267 3268 if (_isArray(keyframes)) { 3269 keyframes.forEach(function (frame) { 3270 return tl.to(parsedTargets, frame, ">"); 3271 }); 3272 tl.duration(); // to ensure tl._dur is cached because we tap into it for performance purposes in the render() method. 3273 } else { 3274 copy = {}; 3275 3276 for (p in keyframes) { 3277 p === "ease" || p === "easeEach" || _parseKeyframe(p, keyframes[p], copy, keyframes.easeEach); 3278 } 3279 3280 for (p in copy) { 3281 a = copy[p].sort(function (a, b) { 3282 return a.t - b.t; 3283 }); 3284 time = 0; 3285 3286 for (i = 0; i < a.length; i++) { 3287 kf = a[i]; 3288 v = { 3289 ease: kf.e, 3290 duration: (kf.t - (i ? a[i - 1].t : 0)) / 100 * duration 3291 }; 3292 v[p] = kf.v; 3293 tl.to(parsedTargets, v, time); 3294 time += v.duration; 3295 } 3296 } 3297 3298 tl.duration() < duration && tl.to({}, { 3299 duration: duration - tl.duration() 3300 }); // in case keyframes didn't go to 100% 3301 } 3302 } 3303 3304 duration || _this3.duration(duration = tl.duration()); 3305 } else { 3306 _this3.timeline = 0; //speed optimization, faster lookups (no going up the prototype chain) 3307 } 3308 3309 if (overwrite === true && !_suppressOverwrites) { 3310 _overwritingTween = _assertThisInitialized(_this3); 3311 3312 _globalTimeline.killTweensOf(parsedTargets); 3313 3314 _overwritingTween = 0; 3315 } 3316 3317 _addToTimeline(parent, _assertThisInitialized(_this3), position); 3318 3319 vars.reversed && _this3.reverse(); 3320 vars.paused && _this3.paused(true); 3321 3322 if (immediateRender || !duration && !keyframes && _this3._start === _roundPrecise(parent._time) && _isNotFalse(immediateRender) && _hasNoPausedAncestors(_assertThisInitialized(_this3)) && parent.data !== "nested") { 3323 _this3._tTime = -_tinyNum; //forces a render without having to set the render() "force" parameter to true because we want to allow lazying by default (using the "force" parameter always forces an immediate full render) 3324 3325 _this3.render(Math.max(0, -delay) || 0); //in case delay is negative 3326 3327 } 3328 3329 scrollTrigger && _scrollTrigger(_assertThisInitialized(_this3), scrollTrigger); 3330 return _this3; 3331 } 3332 3333 var _proto3 = Tween.prototype; 3334 3335 _proto3.render = function render(totalTime, suppressEvents, force) { 3336 var prevTime = this._time, 3337 tDur = this._tDur, 3338 dur = this._dur, 3339 isNegative = totalTime < 0, 3340 tTime = totalTime > tDur - _tinyNum && !isNegative ? tDur : totalTime < _tinyNum ? 0 : totalTime, 3341 time, 3342 pt, 3343 iteration, 3344 cycleDuration, 3345 prevIteration, 3346 isYoyo, 3347 ratio, 3348 timeline, 3349 yoyoEase; 3350 3351 if (!dur) { 3352 _renderZeroDurationTween(this, totalTime, suppressEvents, force); 3353 } else if (tTime !== this._tTime || !totalTime || force || !this._initted && this._tTime || this._startAt && this._zTime < 0 !== isNegative) { 3354 //this senses if we're crossing over the start time, in which case we must record _zTime and force the render, but we do it in this lengthy conditional way for performance reasons (usually we can skip the calculations): this._initted && (this._zTime < 0) !== (totalTime < 0) 3355 time = tTime; 3356 timeline = this.timeline; 3357 3358 if (this._repeat) { 3359 //adjust the time for repeats and yoyos 3360 cycleDuration = dur + this._rDelay; 3361 3362 if (this._repeat < -1 && isNegative) { 3363 return this.totalTime(cycleDuration * 100 + totalTime, suppressEvents, force); 3364 } 3365 3366 time = _roundPrecise(tTime % cycleDuration); //round to avoid floating point errors. (4 % 0.8 should be 0 but some browsers report it as 0.79999999!) 3367 3368 if (tTime === tDur) { 3369 // the tDur === tTime is for edge cases where there's a lengthy decimal on the duration and it may reach the very end but the time is rendered as not-quite-there (remember, tDur is rounded to 4 decimals whereas dur isn't) 3370 iteration = this._repeat; 3371 time = dur; 3372 } else { 3373 iteration = ~~(tTime / cycleDuration); 3374 3375 if (iteration && iteration === _roundPrecise(tTime / cycleDuration)) { 3376 time = dur; 3377 iteration--; 3378 } 3379 3380 time > dur && (time = dur); 3381 } 3382 3383 isYoyo = this._yoyo && iteration & 1; 3384 3385 if (isYoyo) { 3386 yoyoEase = this._yEase; 3387 time = dur - time; 3388 } 3389 3390 prevIteration = _animationCycle(this._tTime, cycleDuration); 3391 3392 if (time === prevTime && !force && this._initted && iteration === prevIteration) { 3393 //could be during the repeatDelay part. No need to render and fire callbacks. 3394 this._tTime = tTime; 3395 return this; 3396 } 3397 3398 if (iteration !== prevIteration) { 3399 timeline && this._yEase && _propagateYoyoEase(timeline, isYoyo); //repeatRefresh functionality 3400 3401 if (this.vars.repeatRefresh && !isYoyo && !this._lock && this._time !== cycleDuration && this._initted) { 3402 // this._time will === cycleDuration when we render at EXACTLY the end of an iteration. Without this condition, it'd often do the repeatRefresh render TWICE (again on the very next tick). 3403 this._lock = force = 1; //force, otherwise if lazy is true, the _attemptInitTween() will return and we'll jump out and get caught bouncing on each tick. 3404 3405 this.render(_roundPrecise(cycleDuration * iteration), true).invalidate()._lock = 0; 3406 } 3407 } 3408 } 3409 3410 if (!this._initted) { 3411 if (_attemptInitTween(this, isNegative ? totalTime : time, force, suppressEvents, tTime)) { 3412 this._tTime = 0; // in constructor if immediateRender is true, we set _tTime to -_tinyNum to have the playhead cross the starting point but we can't leave _tTime as a negative number. 3413 3414 return this; 3415 } 3416 3417 if (prevTime !== this._time && !(force && this.vars.repeatRefresh && iteration !== prevIteration)) { 3418 // rare edge case - during initialization, an onUpdate in the _startAt (.fromTo()) might force this tween to render at a different spot in which case we should ditch this render() call so that it doesn't revert the values. But we also don't want to dump if we're doing a repeatRefresh render! 3419 return this; 3420 } 3421 3422 if (dur !== this._dur) { 3423 // while initting, a plugin like InertiaPlugin might alter the duration, so rerun from the start to ensure everything renders as it should. 3424 return this.render(totalTime, suppressEvents, force); 3425 } 3426 } 3427 3428 this._tTime = tTime; 3429 this._time = time; 3430 3431 if (!this._act && this._ts) { 3432 this._act = 1; //as long as it's not paused, force it to be active so that if the user renders independent of the parent timeline, it'll be forced to re-render on the next tick. 3433 3434 this._lazy = 0; 3435 } 3436 3437 this.ratio = ratio = (yoyoEase || this._ease)(time / dur); 3438 3439 if (this._from) { 3440 this.ratio = ratio = 1 - ratio; 3441 } 3442 3443 if (time && !prevTime && !suppressEvents && !iteration) { 3444 _callback(this, "onStart"); 3445 3446 if (this._tTime !== tTime) { 3447 // in case the onStart triggered a render at a different spot, eject. Like if someone did animation.pause(0.5) or something inside the onStart. 3448 return this; 3449 } 3450 } 3451 3452 pt = this._pt; 3453 3454 while (pt) { 3455 pt.r(ratio, pt.d); 3456 pt = pt._next; 3457 } 3458 3459 timeline && timeline.render(totalTime < 0 ? totalTime : timeline._dur * timeline._ease(time / this._dur), suppressEvents, force) || this._startAt && (this._zTime = totalTime); 3460 3461 if (this._onUpdate && !suppressEvents) { 3462 isNegative && _rewindStartAt(this, totalTime, suppressEvents, force); //note: for performance reasons, we tuck this conditional logic inside less traveled areas (most tweens don't have an onUpdate). We'd just have it at the end before the onComplete, but the values should be updated before any onUpdate is called, so we ALSO put it here and then if it's not called, we do so later near the onComplete. 3463 3464 _callback(this, "onUpdate"); 3465 } 3466 3467 this._repeat && iteration !== prevIteration && this.vars.onRepeat && !suppressEvents && this.parent && _callback(this, "onRepeat"); 3468 3469 if ((tTime === this._tDur || !tTime) && this._tTime === tTime) { 3470 isNegative && !this._onUpdate && _rewindStartAt(this, totalTime, true, true); 3471 (totalTime || !dur) && (tTime === this._tDur && this._ts > 0 || !tTime && this._ts < 0) && _removeFromParent(this, 1); // don't remove if we're rendering at exactly a time of 0, as there could be autoRevert values that should get set on the next tick (if the playhead goes backward beyond the startTime, negative totalTime). Don't remove if the timeline is reversed and the playhead isn't at 0, otherwise tl.progress(1).reverse() won't work. Only remove if the playhead is at the end and timeScale is positive, or if the playhead is at 0 and the timeScale is negative. 3472 3473 if (!suppressEvents && !(isNegative && !prevTime) && (tTime || prevTime || isYoyo)) { 3474 // if prevTime and tTime are zero, we shouldn't fire the onReverseComplete. This could happen if you gsap.to(... {paused:true}).play(); 3475 _callback(this, tTime === tDur ? "onComplete" : "onReverseComplete", true); 3476 3477 this._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom(); 3478 } 3479 } 3480 } 3481 3482 return this; 3483 }; 3484 3485 _proto3.targets = function targets() { 3486 return this._targets; 3487 }; 3488
vendor: 2,804 bytes, lines 3489-3532
3489 _proto3.invalidate = function invalidate(soft) { 3490 // "soft" gives us a way to clear out everything EXCEPT the recorded pre-"from" portion of from() tweens. Otherwise, for example, if you tween.progress(1).render(0, true true).invalidate(), the "from" values would persist and then on the next render, the from() tweens would initialize and the current value would match the "from" values, thus animate from the same value to the same value (no animation). We tap into this in ScrollTrigger's refresh() where we must push a tween to completion and then back again but honor its init state in case the tween is dependent on another tween further up on the page. 3491 (!soft || !this.vars.runBackwards) && (this._startAt = 0); 3492 this._pt = this._op = this._onUpdate = this._lazy = this.ratio = 0; 3493 this._ptLookup = []; 3494 this.timeline && this.timeline.invalidate(soft); 3495 return _Animation2.prototype.invalidate.call(this, soft); 3496 }; 3497 3498 _proto3.resetTo = function resetTo(property, value, start, startIsRelative, skipRecursion) { 3499 _tickerActive || _ticker.wake(); 3500 this._ts || this.play(); 3501 var time = Math.min(this._dur, (this._dp._time - this._start) * this._ts), 3502 ratio; 3503 this._initted || _initTween(this, time); 3504 ratio = this._ease(time / this._dur); // don't just get tween.ratio because it may not have rendered yet. 3505 // possible future addition to allow an object with multiple values to update, like tween.resetTo({x: 100, y: 200}); At this point, it doesn't seem worth the added kb given the fact that most users will likely opt for the convenient gsap.quickTo() way of interacting with this method. 3506 // if (_isObject(property)) { // performance optimization 3507 // for (p in property) { 3508 // if (_updatePropTweens(this, p, property[p], value ? value[p] : null, start, ratio, time)) { 3509 // return this.resetTo(property, value, start, startIsRelative); // if a PropTween wasn't found for the property, it'll get forced with a re-initialization so we need to jump out and start over again. 3510 // } 3511 // } 3512 // } else { 3513 3514 if (_updatePropTweens(this, property, value, start, startIsRelative, ratio, time, skipRecursion)) { 3515 return this.resetTo(property, value, start, startIsRelative, 1); // if a PropTween wasn't found for the property, it'll get forced with a re-initialization so we need to jump out and start over again. 3516 } //} 3517 3518 3519 _alignPlayhead(this, 0); 3520 3521 this.parent || _addLinkedListItem(this._dp, this, "_first", "_last", this._dp._sort ? "_start" : 0); 3522 return this.render(0); 3523 }; 3524 3525 _proto3.kill = function kill(targets, vars) { 3526 if (vars === void 0) { 3527 vars = "all"; 3528 } 3529 3530 if (!targets && (!vars || vars === "all")) { 3531 this._lazy = this._pt = 0; 3532 return this.parent ? _interrupt(this) :
vendor: 16,310 bytes, lines 3532-4044
3532 this; 3533 } 3534 3535 if (this.timeline) { 3536 var tDur = this.timeline.totalDuration(); 3537 this.timeline.killTweensOf(targets, vars, _overwritingTween && _overwritingTween.vars.overwrite !== true)._first || _interrupt(this); // if nothing is left tweening, interrupt. 3538 3539 this.parent && tDur !== this.timeline.totalDuration() && _setDuration(this, this._dur * this.timeline._tDur / tDur, 0, 1); // if a nested tween is killed that changes the duration, it should affect this tween's duration. We must use the ratio, though, because sometimes the internal timeline is stretched like for keyframes where they don't all add up to whatever the parent tween's duration was set to. 3540 3541 return this; 3542 } 3543 3544 var parsedTargets = this._targets, 3545 killingTargets = targets ? toArray(targets) : parsedTargets, 3546 propTweenLookup = this._ptLookup, 3547 firstPT = this._pt, 3548 overwrittenProps, 3549 curLookup, 3550 curOverwriteProps, 3551 props, 3552 p, 3553 pt, 3554 i; 3555 3556 if ((!vars || vars === "all") && _arraysMatch(parsedTargets, killingTargets)) { 3557 vars === "all" && (this._pt = 0); 3558 return _interrupt(this); 3559 } 3560 3561 overwrittenProps = this._op = this._op || []; 3562 3563 if (vars !== "all") { 3564 //so people can pass in a comma-delimited list of property names 3565 if (_isString(vars)) { 3566 p = {}; 3567 3568 _forEachName(vars, function (name) { 3569 return p[name] = 1; 3570 }); 3571 3572 vars = p; 3573 } 3574 3575 vars = _addAliasesToVars(parsedTargets, vars); 3576 } 3577 3578 i = parsedTargets.length; 3579 3580 while (i--) { 3581 if (~killingTargets.indexOf(parsedTargets[i])) { 3582 curLookup = propTweenLookup[i]; 3583 3584 if (vars === "all") { 3585 overwrittenProps[i] = vars; 3586 props = curLookup; 3587 curOverwriteProps = {}; 3588 } else { 3589 curOverwriteProps = overwrittenProps[i] = overwrittenProps[i] || {}; 3590 props = vars; 3591 } 3592 3593 for (p in props) { 3594 pt = curLookup && curLookup[p]; 3595 3596 if (pt) { 3597 if (!("kill" in pt.d) || pt.d.kill(p) === true) { 3598 _removeLinkedListItem(this, pt, "_pt"); 3599 } 3600 3601 delete curLookup[p]; 3602 } 3603 3604 if (curOverwriteProps !== "all") { 3605 curOverwriteProps[p] = 1; 3606 } 3607 } 3608 } 3609 } 3610 3611 this._initted && !this._pt && firstPT && _interrupt(this); //if all tweening properties are killed, kill the tween. Without this line, if there's a tween with multiple targets and then you killTweensOf() each target individually, the tween would technically still remain active and fire its onComplete even though there aren't any more properties tweening. 3612 3613 return this; 3614 }; 3615 3616 Tween.to = function to(targets, vars) { 3617 return new Tween(targets, vars, arguments[2]); 3618 }; 3619 3620 Tween.from = function from(targets, vars) { 3621 return _createTweenType(1, arguments); 3622 }; 3623 3624 Tween.delayedCall = function delayedCall(delay, callback, params, scope) { 3625 return new Tween(callback, 0, { 3626 immediateRender: false, 3627 lazy: false, 3628 overwrite: false, 3629 delay: delay, 3630 onComplete: callback, 3631 onReverseComplete: callback, 3632 onCompleteParams: params, 3633 onReverseCompleteParams: params, 3634 callbackScope: scope 3635 }); // we must use onReverseComplete too for things like timeline.add(() => {...}) which should be triggered in BOTH directions (forward and reverse) 3636 }; 3637 3638 Tween.fromTo = function fromTo(targets, fromVars, toVars) { 3639 return _createTweenType(2, arguments); 3640 }; 3641 3642 Tween.set = function set(targets, vars) { 3643 vars.duration = 0; 3644 vars.repeatDelay || (vars.repeat = 0); 3645 return new Tween(targets, vars); 3646 }; 3647 3648 Tween.killTweensOf = function killTweensOf(targets, props, onlyActive) { 3649 return _globalTimeline.killTweensOf(targets, props, onlyActive); 3650 }; 3651 3652 return Tween; 3653}(Animation); 3654 3655_setDefaults(Tween.prototype, { 3656 _targets: [], 3657 _lazy: 0, 3658 _startAt: 0, 3659 _op: 0, 3660 _onInit: 0 3661}); //add the pertinent timeline methods to Tween instances so that users can chain conveniently and create a timeline automatically. (removed due to concerns that it'd ultimately add to more confusion especially for beginners) 3662// _forEachName("to,from,fromTo,set,call,add,addLabel,addPause", name => { 3663// Tween.prototype[name] = function() { 3664// let tl = new Timeline(); 3665// return _addToTimeline(tl, this)[name].apply(tl, toArray(arguments)); 3666// } 3667// }); 3668//for backward compatibility. Leverage the timeline calls. 3669 3670 3671_forEachName("staggerTo,staggerFrom,staggerFromTo", function (name) { 3672 Tween[name] = function () { 3673 var tl = new Timeline(), 3674 params = _slice.call(arguments, 0); 3675 3676 params.splice(name === "staggerFromTo" ? 5 : 4, 0, 0); 3677 return tl[name].apply(tl, params); 3678 }; 3679}); 3680/* 3681 * -------------------------------------------------------------------------------------- 3682 * PROPTWEEN 3683 * -------------------------------------------------------------------------------------- 3684 */ 3685 3686 3687var _setterPlain = function _setterPlain(target, property, value) { 3688 return target[property] = value; 3689}, 3690 _setterFunc = function _setterFunc(target, property, value) { 3691 return target[property](value); 3692}, 3693 _setterFuncWithParam = function _setterFuncWithParam(target, property, value, data) { 3694 return target[property](data.fp, value); 3695}, 3696 _setterAttribute = function _setterAttribute(target, property, value) { 3697 return target.setAttribute(property, value); 3698}, 3699 _getSetter = function _getSetter(target, property) { 3700 return _isFunction(target[property]) ? _setterFunc : _isUndefined(target[property]) && target.setAttribute ? _setterAttribute : _setterPlain; 3701}, 3702 _renderPlain = function _renderPlain(ratio, data) { 3703 return data.set(data.t, data.p, Math.round((data.s + data.c * ratio) * 1000000) / 1000000, data); 3704}, 3705 _renderBoolean = function _renderBoolean(ratio, data) { 3706 return data.set(data.t, data.p, !!(data.s + data.c * ratio), data); 3707}, 3708 _renderComplexString = function _renderComplexString(ratio, data) { 3709 var pt = data._pt, 3710 s = ""; 3711 3712 if (!ratio && data.b) { 3713 //b = beginning string 3714 s = data.b; 3715 } else if (ratio === 1 && data.e) { 3716 //e = ending string 3717 s = data.e; 3718 } else { 3719 while (pt) { 3720 s = pt.p + (pt.m ? pt.m(pt.s + pt.c * ratio) : Math.round((pt.s + pt.c * ratio) * 10000) / 10000) + s; //we use the "p" property for the text inbetween (like a suffix). And in the context of a complex string, the modifier (m) is typically just Math.round(), like for RGB colors. 3721 3722 pt = pt._next; 3723 } 3724 3725 s += data.c; //we use the "c" of the PropTween to store the final chunk of non-numeric text. 3726 } 3727 3728 data.set(data.t, data.p, s, data); 3729}, 3730 _renderPropTweens = function _renderPropTweens(ratio, data) { 3731 var pt = data._pt; 3732 3733 while (pt) { 3734 pt.r(ratio, pt.d); 3735 pt = pt._next; 3736 } 3737}, 3738 _addPluginModifier = function _addPluginModifier(modifier, tween, target, property) { 3739 var pt = this._pt, 3740 next; 3741 3742 while (pt) { 3743 next = pt._next; 3744 pt.p === property && pt.modifier(modifier, tween, target); 3745 pt = next; 3746 } 3747}, 3748 _killPropTweensOf = function _killPropTweensOf(property) { 3749 var pt = this._pt, 3750 hasNonDependentRemaining, 3751 next; 3752 3753 while (pt) { 3754 next = pt._next; 3755 3756 if (pt.p === property && !pt.op || pt.op === property) { 3757 _removeLinkedListItem(this, pt, "_pt"); 3758 } else if (!pt.dep) { 3759 hasNonDependentRemaining = 1; 3760 } 3761 3762 pt = next; 3763 } 3764 3765 return !hasNonDependentRemaining; 3766}, 3767 _setterWithModifier = function _setterWithModifier(target, property, value, data) { 3768 data.mSet(target, property, data.m.call(data.tween, value, data.mt), data); 3769}, 3770 _sortPropTweensByPriority = function _sortPropTweensByPriority(parent) { 3771 var pt = parent._pt, 3772 next, 3773 pt2, 3774 first, 3775 last; //sorts the PropTween linked list in order of priority because some plugins need to do their work after ALL of the PropTweens were created (like RoundPropsPlugin and ModifiersPlugin) 3776 3777 while (pt) { 3778 next = pt._next; 3779 pt2 = first; 3780 3781 while (pt2 && pt2.pr > pt.pr) { 3782 pt2 = pt2._next; 3783 } 3784 3785 if (pt._prev = pt2 ? pt2._prev : last) { 3786 pt._prev._next = pt; 3787 } else { 3788 first = pt; 3789 } 3790 3791 if (pt._next = pt2) { 3792 pt2._prev = pt; 3793 } else { 3794 last = pt; 3795 } 3796 3797 pt = next; 3798 } 3799 3800 parent._pt = first; 3801}; //PropTween key: t = target, p = prop, r = renderer, d = data, s = start, c = change, op = overwriteProperty (ONLY populated when it's different than p), pr = priority, _next/_prev for the linked list siblings, set = setter, m = modifier, mSet = modifierSetter (the original setter, before a modifier was added) 3802 3803 3804export var PropTween = /*#__PURE__*/function () { 3805 function PropTween(next, target, prop, start, change, renderer, data, setter, priority) { 3806 this.t = target; 3807 this.s = start; 3808 this.c = change; 3809 this.p = prop; 3810 this.r = renderer || _renderPlain; 3811 this.d = data || this; 3812 this.set = setter || _setterPlain; 3813 this.pr = priority || 0; 3814 this._next = next; 3815 3816 if (next) { 3817 next._prev = this; 3818 } 3819 } 3820 3821 var _proto4 = PropTween.prototype; 3822 3823 _proto4.modifier = function modifier(func, tween, target) { 3824 this.mSet = this.mSet || this.set; //in case it was already set (a PropTween can only have one modifier) 3825 3826 this.set = _setterWithModifier; 3827 this.m = func; 3828 this.mt = target; //modifier target 3829 3830 this.tween = tween; 3831 }; 3832 3833 return PropTween; 3834}(); //Initialization tasks 3835 3836_forEachName(_callbackNames + "parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger", function (name) { 3837 return _reservedProps[name] = 1; 3838}); 3839 3840_globals.TweenMax = _globals.TweenLite = Tween; 3841_globals.TimelineLite = _globals.TimelineMax = Timeline; 3842_globalTimeline = new Timeline({ 3843 sortChildren: false, 3844 defaults: _defaults, 3845 autoRemoveChildren: true, 3846 id: "root", 3847 smoothChildTiming: true 3848}); 3849_config.stringFilter = _colorStringFilter; 3850 3851var _media = [], 3852 _listeners = {}, 3853 _emptyArray = [], 3854 _lastMediaTime = 0, 3855 _contextID = 0, 3856 _dispatch = function _dispatch(type) { 3857 return (_listeners[type] || _emptyArray).map(function (f) { 3858 return f(); 3859 }); 3860}, 3861 _onMediaChange = function _onMediaChange() { 3862 var time = Date.now(), 3863 matches = []; 3864 3865 if (time - _lastMediaTime > 2) { 3866 _dispatch("matchMediaInit"); 3867 3868 _media.forEach(function (c) { 3869 var queries = c.queries, 3870 conditions = c.conditions, 3871 match, 3872 p, 3873 anyMatch, 3874 toggled; 3875 3876 for (p in queries) { 3877 match = _win.matchMedia(queries[p]).matches; // Firefox doesn't update the "matches" property of the MediaQueryList object correctly - it only does so as it calls its change handler - so we must re-create a media query here to ensure it's accurate. 3878 3879 match && (anyMatch = 1); 3880 3881 if (match !== conditions[p]) { 3882 conditions[p] = match; 3883 toggled = 1; 3884 } 3885 } 3886 3887 if (toggled) { 3888 c.revert(); 3889 anyMatch && matches.push(c); 3890 } 3891 }); 3892 3893 _dispatch("matchMediaRevert"); 3894 3895 matches.forEach(function (c) { 3896 return c.onMatch(c, function (func) { 3897 return c.add(null, func); 3898 }); 3899 }); 3900 _lastMediaTime = time; 3901 3902 _dispatch("matchMedia"); 3903 } 3904}; 3905 3906var Context = /*#__PURE__*/function () { 3907 function Context(func, scope) { 3908 this.selector = scope && selector(scope); 3909 this.data = []; 3910 this._r = []; // returned/cleanup functions 3911 3912 this.isReverted = false; 3913 this.id = _contextID++; // to work around issues that frameworks like Vue cause by making things into Proxies which make it impossible to do something like _media.indexOf(this) because "this" would no longer refer to the Context instance itself - it'd refer to a Proxy! We needed a way to identify the context uniquely 3914 3915 func && this.add(func); 3916 } 3917 3918 var _proto5 = Context.prototype; 3919 3920 _proto5.add = function add(name, func, scope) { 3921 // possible future addition if we need the ability to add() an animation to a context and for whatever reason cannot create that animation inside of a context.add(() => {...}) function. 3922 // if (name && _isFunction(name.revert)) { 3923 // this.data.push(name); 3924 // return (name._ctx = this); 3925 // } 3926 if (_isFunction(name)) { 3927 scope = func; 3928 func = name; 3929 name = _isFunction; 3930 } 3931 3932 var self = this, 3933 f = function f() { 3934 var prev = _context, 3935 prevSelector = self.selector, 3936 result; 3937 prev && prev !== self && prev.data.push(self); 3938 scope && (self.selector = selector(scope)); 3939 _context = self; 3940 result = func.apply(self, arguments); 3941 _isFunction(result) && self._r.push(result); 3942 _context = prev; 3943 self.selector = prevSelector; 3944 self.isReverted = false; 3945 return result; 3946 }; 3947 3948 self.last = f; 3949 return name === _isFunction ? f(self, function (func) { 3950 return self.add(null, func); 3951 }) : name ? self[name] = f : f; 3952 }; 3953 3954 _proto5.ignore = function ignore(func) { 3955 var prev = _context; 3956 _context = null; 3957 func(this); 3958 _context = prev; 3959 }; 3960 3961 _proto5.getTweens = function getTweens() { 3962 var a = []; 3963 this.data.forEach(function (e) { 3964 return e instanceof Context ? a.push.apply(a, e.getTweens()) : e instanceof Tween && !(e.parent && e.parent.data === "nested") && a.push(e); 3965 }); 3966 return a; 3967 }; 3968 3969 _proto5.clear = function clear() { 3970 this._r.length = this.data.length = 0; 3971 }; 3972 3973 _proto5.kill = function kill(revert, matchMedia) { 3974 var _this4 = this; 3975 3976 if (revert) { 3977 (function () { 3978 var tweens = _this4.getTweens(), 3979 i = _this4.data.length, 3980 t; 3981 3982 while (i--) { 3983 // Flip plugin tweens are very different in that they should actually be pushed to their end. The plugin replaces the timeline's .revert() method to do exactly that. But we also need to remove any of those nested tweens inside the flip timeline so that they don't get individually reverted. 3984 t = _this4.data[i]; 3985 3986 if (t.data === "isFlip") { 3987 t.revert(); 3988 t.getChildren(true, true, false).forEach(function (tween) { 3989 return tweens.splice(tweens.indexOf(tween), 1); 3990 }); 3991 } 3992 } // save as an object so that we can cache the globalTime for each tween to optimize performance during the sort 3993 3994 3995 tweens.map(function (t) { 3996 return { 3997 g: t._dur || t._delay || t._sat && !t._sat.vars.immediateRender ? t.globalTime(0) : -Infinity, 3998 t: t 3999 }; 4000 }).sort(function (a, b) { 4001 return b.g - a.g || -Infinity; 4002 }).forEach(function (o) { 4003 return o.t.revert(revert); 4004 }); // note: all of the _startAt tweens should be reverted in reverse order that they were created, and they'll all have the same globalTime (-1) so the " || -1" in the sort keeps the order properly. 4005 4006 i = _this4.data.length; 4007 4008 while (i--) { 4009 // make sure we loop backwards so that, for example, SplitTexts that were created later on the same element get reverted first 4010 t = _this4.data[i]; 4011 4012 if (t instanceof Timeline) { 4013 if (t.data !== "nested") { 4014 t.scrollTrigger && t.scrollTrigger.revert(); 4015 t.kill(); // don't revert() the timeline because that's duplicating efforts since we already reverted all the tweens 4016 } 4017 } else { 4018 !(t instanceof Tween) && t.revert && t.revert(revert); 4019 } 4020 } 4021 4022 _this4._r.forEach(function (f) { 4023 return f(revert, _this4); 4024 }); 4025 4026 _this4.isReverted = true; 4027 })(); 4028 } else { 4029 this.data.forEach(function (e) { 4030 return e.kill && e.kill(); 4031 }); 4032 } 4033 4034 this.clear(); 4035 4036 if (matchMedia) { 4037 var i = _media.length; 4038 4039 while (i--) { 4040 // previously, we checked _media.indexOf(this), but some frameworks like Vue enforce Proxy objects that make it impossible to get the proper result that way, so we must use a unique ID number instead. 4041 _media[i].id === this.id && _media.splice(i, 1); 4042 } 4043 } 4044 }
vendor: 4,392 bytes, lines 4044-4190
4044; 4045 4046 _proto5.revert = function revert(config) { 4047 this.kill(config || {}); 4048 }; 4049 4050 return Context; 4051}(); 4052 4053var MatchMedia = /*#__PURE__*/function () { 4054 function MatchMedia(scope) { 4055 this.contexts = []; 4056 this.scope = scope; 4057 _context && _context.data.push(this); 4058 } 4059 4060 var _proto6 = MatchMedia.prototype; 4061 4062 _proto6.add = function add(conditions, func, scope) { 4063 _isObject(conditions) || (conditions = { 4064 matches: conditions 4065 }); 4066 var context = new Context(0, scope || this.scope), 4067 cond = context.conditions = {}, 4068 mq, 4069 p, 4070 active; 4071 _context && !context.selector && (context.selector = _context.selector); // in case a context is created inside a context. Like a gsap.matchMedia() that's inside a scoped gsap.context() 4072 4073 this.contexts.push(context); 4074 func = context.add("onMatch", func); 4075 context.queries = conditions; 4076 4077 for (p in conditions) { 4078 if (p === "all") { 4079 active = 1; 4080 } else { 4081 mq = _win.matchMedia(conditions[p]); 4082 4083 if (mq) { 4084 _media.indexOf(context) < 0 && _media.push(context); 4085 (cond[p] = mq.matches) && (active = 1); 4086 mq.addListener ? mq.addListener(_onMediaChange) : mq.addEventListener("change", _onMediaChange); 4087 } 4088 } 4089 } 4090 4091 active && func(context, function (f) { 4092 return context.add(null, f); 4093 }); 4094 return this; 4095 } // refresh() { 4096 // let time = _lastMediaTime, 4097 // media = _media; 4098 // _lastMediaTime = -1; 4099 // _media = this.contexts; 4100 // _onMediaChange(); 4101 // _lastMediaTime = time; 4102 // _media = media; 4103 // } 4104 ; 4105 4106 _proto6.revert = function revert(config) { 4107 this.kill(config || {}); 4108 }; 4109 4110 _proto6.kill = function kill(revert) { 4111 this.contexts.forEach(function (c) { 4112 return c.kill(revert, true); 4113 }); 4114 }; 4115 4116 return MatchMedia; 4117}(); 4118/* 4119 * -------------------------------------------------------------------------------------- 4120 * GSAP 4121 * -------------------------------------------------------------------------------------- 4122 */ 4123 4124 4125var _gsap = { 4126 registerPlugin: function registerPlugin() { 4127 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 4128 args[_key2] = arguments[_key2]; 4129 } 4130 4131 args.forEach(function (config) { 4132 return _createPlugin(config); 4133 }); 4134 }, 4135 timeline: function timeline(vars) { 4136 return new Timeline(vars); 4137 }, 4138 getTweensOf: function getTweensOf(targets, onlyActive) { 4139 return _globalTimeline.getTweensOf(targets, onlyActive); 4140 }, 4141 getProperty: function getProperty(target, property, unit, uncache) { 4142 _isString(target) && (target = toArray(target)[0]); //in case selector text or an array is passed in 4143 4144 var getter = _getCache(target || {}).get, 4145 format = unit ? _passThrough : _numericIfPossible; 4146 4147 unit === "native" && (unit = ""); 4148 return !target ? target : !property ? function (property, unit, uncache) { 4149 return format((_plugins[property] && _plugins[property].get || getter)(target, property, unit, uncache)); 4150 } : format((_plugins[property] && _plugins[property].get || getter)(target, property, unit, uncache)); 4151 }, 4152 quickSetter: function quickSetter(target, property, unit) { 4153 target = toArray(target); 4154 4155 if (target.length > 1) { 4156 var setters = target.map(function (t) { 4157 return gsap.quickSetter(t, property, unit); 4158 }), 4159 l = setters.length; 4160 return function (value) { 4161 var i = l; 4162 4163 while (i--) { 4164 setters[i](value); 4165 } 4166 }; 4167 } 4168 4169 target = target[0] || {}; 4170 4171 var Plugin = _plugins[property], 4172 cache = _getCache(target), 4173 p = cache.harness && (cache.harness.aliases || {})[property] || property, 4174 // in case it's an alias, like "rotate" for "rotation". 4175 setter = Plugin ? function (value) { 4176 var p = new Plugin(); 4177 _quickTween._pt = 0; 4178 p.init(target, unit ? value + unit : value, _quickTween, 0, [target]); 4179 p.render(1, p); 4180 _quickTween._pt && _renderPropTweens(1, _quickTween); 4181 } : cache.set(target, p); 4182 4183 return Plugin ? setter : function (value) { 4184 return setter(target, p, unit ? value + unit : value, cache, 1); 4185 }; 4186 }, 4187 quickTo: function quickTo(target, property, vars) { 4188 var _merge2; 4189 4190 var tween = gsap.to(target, _merge((_merge2 = {}, _merge2[property] = "+=0.1", _merge2.paused = true, _merge
vendor: 5,536 bytes, lines 4190-4394
41902), vars || {})), 4191 func = function func(value, start, startIsRelative) { 4192 return tween.resetTo(property, value, start, startIsRelative); 4193 }; 4194 4195 func.tween = tween; 4196 return func; 4197 }, 4198 isTweening: function isTweening(targets) { 4199 return _globalTimeline.getTweensOf(targets, true).length > 0; 4200 }, 4201 defaults: function defaults(value) { 4202 value && value.ease && (value.ease = _parseEase(value.ease, _defaults.ease)); 4203 return _mergeDeep(_defaults, value || {}); 4204 }, 4205 config: function config(value) { 4206 return _mergeDeep(_config, value || {}); 4207 }, 4208 registerEffect: function registerEffect(_ref3) { 4209 var name = _ref3.name, 4210 effect = _ref3.effect, 4211 plugins = _ref3.plugins, 4212 defaults = _ref3.defaults, 4213 extendTimeline = _ref3.extendTimeline; 4214 (plugins || "").split(",").forEach(function (pluginName) { 4215 return pluginName && !_plugins[pluginName] && !_globals[pluginName] && _warn(name + " effect requires " + pluginName + " plugin."); 4216 }); 4217 4218 _effects[name] = function (targets, vars, tl) { 4219 return effect(toArray(targets), _setDefaults(vars || {}, defaults), tl); 4220 }; 4221 4222 if (extendTimeline) { 4223 Timeline.prototype[name] = function (targets, vars, position) { 4224 return this.add(_effects[name](targets, _isObject(vars) ? vars : (position = vars) && {}, this), position); 4225 }; 4226 } 4227 }, 4228 registerEase: function registerEase(name, ease) { 4229 _easeMap[name] = _parseEase(ease); 4230 }, 4231 parseEase: function parseEase(ease, defaultEase) { 4232 return arguments.length ? _parseEase(ease, defaultEase) : _easeMap; 4233 }, 4234 getById: function getById(id) { 4235 return _globalTimeline.getById(id); 4236 }, 4237 exportRoot: function exportRoot(vars, includeDelayedCalls) { 4238 if (vars === void 0) { 4239 vars = {}; 4240 } 4241 4242 var tl = new Timeline(vars), 4243 child, 4244 next; 4245 tl.smoothChildTiming = _isNotFalse(vars.smoothChildTiming); 4246 4247 _globalTimeline.remove(tl); 4248 4249 tl._dp = 0; //otherwise it'll get re-activated when adding children and be re-introduced into _globalTimeline's linked list (then added to itself). 4250 4251 tl._time = tl._tTime = _globalTimeline._time; 4252 child = _globalTimeline._first; 4253 4254 while (child) { 4255 next = child._next; 4256 4257 if (includeDelayedCalls || !(!child._dur && child instanceof Tween && child.vars.onComplete === child._targets[0])) { 4258 _addToTimeline(tl, child, child._start - child._delay); 4259 } 4260 4261 child = next; 4262 } 4263 4264 _addToTimeline(_globalTimeline, tl, 0); 4265 4266 return tl; 4267 }, 4268 context: function context(func, scope) { 4269 return func ? new Context(func, scope) : _context; 4270 }, 4271 matchMedia: function matchMedia(scope) { 4272 return new MatchMedia(scope); 4273 }, 4274 matchMediaRefresh: function matchMediaRefresh() { 4275 return _media.forEach(function (c) { 4276 var cond = c.conditions, 4277 found, 4278 p; 4279 4280 for (p in cond) { 4281 if (cond[p]) { 4282 cond[p] = false; 4283 found = 1; 4284 } 4285 } 4286 4287 found && c.revert(); 4288 }) || _onMediaChange(); 4289 }, 4290 addEventListener: function addEventListener(type, callback) { 4291 var a = _listeners[type] || (_listeners[type] = []); 4292 ~a.indexOf(callback) || a.push(callback); 4293 }, 4294 removeEventListener: function removeEventListener(type, callback) { 4295 var a = _listeners[type], 4296 i = a && a.indexOf(callback); 4297 i >= 0 && a.splice(i, 1); 4298 }, 4299 utils: { 4300 wrap: wrap, 4301 wrapYoyo: wrapYoyo, 4302 distribute: distribute, 4303 random: random, 4304 snap: snap, 4305 normalize: normalize, 4306 getUnit: getUnit, 4307 clamp: clamp, 4308 splitColor: splitColor, 4309 toArray: toArray, 4310 selector: selector, 4311 mapRange: mapRange, 4312 pipe: pipe, 4313 unitize: unitize, 4314 interpolate: interpolate, 4315 shuffle: shuffle 4316 }, 4317 install: _install, 4318 effects: _effects, 4319 ticker: _ticker, 4320 updateRoot: Timeline.updateRoot, 4321 plugins: _plugins, 4322 globalTimeline: _globalTimeline, 4323 core: { 4324 PropTween: PropTween, 4325 globals: _addGlobal, 4326 Tween: Tween, 4327 Timeline: Timeline, 4328 Animation: Animation, 4329 getCache: _getCache, 4330 _removeLinkedListItem: _removeLinkedListItem, 4331 reverting: function reverting() { 4332 return _reverting; 4333 }, 4334 context: function context(toAdd) { 4335 if (toAdd && _context) { 4336 _context.data.push(toAdd); 4337 4338 toAdd._ctx = _context; 4339 } 4340 4341 return _context; 4342 }, 4343 suppressOverwrites: function suppressOverwrites(value) { 4344 return _suppressOverwrites = value; 4345 } 4346 } 4347}; 4348 4349_forEachName("to,from,fromTo,delayedCall,set,killTweensOf", function (name) { 4350 return _gsap[name] = Tween[name]; 4351}); 4352 4353_ticker.add(Timeline.updateRoot); 4354 4355_quickTween = _gsap.to({}, { 4356 duration: 0 4357}); // ---- EXTRA PLUGINS -------------------------------------------------------- 4358 4359var _getPluginPropTween = function _getPluginPropTween(plugin, prop) { 4360 var pt = plugin._pt; 4361 4362 while (pt && pt.p !== prop && pt.op !== prop && pt.fp !== prop) { 4363 pt = pt._next; 4364 } 4365 4366 return pt; 4367}, 4368 _addModifiers = function _addModifiers(tween, modifiers) { 4369 var targets = tween._targets, 4370 p, 4371 i, 4372 pt; 4373 4374 for (p in modifiers) { 4375 i = targets.length; 4376 4377 while (i--) { 4378 pt = tween._ptLookup[i][p]; 4379 4380 if (pt && (pt = pt.d)) { 4381 if (pt._pt) { 4382 // is a plugin 4383 pt = _getPluginPropTween(pt, p); 4384 } 4385 4386 pt && pt.modifier && pt.modifier(modifiers[p], tween, targets[i], p); 4387 } 4388 } 4389 } 4390}, 4391 _buildModifierPlugin = function _buildModifierPlugin(name, modifier) { 4392 return { 4393 name: name, 4394
vendor: 1,935 bytes, lines 4394-4463
4394rawVars: 1, 4395 //don't pre-process function-based values or "random()" strings. 4396 init: function init(target, vars, tween) { 4397 tween._onInit = function (tween) { 4398 var temp, p; 4399 4400 if (_isString(vars)) { 4401 temp = {}; 4402 4403 _forEachName(vars, function (name) { 4404 return temp[name] = 1; 4405 }); //if the user passes in a comma-delimited list of property names to roundProps, like "x,y", we round to whole numbers. 4406 4407 4408 vars = temp; 4409 } 4410 4411 if (modifier) { 4412 temp = {}; 4413 4414 for (p in vars) { 4415 temp[p] = modifier(vars[p]); 4416 } 4417 4418 vars = temp; 4419 } 4420 4421 _addModifiers(tween, vars); 4422 }; 4423 } 4424 }; 4425}; //register core plugins 4426 4427 4428export var gsap = _gsap.registerPlugin({ 4429 name: "attr", 4430 init: function init(target, vars, tween, index, targets) { 4431 var p, pt, v; 4432 this.tween = tween; 4433 4434 for (p in vars) { 4435 v = target.getAttribute(p) || ""; 4436 pt = this.add(target, "setAttribute", (v || 0) + "", vars[p], index, targets, 0, 0, p); 4437 pt.op = p; 4438 pt.b = v; // record the beginning value so we can revert() 4439 4440 this._props.push(p); 4441 } 4442 }, 4443 render: function render(ratio, data) { 4444 var pt = data._pt; 4445 4446 while (pt) { 4447 _reverting ? pt.set(pt.t, pt.p, pt.b, pt) : pt.r(ratio, pt.d); // if reverting, go back to the original (pt.b) 4448 4449 pt = pt._next; 4450 } 4451 } 4452}, { 4453 name: "endArray", 4454 init: function init(target, value) { 4455 var i = value.length; 4456 4457 while (i--) { 4458 this.add(target, i, target[i] || 0, value[i], 0, 0, 0, 0, 0, 1); 4459 } 4460 } 4461}, _buildModifierPlugin("roundProps", _roundModifier), _buildModifierPlugin("modifiers"), _buildModifierPlugin("snap", snap)) || _gsap; //to prevent the core plugins from being dropped via aggressive tree shaking, we must include them in the variable declaration in this way. 4462 4463Tween.version = Timeline.version = gsap.version = "3.12.5
vendor: 1,478 bytes, lines 4463-4487
4463"; 4464_coreReady = 1; 4465_windowExists() && _wake(); 4466var Power0 = _easeMap.Power0, 4467 Power1 = _easeMap.Power1, 4468 Power2 = _easeMap.Power2, 4469 Power3 = _easeMap.Power3, 4470 Power4 = _easeMap.Power4, 4471 Linear = _easeMap.Linear, 4472 Quad = _easeMap.Quad, 4473 Cubic = _easeMap.Cubic, 4474 Quart = _easeMap.Quart, 4475 Quint = _easeMap.Quint, 4476 Strong = _easeMap.Strong, 4477 Elastic = _easeMap.Elastic, 4478 Back = _easeMap.Back, 4479 SteppedEase = _easeMap.SteppedEase, 4480 Bounce = _easeMap.Bounce, 4481 Sine = _easeMap.Sine, 4482 Expo = _easeMap.Expo, 4483 Circ = _easeMap.Circ; 4484export { Power0, Power1, Power2, Power3, Power4, Linear, Quad, Cubic, Quart, Quint, Strong, Elastic, Back, SteppedEase, Bounce, Sine, Expo, Circ }; 4485export { Tween as TweenMax, Tween as TweenLite, Timeline as TimelineMax, Timeline as TimelineLite, gsap as default, wrap, wrapYoyo, distribute, random, snap, normalize, getUnit, clamp, splitColor, toArray, selector, mapRange, pipe, unitize, interpolate, shuffle }; //export some internal methods/orojects for use in CSSPlugin so that we can externalize that file and allow custom builds that exclude it. 4486 4487export { _getProperty, _numExp, _numWithUnitExp, _isString, _isUndefined, _renderComplexString, _relExp, _setDefaults, _removeLinkedListItem, _forEachName, _sortPropTweensByPriority, _colorStringFilter, _replaceRandom, _checkPlugin, _plugins, _ticker, _config, _roundModifier, _round, _missingPlugin, _getSetter, _getCache, _colorExp, _parseRelative };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.