vendor: 27,243 bytes, lines 1-632
1/******/ (() => { // webpackBootstrap 2/******/ "use strict"; 3/******/ var __webpack_modules__ = ({ 4 5/***/ "./node_modules/gsap/CSSPlugin.js" 6/*!****************************************!*\ 7 !*** ./node_modules/gsap/CSSPlugin.js ***! 8 \****************************************/ 9(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 10 11__webpack_require__.r(__webpack_exports__); 12/* harmony export */ __webpack_require__.d(__webpack_exports__, { 13/* harmony export */ CSSPlugin: () => (/* binding */ CSSPlugin), 14/* harmony export */ _createElement: () => (/* binding */ _createElement), 15/* harmony export */ _getBBox: () => (/* binding */ _getBBox), 16/* harmony export */ checkPrefix: () => (/* binding */ _checkPropPrefix), 17/* harmony export */ "default": () => (/* binding */ CSSPlugin) 18/* harmony export */ }); 19/* harmony import */ var _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./gsap-core.js */ "./node_modules/gsap/gsap-core.js"); 20/*! 21 * CSSPlugin 3.15.0 22 * https://gsap.com 23 * 24 * Copyright 2008-2026, GreenSock. All rights reserved. 25 * Subject to the terms at https://gsap.com/standard-license 26 * @author: Jack Doyle, [email protected] 27*/ 28 29/* eslint-disable */ 30 31 32var _win, 33 _doc, 34 _docElement, 35 _pluginInitted, 36 _tempDiv, 37 _tempDivStyler, 38 _recentSetterPlugin, 39 _reverting, 40 _windowExists = function _windowExists() { 41 return typeof window !== "undefined"; 42}, 43 _transformProps = {}, 44 _RAD2DEG = 180 / Math.PI, 45 _DEG2RAD = Math.PI / 180, 46 _atan2 = Math.atan2, 47 _bigNum = 1e8, 48 _capsExp = /([A-Z])/g, 49 _horizontalExp = /(left|right|width|margin|padding|x)/i, 50 _complexExp = /[\s,\(]\S/, 51 _propertyAliases = { 52 autoAlpha: "opacity,visibility", 53 scale: "scaleX,scaleY", 54 alpha: "opacity" 55}, 56 _renderCSSProp = function _renderCSSProp(ratio, data) { 57 return data.set(data.t, data.p, Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u, data); 58}, 59 _renderPropWithEnd = function _renderPropWithEnd(ratio, data) { 60 return data.set(data.t, data.p, ratio === 1 ? data.e : Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u, data); 61}, 62 _renderCSSPropWithBeginning = function _renderCSSPropWithBeginning(ratio, data) { 63 return data.set(data.t, data.p, ratio ? Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u : data.b, data); 64}, 65 //if units change, we need a way to render the original unit/value when the tween goes all the way back to the beginning (ratio:0) 66_renderCSSPropWithBeginningAndEnd = function _renderCSSPropWithBeginningAndEnd(ratio, data) { 67 return data.set(data.t, data.p, ratio === 1 ? data.e : ratio ? Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u : data.b, data); 68}, 69 //if units change, we need a way to render the original unit/value when the tween goes all the way back to the beginning (ratio:0) 70_renderRoundedCSSProp = function _renderRoundedCSSProp(ratio, data) { 71 var value = data.s + data.c * ratio; 72 data.set(data.t, data.p, ~~(value + (value < 0 ? -.5 : .5)) + data.u, data); 73}, 74 _renderNonTweeningValue = function _renderNonTweeningValue(ratio, data) { 75 return data.set(data.t, data.p, ratio ? data.e : data.b, data); 76}, 77 _renderNonTweeningValueOnlyAtEnd = function _renderNonTweeningValueOnlyAtEnd(ratio, data) { 78 return data.set(data.t, data.p, ratio !== 1 ? data.b : data.e, data); 79}, 80 _setterCSSStyle = function _setterCSSStyle(target, property, value) { 81 return target.style[property] = value; 82}, 83 _setterCSSProp = function _setterCSSProp(target, property, value) { 84 return target.style.setProperty(property, value); 85}, 86 _setterTransform = function _setterTransform(target, property, value) { 87 return target._gsap[property] = value; 88}, 89 _setterScale = function _setterScale(target, property, value) { 90 return target._gsap.scaleX = target._gsap.scaleY = value; 91}, 92 _setterScaleWithRender = function _setterScaleWithRender(target, property, value, data, ratio) { 93 var cache = target._gsap; 94 cache.scaleX = cache.scaleY = value; 95 cache.renderTransform(ratio, cache); 96}, 97 _setterTransformWithRender = function _setterTransformWithRender(target, property, value, data, ratio) { 98 var cache = target._gsap; 99 cache[property] = value; 100 cache.renderTransform(ratio, cache); 101}, 102 _transformProp = "transform", 103 _transformOriginProp = _transformProp + "Origin", 104 _saveStyle = function _saveStyle(property, isNotCSS) { 105 var _this = this; 106 107 var target = this.target, 108 style = target.style, 109 cache = target._gsap; 110 111 if (property in _transformProps && style) { 112 this.tfm = this.tfm || {}; 113 114 if (property !== "transform") { 115 property = _propertyAliases[property] || property; 116 ~property.indexOf(",") ? property.split(",").forEach(function (a) { 117 return _this.tfm[a] = _get(target, a); 118 }) : this.tfm[property] = cache.x ? cache[property] : _get(target, property); // note: scale would map to "scaleX,scaleY", thus we loop and apply them both. 119 120 property === _transformOriginProp && (this.tfm.zOrigin = cache.zOrigin); 121 } else { 122 return _propertyAliases.transform.split(",").forEach(function (p) { 123 return _saveStyle.call(_this, p, isNotCSS); 124 }); 125 } 126 127 if (this.props.indexOf(_transformProp) >= 0) { 128 return; 129 } 130 131 if (cache.svg) { 132 this.svgo = target.getAttribute("data-svg-origin"); 133 this.props.push(_transformOriginProp, isNotCSS, ""); 134 } 135 136 property = _transformProp; 137 } 138 139 (style || isNotCSS) && this.props.push(property, isNotCSS, style[property]); 140}, 141 _removeIndependentTransforms = function _removeIndependentTransforms(style) { 142 if (style.translate) { 143 style.removeProperty("translate"); 144 style.removeProperty("scale"); 145 style.removeProperty("rotate"); 146 } 147}, 148 _revertStyle = function _revertStyle() { 149 var props = this.props, 150 target = this.target, 151 style = target.style, 152 cache = target._gsap, 153 i, 154 p; 155 156 for (i = 0; i < props.length; i += 3) { 157 // stored like this: property, isNotCSS, value 158 if (!props[i + 1]) { 159 props[i + 2] ? style[props[i]] = props[i + 2] : style.removeProperty(props[i].substr(0, 2) === "--" ? props[i] : props[i].replace(_capsExp, "-$1").toLowerCase()); 160 } else if (props[i + 1] === 2) { 161 // non-CSS value (function-based) 162 target[props[i]](props[i + 2]); 163 } else { 164 // non-CSS value (not function-based) 165 target[props[i]] = props[i + 2]; 166 } 167 } 168 169 if (this.tfm) { 170 for (p in this.tfm) { 171 cache[p] = this.tfm[p]; 172 } 173 174 if (cache.svg) { 175 cache.renderTransform(); 176 target.setAttribute("data-svg-origin", this.svgo || ""); 177 } 178 179 i = _reverting(); 180 181 if ((!i || !i.isStart) && !style[_transformProp]) { 182 _removeIndependentTransforms(style); 183 184 if (cache.zOrigin && style[_transformOriginProp]) { 185 style[_transformOriginProp] += " " + cache.zOrigin + "px"; // since we're uncaching, we must put the zOrigin back into the transformOrigin so that we can pull it out accurately when we parse again. Otherwise, we'd lose the z portion of the origin since we extract it to protect from Safari bugs. 186 187 cache.zOrigin = 0; 188 cache.renderTransform(); 189 } 190 191 cache.uncache = 1; // if it's a startAt that's being reverted in the _initTween() of the core, we don't need to uncache transforms. This is purely a performance optimization. 192 } 193 } 194}, 195 _getStyleSaver = function _getStyleSaver(target, properties) { 196 var saver = { 197 target: target, 198 props: [], 199 revert: _revertStyle, 200 save: _saveStyle 201 }; 202 target._gsap || _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.gsap.core.getCache(target); // just make sure there's a _gsap cache defined because we read from it in _saveStyle() and it's more efficient to just check it here once. 203 204 properties && target.style && target.nodeType && properties.split(",").forEach(function (p) { 205 return saver.save(p); 206 }); // make sure it's a DOM node too. 207 208 return saver; 209}, 210 _supports3D, 211 _createElement = function _createElement(type, ns) { 212 var e = _doc.createElementNS ? _doc.createElementNS((ns || "http://www.w3.org/1999/xhtml").replace(/^https/, "http"), type) : _doc.createElement(type); //some servers swap in https for http in the namespace which can break things, making "style" inaccessible. 213 214 return e && e.style ? e : _doc.createElement(type); //some environments won't allow access to the element's style when created with a namespace in which case we default to the standard createElement() to work around the issue. Also note that when GSAP is embedded directly inside an SVG file, createElement() won't allow access to the style object in Firefox (see https://gsap.com/forums/topic/20215-problem-using-tweenmax-in-standalone-self-containing-svg-file-err-cannot-set-property-csstext-of-undefined/). 215}, 216 _getComputedProperty = function _getComputedProperty(target, property, skipPrefixFallback) { 217 var cs = getComputedStyle(target); 218 return cs[property] || cs.getPropertyValue(property.replace(_capsExp, "-$1").toLowerCase()) || cs.getPropertyValue(property) || !skipPrefixFallback && _getComputedProperty(target, _checkPropPrefix(property) || property, 1) || ""; //css variables may not need caps swapped out for dashes and lowercase. 219}, 220 _prefixes = "O,Moz,ms,Ms,Webkit".split(","), 221 _checkPropPrefix = function _checkPropPrefix(property, element, preferPrefix) { 222 var e = element || _tempDiv, 223 s = e.style, 224 i = 5; 225 226 if (property in s && !preferPrefix) { 227 return property; 228 } 229 230 property = property.charAt(0).toUpperCase() + property.substr(1); 231 232 while (i-- && !(_prefixes[i] + property in s)) {} 233 234 return i < 0 ? null : (i === 3 ? "ms" : i >= 0 ? _prefixes[i] : "") + property; 235}, 236 _initCore = function _initCore() { 237 if (_windowExists() && window.document) { 238 _win = window; 239 _doc = _win.document; 240 _docElement = _doc.documentElement; 241 _tempDiv = _createElement("div") || { 242 style: {} 243 }; 244 _tempDivStyler = _createElement("div"); 245 _transformProp = _checkPropPrefix(_transformProp); 246 _transformOriginProp = _transformProp + "Origin"; 247 _tempDiv.style.cssText = "border-width:0;line-height:0;position:absolute;padding:0"; //make sure to override certain properties that may contaminate measurements, in case the user has overreaching style sheets. 248 249 _supports3D = !!_checkPropPrefix("perspective"); 250 _reverting = _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.gsap.core.reverting; 251 _pluginInitted = 1; 252 } 253}, 254 _getReparentedCloneBBox = function _getReparentedCloneBBox(target) { 255 //works around issues in some browsers (like Firefox) that don't correctly report getBBox() on SVG elements inside a <defs> element and/or <mask>. We try creating an SVG, adding it to the documentElement and toss the element in there so that it's definitely part of the rendering tree, then grab the bbox and if it works, we actually swap out the original getBBox() method for our own that does these extra steps whenever getBBox is needed. This helps ensure that performance is optimal (only do all these extra steps when absolutely necessary...most elements don't need it). 256 var owner = target.ownerSVGElement, 257 svg = _createElement("svg", owner && owner.getAttribute("xmlns") || "http://www.w3.org/2000/svg"), 258 clone = target.cloneNode(true), 259 bbox; 260 261 clone.style.display = "block"; 262 svg.appendChild(clone); 263 264 _docElement.appendChild(svg); 265 266 try { 267 bbox = clone.getBBox(); 268 } catch (e) {} 269 270 svg.removeChild(clone); 271 272 _docElement.removeChild(svg); 273 274 return bbox; 275}, 276 _getAttributeFallbacks = function _getAttributeFallbacks(target, attributesArray) { 277 var i = attributesArray.length; 278 279 while (i--) { 280 if (target.hasAttribute(attributesArray[i])) { 281 return target.getAttribute(attributesArray[i]); 282 } 283 } 284}, 285 _getBBox = function _getBBox(target) { 286 var bounds, cloned; 287 288 try { 289 bounds = target.getBBox(); //Firefox throws errors if you try calling getBBox() on an SVG element that's not rendered (like in a <symbol> or <defs>). https://bugzilla.mozilla.org/show_bug.cgi?id=612118 290 } catch (error) { 291 bounds = _getReparentedCloneBBox(target); 292 cloned = 1; 293 } 294 295 bounds && (bounds.width || bounds.height) || cloned || (bounds = _getReparentedCloneBBox(target)); //some browsers (like Firefox) misreport the bounds if the element has zero width and height (it just assumes it's at x:0, y:0), thus we need to manually grab the position in that case. 296 297 return bounds && !bounds.width && !bounds.x && !bounds.y ? { 298 x: +_getAttributeFallbacks(target, ["x", "cx", "x1"]) || 0, 299 y: +_getAttributeFallbacks(target, ["y", "cy", "y1"]) || 0, 300 width: 0, 301 height: 0 302 } : bounds; 303}, 304 _isSVG = function _isSVG(e) { 305 return !!(e.getCTM && (!e.parentNode || e.ownerSVGElement) && _getBBox(e)); 306}, 307 //reports if the element is an SVG on which getBBox() actually works 308_removeProperty = function _removeProperty(target, property) { 309 if (property) { 310 var style = target.style, 311 first2Chars; 312 313 if (property in _transformProps && property !== _transformOriginProp) { 314 property = _transformProp; 315 } 316 317 if (style.removeProperty) { 318 first2Chars = property.substr(0, 2); 319 320 if (first2Chars === "ms" || property.substr(0, 6) === "webkit") { 321 //Microsoft and some Webkit browsers don't conform to the standard of capitalizing the first prefix character, so we adjust so that when we prefix the caps with a dash, it's correct (otherwise it'd be "ms-transform" instead of "-ms-transform" for IE9, for example) 322 property = "-" + property; 323 } 324 325 style.removeProperty(first2Chars === "--" ? property : property.replace(_capsExp, "-$1").toLowerCase()); 326 } else { 327 //note: old versions of IE use "removeAttribute()" instead of "removeProperty()" 328 style.removeAttribute(property); 329 } 330 } 331}, 332 _addNonTweeningPT = function _addNonTweeningPT(plugin, target, property, beginning, end, onlySetAtEnd) { 333 var pt = new _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.PropTween(plugin._pt, target, property, 0, 1, onlySetAtEnd ? _renderNonTweeningValueOnlyAtEnd : _renderNonTweeningValue); 334 plugin._pt = pt; 335 pt.b = beginning; 336 pt.e = end; 337 338 plugin._props.push(property); 339 340 return pt; 341}, 342 _nonConvertibleUnits = { 343 deg: 1, 344 rad: 1, 345 turn: 1 346}, 347 _nonStandardLayouts = { 348 grid: 1, 349 flex: 1 350}, 351 //takes a single value like 20px and converts it to the unit specified, like "%", returning only the numeric amount. 352_convertToUnit = function _convertToUnit(target, property, value, unit) { 353 var curValue = parseFloat(value) || 0, 354 curUnit = (value + "").trim().substr((curValue + "").length) || "px", 355 // some browsers leave extra whitespace at the beginning of CSS variables, hence the need to trim() 356 style = _tempDiv.style, 357 horizontal = _horizontalExp.test(property), 358 isRootSVG = target.tagName.toLowerCase() === "svg", 359 measureProperty = (isRootSVG ? "client" : "offset") + (horizontal ? "Width" : "Height"), 360 amount = 100, 361 toPixels = unit === "px", 362 toPercent = unit === "%", 363 px, 364 parent, 365 cache, 366 isSVG; 367 368 if (unit === curUnit || !curValue || _nonConvertibleUnits[unit] || _nonConvertibleUnits[curUnit]) { 369 return curValue; 370 } 371 372 curUnit !== "px" && !toPixels && (curValue = _convertToUnit(target, property, value, "px")); 373 isSVG = target.getCTM && _isSVG(target); 374 375 if ((toPercent || curUnit === "%") && (_transformProps[property] || ~property.indexOf("adius"))) { 376 px = isSVG ? target.getBBox()[horizontal ? "width" : "height"] : target[measureProperty]; 377 return (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(toPercent ? curValue / px * amount : curValue / 100 * px); 378 } 379 380 style[horizontal ? "width" : "height"] = amount + (toPixels ? curUnit : unit); 381 parent = unit !== "rem" && ~property.indexOf("adius") || unit === "em" && target.appendChild && !isRootSVG ? target : target.parentNode; 382 383 if (isSVG) { 384 parent = (target.ownerSVGElement || {}).parentNode; 385 } 386 387 if (!parent || parent === _doc || !parent.appendChild) { 388 parent = _doc.body; 389 } 390 391 cache = parent._gsap; 392 393 if (cache && toPercent && cache.width && horizontal && cache.time === _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._ticker.time && !cache.uncache) { 394 return (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(curValue / cache.width * amount); 395 } else { 396 if (toPercent && (property === "height" || property === "width")) { 397 // if we're dealing with width/height that's inside a container with padding and/or it's a flexbox/grid container, we must apply it to the target itself rather than the _tempDiv in order to ensure complete accuracy, factoring in the parent's padding. 398 var v = target.style[property]; 399 target.style[property] = amount + unit; 400 px = target[measureProperty]; 401 v ? target.style[property] = v : _removeProperty(target, property); 402 } else { 403 (toPercent || curUnit === "%") && !_nonStandardLayouts[_getComputedProperty(parent, "display")] && (style.position = _getComputedProperty(target, "position")); 404 parent === target && (style.position = "static"); // like for borderRadius, if it's a % we must have it relative to the target itself but that may not have position: relative or position: absolute in which case it'd go up the chain until it finds its offsetParent (bad). position: static protects against that. 405 406 parent.appendChild(_tempDiv); 407 px = _tempDiv[measureProperty]; 408 parent.removeChild(_tempDiv); 409 style.position = "absolute"; 410 } 411 412 if (horizontal && toPercent) { 413 cache = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._getCache)(parent); 414 cache.time = _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._ticker.time; 415 cache.width = parent[measureProperty]; 416 } 417 } 418 419 return (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(toPixels ? px * curValue / amount : px && curValue ? amount / px * curValue : 0); 420}, 421 _get = function _get(target, property, unit, uncache) { 422 var value; 423 _pluginInitted || _initCore(); 424 425 if (property in _propertyAliases && property !== "transform") { 426 property = _propertyAliases[property]; 427 428 if (~property.indexOf(",")) { 429 property = property.split(",")[0]; 430 } 431 } 432 433 if (_transformProps[property] && property !== "transform") { 434 value = _parseTransform(target, uncache); 435 value = property !== "transformOrigin" ? value[property] : value.svg ? value.origin : _firstTwoOnly(_getComputedProperty(target, _transformOriginProp)) + " " + value.zOrigin + "px"; 436 } else { 437 value = target.style[property]; 438 439 if (!value || value === "auto" || uncache || ~(value + "").indexOf("calc(")) { 440 value = _specialProps[property] && _specialProps[property](target, property, unit) || _getComputedProperty(target, property) || (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._getProperty)(target, property) || (property === "opacity" ? 1 : 0); // note: some browsers, like Firefox, don't report borderRadius correctly! Instead, it only reports every corner like borderTopLeftRadius 441 } 442 } 443 444 return unit && !~(value + "").trim().indexOf(" ") ? _convertToUnit(target, property, value, unit) + unit : value; 445}, 446 _tweenComplexCSSString = function _tweenComplexCSSString(target, prop, start, end) { 447 // note: we call _tweenComplexCSSString.call(pluginInstance...) to ensure that it's scoped properly. We may call it from within a plugin too, thus "this" would refer to the plugin. 448 if (!start || start === "none") { 449 // some browsers like Safari actually PREFER the prefixed property and mis-report the unprefixed value like clipPath (BUG). In other words, even though clipPath exists in the style ("clipPath" in target.style) and it's set in the CSS properly (along with -webkit-clip-path), Safari reports clipPath as "none" whereas WebkitClipPath reports accurately like "ellipse(100% 0% at 50% 0%)", so in this case we must SWITCH to using the prefixed property instead. See https://gsap.com/forums/topic/18310-clippath-doesnt-work-on-ios/ 450 var p = _checkPropPrefix(prop, target, 1), 451 s = p && _getComputedProperty(target, p, 1); 452 453 if (s && s !== start) { 454 prop = p; 455 start = s; 456 } else if (prop === "borderColor") { 457 start = _getComputedProperty(target, "borderTopColor"); // Firefox bug: always reports "borderColor" as "", so we must fall back to borderTopColor. See https://gsap.com/forums/topic/24583-how-to-return-colors-that-i-had-after-reverse/ 458 } 459 } 460 461 var pt = new _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.PropTween(this._pt, target.style, prop, 0, 1, _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._renderComplexString), 462 index = 0, 463 matchIndex = 0, 464 a, 465 result, 466 startValues, 467 startNum, 468 color, 469 startValue, 470 endValue, 471 endNum, 472 chunk, 473 endUnit, 474 startUnit, 475 endValues; 476 pt.b = start; 477 pt.e = end; 478 start += ""; // ensure values are strings 479 480 end += ""; 481 482 if (end.substring(0, 6) === "var(--") { 483 end = _getComputedProperty(target, end.substring(4, end.indexOf(")"))); 484 } 485 486 if (end === "auto") { 487 startValue = target.style[prop]; 488 target.style[prop] = end; 489 end = _getComputedProperty(target, prop) || end; 490 startValue ? target.style[prop] = startValue : _removeProperty(target, prop); 491 } 492 493 a = [start, end]; 494 495 (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._colorStringFilter)(a); // pass an array with the starting and ending values and let the filter do whatever it needs to the values. If colors are found, it returns true and then we must match where the color shows up order-wise because for things like boxShadow, sometimes the browser provides the computed values with the color FIRST, but the user provides it with the color LAST, so flip them if necessary. Same for drop-shadow(). 496 497 498 start = a[0]; 499 end = a[1]; 500 startValues = start.match(_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._numWithUnitExp) || []; 501 endValues = end.match(_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._numWithUnitExp) || []; 502 503 if (endValues.length) { 504 while (result = _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._numWithUnitExp.exec(end)) { 505 endValue = result[0]; 506 chunk = end.substring(index, result.index); 507 508 if (color) { 509 color = (color + 1) % 5; 510 } else if (chunk.substr(-5) === "rgba(" || chunk.substr(-5) === "hsla(") { 511 color = 1; 512 } 513 514 if (endValue !== (startValue = startValues[matchIndex++] || "")) { 515 startNum = parseFloat(startValue) || 0; 516 startUnit = startValue.substr((startNum + "").length); 517 endValue.charAt(1) === "=" && (endValue = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._parseRelative)(startNum, endValue) + startUnit); 518 endNum = parseFloat(endValue); 519 endUnit = endValue.substr((endNum + "").length); 520 index = _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._numWithUnitExp.lastIndex - endUnit.length; 521 522 if (!endUnit) { 523 //if something like "perspective:300" is passed in and we must add a unit to the end 524 endUnit = endUnit || _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._config.units[prop] || startUnit; 525 526 if (index === end.length) { 527 end += endUnit; 528 pt.e += endUnit; 529 } 530 } 531 532 if (startUnit !== endUnit) { 533 startNum = _convertToUnit(target, prop, startValue, endUnit) || 0; 534 } // 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. 535 536 537 pt._pt = { 538 _next: pt._pt, 539 p: chunk || matchIndex === 1 ? chunk : ",", 540 //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. 541 s: startNum, 542 c: endNum - startNum, 543 m: color && color < 4 || prop === "zIndex" ? Math.round : 0 544 }; 545 } 546 } 547 548 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) 549 } else { 550 pt.r = prop === "display" && end === "none" ? _renderNonTweeningValueOnlyAtEnd : _renderNonTweeningValue; 551 } 552 553 _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._relExp.test(end) && (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). 554 555 this._pt = pt; //start the linked list with this new PropTween. Remember, we call _tweenComplexCSSString.call(pluginInstance...) to ensure that it's scoped properly. We may call it from within another plugin too, thus "this" would refer to the plugin. 556 557 return pt; 558}, 559 _keywordToPercent = { 560 top: "0%", 561 bottom: "100%", 562 left: "0%", 563 right: "100%", 564 center: "50%" 565}, 566 _convertKeywordsToPercentages = function _convertKeywordsToPercentages(value) { 567 var split = value.split(" "), 568 x = split[0], 569 y = split[1] || "50%"; 570 571 if (x === "top" || x === "bottom" || y === "left" || y === "right") { 572 //the user provided them in the wrong order, so flip them 573 value = x; 574 x = y; 575 y = value; 576 } 577 578 split[0] = _keywordToPercent[x] || x; 579 split[1] = _keywordToPercent[y] || y; 580 return split.join(" "); 581}, 582 _renderClearProps = function _renderClearProps(ratio, data) { 583 if (data.tween && data.tween._time === data.tween._dur) { 584 var target = data.t, 585 style = target.style, 586 props = data.u, 587 cache = target._gsap, 588 prop, 589 clearTransforms, 590 i; 591 592 if (props === "all" || props === true) { 593 style.cssText = ""; 594 clearTransforms = 1; 595 } else { 596 props = props.split(","); 597 i = props.length; 598 599 while (--i > -1) { 600 prop = props[i]; 601 602 if (_transformProps[prop]) { 603 clearTransforms = 1; 604 prop = prop === "transformOrigin" ? _transformOriginProp : _transformProp; 605 } 606 607 _removeProperty(target, prop); 608 } 609 } 610 611 if (clearTransforms) { 612 _removeProperty(target, _transformProp); 613 614 if (cache) { 615 cache.svg && target.removeAttribute("transform"); 616 style.scale = style.rotate = style.translate = "none"; 617 618 _parseTransform(target, 1); // force all the cached values back to "normal"/identity, otherwise if there's another tween that's already set to render transforms on this element, it could display the wrong values. 619 620 621 cache.uncache = 1; 622 623 _removeIndependentTransforms(style); 624 } 625 } 626 } 627}, 628 // note: specialProps should return 1 if (and only if) they have a non-zero priority. It indicates we need to sort the linked list. 629_specialProps = { 630 clearProps: function clearProps(plugin, target, property, endValue, tween) { 631 if (tween.data !== "isFromStart") { 632 var pt = plugin._pt = new _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.
vendor: 3,637 bytes, lines 632-721
632PropTween(plugin._pt, target, property, 0, 0, _renderClearProps); 633 pt.u = endValue; 634 pt.pr = -10; 635 pt.tween = tween; 636 637 plugin._props.push(property); 638 639 return 1; 640 } 641 } 642 /* className feature (about 0.4kb gzipped). 643 , className(plugin, target, property, endValue, tween) { 644 let _renderClassName = (ratio, data) => { 645 data.css.render(ratio, data.css); 646 if (!ratio || ratio === 1) { 647 let inline = data.rmv, 648 target = data.t, 649 p; 650 target.setAttribute("class", ratio ? data.e : data.b); 651 for (p in inline) { 652 _removeProperty(target, p); 653 } 654 } 655 }, 656 _getAllStyles = (target) => { 657 let styles = {}, 658 computed = getComputedStyle(target), 659 p; 660 for (p in computed) { 661 if (isNaN(p) && p !== "cssText" && p !== "length") { 662 styles[p] = computed[p]; 663 } 664 } 665 _setDefaults(styles, _parseTransform(target, 1)); 666 return styles; 667 }, 668 startClassList = target.getAttribute("class"), 669 style = target.style, 670 cssText = style.cssText, 671 cache = target._gsap, 672 classPT = cache.classPT, 673 inlineToRemoveAtEnd = {}, 674 data = {t:target, plugin:plugin, rmv:inlineToRemoveAtEnd, b:startClassList, e:(endValue.charAt(1) !== "=") ? endValue : startClassList.replace(new RegExp("(?:\\s|^)" + endValue.substr(2) + "(?![\\w-])"), "") + ((endValue.charAt(0) === "+") ? " " + endValue.substr(2) : "")}, 675 changingVars = {}, 676 startVars = _getAllStyles(target), 677 transformRelated = /(transform|perspective)/i, 678 endVars, p; 679 if (classPT) { 680 classPT.r(1, classPT.d); 681 _removeLinkedListItem(classPT.d.plugin, classPT, "_pt"); 682 } 683 target.setAttribute("class", data.e); 684 endVars = _getAllStyles(target, true); 685 target.setAttribute("class", startClassList); 686 for (p in endVars) { 687 if (endVars[p] !== startVars[p] && !transformRelated.test(p)) { 688 changingVars[p] = endVars[p]; 689 if (!style[p] && style[p] !== "0") { 690 inlineToRemoveAtEnd[p] = 1; 691 } 692 } 693 } 694 cache.classPT = plugin._pt = new PropTween(plugin._pt, target, "className", 0, 0, _renderClassName, data, 0, -11); 695 if (style.cssText !== cssText) { //only apply if things change. Otherwise, in cases like a background-image that's pulled dynamically, it could cause a refresh. See https://gsap.com/forums/topic/20368-possible-gsap-bug-switching-classnames-in-chrome/. 696 style.cssText = cssText; //we recorded cssText before we swapped classes and ran _getAllStyles() because in cases when a className tween is overwritten, we remove all the related tweening properties from that class change (otherwise class-specific stuff can't override properties we've directly set on the target's style object due to specificity). 697 } 698 _parseTransform(target, true); //to clear the caching of transforms 699 data.css = new gsap.plugins.css(); 700 data.css.init(target, changingVars, tween); 701 plugin._props.push(...data.css._props); 702 return 1; 703 } 704 */ 705 706}, 707 708/* 709 * -------------------------------------------------------------------------------------- 710 * TRANSFORMS 711 * -------------------------------------------------------------------------------------- 712 */ 713_identity2DMatrix = [1, 0, 0, 1, 0, 0], 714 _rotationalProperties = {}, 715 _isNullTransform = function _isNullTransform(value) { 716 return value === "matrix(1, 0, 0, 1, 0, 0)" || value === "none" || !value; 717}, 718 _getComputedTransformMatrixAsArray = function _getComputedTransformMatrixAsArray(target) { 719 var matrixString = _getComputedProperty(target, _transformProp); 720 721 return _isNullTransform(matrixString) ? _identity2DMatrix : matrixString.substr(7).match(_
vendor: 3,835 bytes, lines 721-787
721gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._numExp).map(_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round); 722}, 723 _getMatrix = function _getMatrix(target, force2D) { 724 var cache = target._gsap || (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._getCache)(target), 725 style = target.style, 726 matrix = _getComputedTransformMatrixAsArray(target), 727 parent, 728 nextSibling, 729 temp, 730 addedToDOM; 731 732 if (cache.svg && target.getAttribute("transform")) { 733 temp = target.transform.baseVal.consolidate().matrix; //ensures that even complex values like "translate(50,60) rotate(135,0,0)" are parsed because it mashes it into a matrix. 734 735 matrix = [temp.a, temp.b, temp.c, temp.d, temp.e, temp.f]; 736 return matrix.join(",") === "1,0,0,1,0,0" ? _identity2DMatrix : matrix; 737 } else if (matrix === _identity2DMatrix && !target.offsetParent && target !== _docElement && !cache.svg) { 738 //note: if offsetParent is null, that means the element isn't in the normal document flow, like if it has display:none or one of its ancestors has display:none). Firefox returns null for getComputedStyle() if the element is in an iframe that has display:none. https://bugzilla.mozilla.org/show_bug.cgi?id=548397 739 //browsers don't report transforms accurately unless the element is in the DOM and has a display value that's not "none". Firefox and Microsoft browsers have a partial bug where they'll report transforms even if display:none BUT not any percentage-based values like translate(-50%, 8px) will be reported as if it's translate(0, 8px). 740 temp = style.display; 741 style.display = "block"; 742 parent = target.parentNode; 743 744 if (!parent || !target.offsetParent && !target.getBoundingClientRect().width) { 745 // note: in 3.3.0 we switched target.offsetParent to _doc.body.contains(target) to avoid [sometimes unnecessary] MutationObserver calls but that wasn't adequate because there are edge cases where nested position: fixed elements need to get reparented to accurately sense transforms. See https://github.com/greensock/GSAP/issues/388 and https://github.com/greensock/GSAP/issues/375. Note: position: fixed elements report a null offsetParent but they could also be invisible because they're in an ancestor with display: none, so we check getBoundingClientRect(). We only want to alter the DOM if we absolutely have to because it can cause iframe content to reload, like a Vimeo video. 746 addedToDOM = 1; //flag 747 748 nextSibling = target.nextElementSibling; 749 750 _docElement.appendChild(target); //we must add it to the DOM in order to get values properly 751 752 } 753 754 matrix = _getComputedTransformMatrixAsArray(target); 755 temp ? style.display = temp : _removeProperty(target, "display"); 756 757 if (addedToDOM) { 758 nextSibling ? parent.insertBefore(target, nextSibling) : parent ? parent.appendChild(target) : _docElement.removeChild(target); 759 } 760 } 761 762 return force2D && matrix.length > 6 ? [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]] : matrix; 763}, 764 _applySVGOrigin = function _applySVGOrigin(target, origin, originIsAbsolute, smooth, matrixArray, pluginToAddPropTweensTo) { 765 var cache = target._gsap, 766 matrix = matrixArray || _getMatrix(target, true), 767 xOriginOld = cache.xOrigin || 0, 768 yOriginOld = cache.yOrigin || 0, 769 xOffsetOld = cache.xOffset || 0, 770 yOffsetOld = cache.yOffset || 0, 771 a = matrix[0], 772 b = matrix[1], 773 c = matrix[2], 774 d = matrix[3], 775 tx = matrix[4], 776 ty = matrix[5], 777 originSplit = origin.split(" "), 778 xOrigin = parseFloat(originSplit[0]) || 0, 779 yOrigin = parseFloat(originSplit[1]) || 0, 780 bounds, 781 determinant, 782 x, 783 y; 784 785 if (!originIsAbsolute) { 786 bounds = _getBBox(target); 787 xOrigin = bounds.x + (~originSplit[0].indexOf("%") ? xOrigin / 100 * boun
vendor: 9,144 bytes, lines 787-1028
787ds.width : xOrigin); 788 yOrigin = bounds.y + (~(originSplit[1] || originSplit[0]).indexOf("%") ? yOrigin / 100 * bounds.height : yOrigin); // if (!("xOrigin" in cache) && (xOrigin || yOrigin)) { // added in 3.12.3, reverted in 3.12.4; requires more exploration 789 // xOrigin -= bounds.x; 790 // yOrigin -= bounds.y; 791 // } 792 } else if (matrix !== _identity2DMatrix && (determinant = a * d - b * c)) { 793 //if it's zero (like if scaleX and scaleY are zero), skip it to avoid errors with dividing by zero. 794 x = xOrigin * (d / determinant) + yOrigin * (-c / determinant) + (c * ty - d * tx) / determinant; 795 y = xOrigin * (-b / determinant) + yOrigin * (a / determinant) - (a * ty - b * tx) / determinant; 796 xOrigin = x; 797 yOrigin = y; // theory: we only had to do this for smoothing and it assumes that the previous one was not originIsAbsolute. 798 } 799 800 if (smooth || smooth !== false && cache.smooth) { 801 tx = xOrigin - xOriginOld; 802 ty = yOrigin - yOriginOld; 803 cache.xOffset = xOffsetOld + (tx * a + ty * c) - tx; 804 cache.yOffset = yOffsetOld + (tx * b + ty * d) - ty; 805 } else { 806 cache.xOffset = cache.yOffset = 0; 807 } 808 809 cache.xOrigin = xOrigin; 810 cache.yOrigin = yOrigin; 811 cache.smooth = !!smooth; 812 cache.origin = origin; 813 cache.originIsAbsolute = !!originIsAbsolute; 814 target.style[_transformOriginProp] = "0px 0px"; //otherwise, if someone sets an origin via CSS, it will likely interfere with the SVG transform attribute ones (because remember, we're baking the origin into the matrix() value). 815 816 if (pluginToAddPropTweensTo) { 817 _addNonTweeningPT(pluginToAddPropTweensTo, cache, "xOrigin", xOriginOld, xOrigin); 818 819 _addNonTweeningPT(pluginToAddPropTweensTo, cache, "yOrigin", yOriginOld, yOrigin); 820 821 _addNonTweeningPT(pluginToAddPropTweensTo, cache, "xOffset", xOffsetOld, cache.xOffset); 822 823 _addNonTweeningPT(pluginToAddPropTweensTo, cache, "yOffset", yOffsetOld, cache.yOffset); 824 } 825 826 target.setAttribute("data-svg-origin", xOrigin + " " + yOrigin); 827}, 828 _parseTransform = function _parseTransform(target, uncache) { 829 var cache = target._gsap || new _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.GSCache(target); 830 831 if ("x" in cache && !uncache && !cache.uncache) { 832 return cache; 833 } 834 835 var style = target.style, 836 invertedScaleX = cache.scaleX < 0, 837 px = "px", 838 deg = "deg", 839 cs = getComputedStyle(target), 840 origin = _getComputedProperty(target, _transformOriginProp) || "0", 841 x, 842 y, 843 z, 844 scaleX, 845 scaleY, 846 rotation, 847 rotationX, 848 rotationY, 849 skewX, 850 skewY, 851 perspective, 852 xOrigin, 853 yOrigin, 854 matrix, 855 angle, 856 cos, 857 sin, 858 a, 859 b, 860 c, 861 d, 862 a12, 863 a22, 864 t1, 865 t2, 866 t3, 867 a13, 868 a23, 869 a33, 870 a42, 871 a43, 872 a32; 873 x = y = z = rotation = rotationX = rotationY = skewX = skewY = perspective = 0; 874 scaleX = scaleY = 1; 875 cache.svg = !!(target.getCTM && _isSVG(target)); 876 877 if (cs.translate) { 878 // accommodate independent transforms by combining them into normal ones. 879 if (cs.translate !== "none" || cs.scale !== "none" || cs.rotate !== "none") { 880 style[_transformProp] = (cs.translate !== "none" ? "translate3d(" + (cs.translate + " 0 0").split(" ").slice(0, 3).join(", ") + ") " : "") + (cs.rotate !== "none" ? "rotate(" + cs.rotate + ") " : "") + (cs.scale !== "none" ? "scale(" + cs.scale.split(" ").join(",") + ") " : "") + (cs[_transformProp] !== "none" ? cs[_transformProp] : ""); 881 } 882 883 style.scale = style.rotate = style.translate = "none"; 884 } 885 886 matrix = _getMatrix(target, cache.svg); 887 888 if (cache.svg) { 889 if (cache.uncache) { 890 // if cache.uncache is true (and maybe if origin is 0,0), we need to set element.style.transformOrigin = (cache.xOrigin - bbox.x) + "px " + (cache.yOrigin - bbox.y) + "px". Previously we let the data-svg-origin stay instead, but when introducing revert(), it complicated things. 891 t2 = target.getBBox(); 892 origin = cache.xOrigin - t2.x + "px " + (cache.yOrigin - t2.y) + "px"; 893 t1 = ""; 894 } else { 895 t1 = !uncache && target.getAttribute("data-svg-origin"); // Remember, to work around browser inconsistencies we always force SVG elements' transformOrigin to 0,0 and offset the translation accordingly. 896 } 897 898 _applySVGOrigin(target, t1 || origin, !!t1 || cache.originIsAbsolute, cache.smooth !== false, matrix); 899 } 900 901 xOrigin = cache.xOrigin || 0; 902 yOrigin = cache.yOrigin || 0; 903 904 if (matrix !== _identity2DMatrix) { 905 a = matrix[0]; //a11 906 907 b = matrix[1]; //a21 908 909 c = matrix[2]; //a31 910 911 d = matrix[3]; //a41 912 913 x = a12 = matrix[4]; 914 y = a22 = matrix[5]; //2D matrix 915 916 if (matrix.length === 6) { 917 scaleX = Math.sqrt(a * a + b * b); 918 scaleY = Math.sqrt(d * d + c * c); 919 rotation = a || b ? _atan2(b, a) * _RAD2DEG : 0; //note: if scaleX is 0, we cannot accurately measure rotation. Same for skewX with a scaleY of 0. Therefore, we default to the previously recorded value (or zero if that doesn't exist). 920 921 skewX = c || d ? _atan2(c, d) * _RAD2DEG + rotation : 0; 922 skewX && (scaleY *= Math.abs(Math.cos(skewX * _DEG2RAD))); 923 924 if (cache.svg) { 925 x -= xOrigin - (xOrigin * a + yOrigin * c); 926 y -= yOrigin - (xOrigin * b + yOrigin * d); 927 } //3D matrix 928 929 } else { 930 a32 = matrix[6]; 931 a42 = matrix[7]; 932 a13 = matrix[8]; 933 a23 = matrix[9]; 934 a33 = matrix[10]; 935 a43 = matrix[11]; 936 x = matrix[12]; 937 y = matrix[13]; 938 z = matrix[14]; 939 angle = _atan2(a32, a33); 940 rotationX = angle * _RAD2DEG; //rotationX 941 942 if (angle) { 943 cos = Math.cos(-angle); 944 sin = Math.sin(-angle); 945 t1 = a12 * cos + a13 * sin; 946 t2 = a22 * cos + a23 * sin; 947 t3 = a32 * cos + a33 * sin; 948 a13 = a12 * -sin + a13 * cos; 949 a23 = a22 * -sin + a23 * cos; 950 a33 = a32 * -sin + a33 * cos; 951 a43 = a42 * -sin + a43 * cos; 952 a12 = t1; 953 a22 = t2; 954 a32 = t3; 955 } //rotationY 956 957 958 angle = _atan2(-c, a33); 959 rotationY = angle * _RAD2DEG; 960 961 if (angle) { 962 cos = Math.cos(-angle); 963 sin = Math.sin(-angle); 964 t1 = a * cos - a13 * sin; 965 t2 = b * cos - a23 * sin; 966 t3 = c * cos - a33 * sin; 967 a43 = d * sin + a43 * cos; 968 a = t1; 969 b = t2; 970 c = t3; 971 } //rotationZ 972 973 974 angle = _atan2(b, a); 975 rotation = angle * _RAD2DEG; 976 977 if (angle) { 978 cos = Math.cos(angle); 979 sin = Math.sin(angle); 980 t1 = a * cos + b * sin; 981 t2 = a12 * cos + a22 * sin; 982 b = b * cos - a * sin; 983 a22 = a22 * cos - a12 * sin; 984 a = t1; 985 a12 = t2; 986 } 987 988 if (rotationX && Math.abs(rotationX) + Math.abs(rotation) > 359.9) { 989 //when rotationY is set, it will often be parsed as 180 degrees different than it should be, and rotationX and rotation both being 180 (it looks the same), so we adjust for that here. 990 rotationX = rotation = 0; 991 rotationY = 180 - rotationY; 992 } 993 994 scaleX = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(Math.sqrt(a * a + b * b + c * c)); 995 scaleY = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(Math.sqrt(a22 * a22 + a32 * a32)); 996 angle = _atan2(a12, a22); 997 skewX = Math.abs(angle) > 0.0002 ? angle * _RAD2DEG : 0; 998 perspective = a43 ? 1 / (a43 < 0 ? -a43 : a43) : 0; 999 } 1000 1001 if (cache.svg) { 1002 //sense if there are CSS transforms applied on an SVG element in which case we must overwrite them when rendering. The transform attribute is more reliable cross-browser, but we can't just remove the CSS ones because they may be applied in a CSS rule somewhere (not just inline). 1003 t1 = target.getAttribute("transform"); 1004 cache.forceCSS = target.setAttribute("transform", "") || !_isNullTransform(_getComputedProperty(target, _transformProp)); 1005 t1 && target.setAttribute("transform", t1); 1006 } 1007 } 1008 1009 if (Math.abs(skewX) > 90 && Math.abs(skewX) < 270) { 1010 if (invertedScaleX) { 1011 scaleX *= -1; 1012 skewX += rotation <= 0 ? 180 : -180; 1013 rotation += rotation <= 0 ? 180 : -180; 1014 } else { 1015 scaleY *= -1; 1016 skewX += skewX <= 0 ? 180 : -180; 1017 } 1018 } 1019 1020 uncache = uncache || cache.uncache; 1021 cache.x = x - ((cache.xPercent = x && (!uncache && cache.xPercent || (Math.round(target.offsetWidth / 2) === Math.round(-x) ? -50 : 0))) ? target.offsetWidth * cache.xPercent / 100 : 0) + px; 1022 cache.y = y - ((cache.yPercent = y && (!uncache && cache.yPercent || (Math.round(target.offsetHeight / 2) === Math.round(-y) ? -50 : 0))) ? target.offsetHeight * cache.yPercent / 100 : 0) + px; 1023 cache.z = z + px; 1024 cache.scaleX = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(scaleX); 1025 cache.scaleY = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(scaleY); 1026 cache.rotation = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(rotation) + deg; 1027 cache.rotationX = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(rotationX) + deg; 1028 cache.rotationY = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(rotationY) + deg;
vendor: 1,166 bytes, lines 1029-1053
1029 cache.skewX = skewX + deg; 1030 cache.skewY = skewY + deg; 1031 cache.transformPerspective = perspective + px; 1032 1033 if (cache.zOrigin = parseFloat(origin.split(" ")[2]) || !uncache && cache.zOrigin || 0) { 1034 style[_transformOriginProp] = _firstTwoOnly(origin); 1035 } 1036 1037 cache.xOffset = cache.yOffset = 0; 1038 cache.force3D = _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._config.force3D; 1039 cache.renderTransform = cache.svg ? _renderSVGTransforms : _supports3D ? _renderCSSTransforms : _renderNon3DTransforms; 1040 cache.uncache = 0; 1041 return cache; 1042}, 1043 _firstTwoOnly = function _firstTwoOnly(value) { 1044 return (value = value.split(" "))[0] + " " + value[1]; 1045}, 1046 //for handling transformOrigin values, stripping out the 3rd dimension 1047_addPxTranslate = function _addPxTranslate(target, start, value) { 1048 var unit = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.getUnit)(start); 1049 return (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(parseFloat(start) + parseFloat(_convertToUnit(target, "x", value + "px", unit))) + unit; 1050}, 1051 _renderNon3DTransforms = function _renderNon3DTransforms(ratio, cache) { 1052 cache.z = "0px"; 1053 cache.rotationY = cache.rotationX = "0deg";
vendor: 9,614 bytes, lines 1054-1323
1054 cache.force3D = 0; 1055 1056 _renderCSSTransforms(ratio, cache); 1057}, 1058 _zeroDeg = "0deg", 1059 _zeroPx = "0px", 1060 _endParenthesis = ") ", 1061 _renderCSSTransforms = function _renderCSSTransforms(ratio, cache) { 1062 var _ref = cache || this, 1063 xPercent = _ref.xPercent, 1064 yPercent = _ref.yPercent, 1065 x = _ref.x, 1066 y = _ref.y, 1067 z = _ref.z, 1068 rotation = _ref.rotation, 1069 rotationY = _ref.rotationY, 1070 rotationX = _ref.rotationX, 1071 skewX = _ref.skewX, 1072 skewY = _ref.skewY, 1073 scaleX = _ref.scaleX, 1074 scaleY = _ref.scaleY, 1075 transformPerspective = _ref.transformPerspective, 1076 force3D = _ref.force3D, 1077 target = _ref.target, 1078 zOrigin = _ref.zOrigin, 1079 transforms = "", 1080 use3D = force3D === "auto" && ratio && ratio !== 1 || force3D === true; // Safari has a bug that causes it not to render 3D transform-origin values properly, so we force the z origin to 0, record it in the cache, and then do the math here to offset the translate values accordingly (basically do the 3D transform-origin part manually) 1081 1082 1083 if (zOrigin && (rotationX !== _zeroDeg || rotationY !== _zeroDeg)) { 1084 var angle = parseFloat(rotationY) * _DEG2RAD, 1085 a13 = Math.sin(angle), 1086 a33 = Math.cos(angle), 1087 cos; 1088 1089 angle = parseFloat(rotationX) * _DEG2RAD; 1090 cos = Math.cos(angle); 1091 x = _addPxTranslate(target, x, a13 * cos * -zOrigin); 1092 y = _addPxTranslate(target, y, -Math.sin(angle) * -zOrigin); 1093 z = _addPxTranslate(target, z, a33 * cos * -zOrigin + zOrigin); 1094 } 1095 1096 if (transformPerspective !== _zeroPx) { 1097 transforms += "perspective(" + transformPerspective + _endParenthesis; 1098 } 1099 1100 if (xPercent || yPercent) { 1101 transforms += "translate(" + xPercent + "%, " + yPercent + "%) "; 1102 } 1103 1104 if (use3D || x !== _zeroPx || y !== _zeroPx || z !== _zeroPx) { 1105 transforms += z !== _zeroPx || use3D ? "translate3d(" + x + ", " + y + ", " + z + ") " : "translate(" + x + ", " + y + _endParenthesis; 1106 } 1107 1108 if (rotation !== _zeroDeg) { 1109 transforms += "rotate(" + rotation + _endParenthesis; 1110 } 1111 1112 if (rotationY !== _zeroDeg) { 1113 transforms += "rotateY(" + rotationY + _endParenthesis; 1114 } 1115 1116 if (rotationX !== _zeroDeg) { 1117 transforms += "rotateX(" + rotationX + _endParenthesis; 1118 } 1119 1120 if (skewX !== _zeroDeg || skewY !== _zeroDeg) { 1121 transforms += "skew(" + skewX + ", " + skewY + _endParenthesis; 1122 } 1123 1124 if (scaleX !== 1 || scaleY !== 1) { 1125 transforms += "scale(" + scaleX + ", " + scaleY + _endParenthesis; 1126 } 1127 1128 target.style[_transformProp] = transforms || "translate(0, 0)"; 1129}, 1130 _renderSVGTransforms = function _renderSVGTransforms(ratio, cache) { 1131 var _ref2 = cache || this, 1132 xPercent = _ref2.xPercent, 1133 yPercent = _ref2.yPercent, 1134 x = _ref2.x, 1135 y = _ref2.y, 1136 rotation = _ref2.rotation, 1137 skewX = _ref2.skewX, 1138 skewY = _ref2.skewY, 1139 scaleX = _ref2.scaleX, 1140 scaleY = _ref2.scaleY, 1141 target = _ref2.target, 1142 xOrigin = _ref2.xOrigin, 1143 yOrigin = _ref2.yOrigin, 1144 xOffset = _ref2.xOffset, 1145 yOffset = _ref2.yOffset, 1146 forceCSS = _ref2.forceCSS, 1147 tx = parseFloat(x), 1148 ty = parseFloat(y), 1149 a11, 1150 a21, 1151 a12, 1152 a22, 1153 temp; 1154 1155 rotation = parseFloat(rotation); 1156 skewX = parseFloat(skewX); 1157 skewY = parseFloat(skewY); 1158 1159 if (skewY) { 1160 //for performance reasons, we combine all skewing into the skewX and rotation values. Remember, a skewY of 10 degrees looks the same as a rotation of 10 degrees plus a skewX of 10 degrees. 1161 skewY = parseFloat(skewY); 1162 skewX += skewY; 1163 rotation += skewY; 1164 } 1165 1166 if (rotation || skewX) { 1167 rotation *= _DEG2RAD; 1168 skewX *= _DEG2RAD; 1169 a11 = Math.cos(rotation) * scaleX; 1170 a21 = Math.sin(rotation) * scaleX; 1171 a12 = Math.sin(rotation - skewX) * -scaleY; 1172 a22 = Math.cos(rotation - skewX) * scaleY; 1173 1174 if (skewX) { 1175 skewY *= _DEG2RAD; 1176 temp = Math.tan(skewX - skewY); 1177 temp = Math.sqrt(1 + temp * temp); 1178 a12 *= temp; 1179 a22 *= temp; 1180 1181 if (skewY) { 1182 temp = Math.tan(skewY); 1183 temp = Math.sqrt(1 + temp * temp); 1184 a11 *= temp; 1185 a21 *= temp; 1186 } 1187 } 1188 1189 a11 = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(a11); 1190 a21 = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(a21); 1191 a12 = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(a12); 1192 a22 = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(a22); 1193 } else { 1194 a11 = scaleX; 1195 a22 = scaleY; 1196 a21 = a12 = 0; 1197 } 1198 1199 if (tx && !~(x + "").indexOf("px") || ty && !~(y + "").indexOf("px")) { 1200 tx = _convertToUnit(target, "x", x, "px"); 1201 ty = _convertToUnit(target, "y", y, "px"); 1202 } 1203 1204 if (xOrigin || yOrigin || xOffset || yOffset) { 1205 tx = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(tx + xOrigin - (xOrigin * a11 + yOrigin * a12) + xOffset); 1206 ty = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(ty + yOrigin - (xOrigin * a21 + yOrigin * a22) + yOffset); 1207 } 1208 1209 if (xPercent || yPercent) { 1210 //The SVG spec doesn't support percentage-based translation in the "transform" attribute, so we merge it into the translation to simulate it. 1211 temp = target.getBBox(); 1212 tx = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(tx + xPercent / 100 * temp.width); 1213 ty = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(ty + yPercent / 100 * temp.height); 1214 } 1215 1216 temp = "matrix(" + a11 + "," + a21 + "," + a12 + "," + a22 + "," + tx + "," + ty + ")"; 1217 target.setAttribute("transform", temp); 1218 forceCSS && (target.style[_transformProp] = temp); //some browsers prioritize CSS transforms over the transform attribute. When we sense that the user has CSS transforms applied, we must overwrite them this way (otherwise some browser simply won't render the transform attribute changes!) 1219}, 1220 _addRotationalPropTween = function _addRotationalPropTween(plugin, target, property, startNum, endValue) { 1221 var cap = 360, 1222 isString = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._isString)(endValue), 1223 endNum = parseFloat(endValue) * (isString && ~endValue.indexOf("rad") ? _RAD2DEG : 1), 1224 change = endNum - startNum, 1225 finalValue = startNum + change + "deg", 1226 direction, 1227 pt; 1228 1229 if (isString) { 1230 direction = endValue.split("_")[1]; 1231 1232 if (direction === "short") { 1233 change %= cap; 1234 1235 if (change !== change % (cap / 2)) { 1236 change += change < 0 ? cap : -cap; 1237 } 1238 } 1239 1240 if (direction === "cw" && change < 0) { 1241 change = (change + cap * _bigNum) % cap - ~~(change / cap) * cap; 1242 } else if (direction === "ccw" && change > 0) { 1243 change = (change - cap * _bigNum) % cap - ~~(change / cap) * cap; 1244 } 1245 } 1246 1247 plugin._pt = pt = new _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.PropTween(plugin._pt, target, property, startNum, change, _renderPropWithEnd); 1248 pt.e = finalValue; 1249 pt.u = "deg"; 1250 1251 plugin._props.push(property); 1252 1253 return pt; 1254}, 1255 _assign = function _assign(target, source) { 1256 // Internet Explorer doesn't have Object.assign(), so we recreate it here. 1257 for (var p in source) { 1258 target[p] = source[p]; 1259 } 1260 1261 return target; 1262}, 1263 _addRawTransformPTs = function _addRawTransformPTs(plugin, transforms, target) { 1264 //for handling cases where someone passes in a whole transform string, like transform: "scale(2, 3) rotate(20deg) translateY(30em)" 1265 var startCache = _assign({}, target._gsap), 1266 exclude = "perspective,force3D,transformOrigin,svgOrigin", 1267 style = target.style, 1268 endCache, 1269 p, 1270 startValue, 1271 endValue, 1272 startNum, 1273 endNum, 1274 startUnit, 1275 endUnit; 1276 1277 if (startCache.svg) { 1278 startValue = target.getAttribute("transform"); 1279 target.setAttribute("transform", ""); 1280 style[_transformProp] = transforms; 1281 endCache = _parseTransform(target, 1); 1282 1283 _removeProperty(target, _transformProp); 1284 1285 target.setAttribute("transform", startValue); 1286 } else { 1287 startValue = getComputedStyle(target)[_transformProp]; 1288 style[_transformProp] = transforms; 1289 endCache = _parseTransform(target, 1); 1290 style[_transformProp] = startValue; 1291 } 1292 1293 for (p in _transformProps) { 1294 startValue = startCache[p]; 1295 endValue = endCache[p]; 1296 1297 if (startValue !== endValue && exclude.indexOf(p) < 0) { 1298 //tweening to no perspective gives very unintuitive results - just keep the same perspective in that case. 1299 startUnit = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.getUnit)(startValue); 1300 endUnit = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.getUnit)(endValue); 1301 startNum = startUnit !== endUnit ? _convertToUnit(target, p, startValue, endUnit) : parseFloat(startValue); 1302 endNum = parseFloat(endValue); 1303 plugin._pt = new _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.PropTween(plugin._pt, endCache, p, startNum, endNum - startNum, _renderCSSProp); 1304 plugin._pt.u = endUnit || 0; 1305 1306 plugin._props.push(p); 1307 } 1308 } 1309 1310 _assign(endCache, startCache); 1311}; // handle splitting apart padding, margin, borderWidth, and borderRadius into their 4 components. Firefox, for example, won't report borderRadius correctly - it will only do borderTopLeftRadius and the other corners. We also want to handle paddingTop, marginLeft, borderRightWidth, etc. 1312 1313 1314(0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._forEachName)("padding,margin,Width,Radius", function (name, index) { 1315 var t = "Top", 1316 r = "Right", 1317 b = "Bottom", 1318 l = "Left", 1319 props = (index < 3 ? [t, r, b, l] : [t + l, t + r, b + r, b + l]).map(function (side) { 1320 return index < 2 ? name + side : "border" + side + name; 1321 }); 1322 1323 _specialProps[index >
1323 1 ? "border" + name : name] = function (plugin, target, property, endValue, tween) { 1324 var a, vars; 1325 1326 if (arguments.length < 4) { 1327 // getter, passed target, property, and unit (from _get()) 1328 a = props.map(function (prop) { 1329 return _get(plugin, prop, property); 1330 }); 1331 vars = a.join(" "); 1332 return vars.split(a[0]).length === 5 ? a[0] : vars; 1333 } 1334 1335 a = (endValue + "").split(" "); 1336 vars = {}; 1337 props.forEach(function (prop, i) { 1338 return vars[prop] = a[i] = a[i] || a[(i - 1) / 2 | 0]; 1339 }); 1340 plugin.init(target, vars, tween); 1341 }; 1342}); 1343 1344var CSSPlugin = { 1345 name: "css", 1346 register: _initCore, 1347 targetTest: function targetTest(target) { 1348 return target.style && target.nodeType; 1349 }, 1350 init: function init(target, vars, tween, index, targets) { 1351 var props = this._props, 1352 style = target.style, 1353 startAt = tween.vars.startAt, 1354 startValue, 1355 endValue, 1356 endNum, 1357 startNum, 1358 type, 1359 specialProp, 1360 p, 1361 startUnit, 1362 endUnit, 1363 relative, 1364 isTransformRelated, 1365 transformPropTween, 1366 cache, 1367 smooth, 1368 hasPriority, 1369 inlineProps, 1370 finalTransformValue; 1371 _pluginInitted || _initCore(); // we may call init() multiple times on the same plugin instance, like when adding special properties, so make sure we don't overwrite the revert data or inlineProps 1372 1373 this.styles = this.styles || _getStyleSaver(target); 1374 inlineProps = this.styles.props; 1375 this.tween = tween; 1376 1377 for (p in vars) { 1378 if (p === "autoRound") { 1379 continue; 1380 } 1381 1382 endValue = vars[p]; 1383 1384 if (_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._plugins[p] && (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._checkPlugin)(p, vars, tween, index, target, targets)) { 1385 // plugins 1386 continue; 1387 } 1388 1389 type = typeof endValue; 1390 specialProp = _specialProps[p]; 1391 1392 if (type === "function") { 1393 endValue = endValue.call(tween, index, target, targets); 1394 type = typeof endValue; 1395 } 1396 1397 if (type === "string" && ~endValue.indexOf("random(")) { 1398 endValue = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._replaceRandom)(endValue); 1399 } 1400 1401 if (specialProp) { 1402 specialProp(this, target, p, endValue, tween) && (hasPriority = 1); 1403 } else if (p.substr(0, 2) === "--") { 1404 //CSS variable 1405 startValue = (getComputedStyle(target).getPropertyValue(p) + "").trim(); 1406 endValue += ""; 1407 _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._colorExp.lastIndex = 0; 1408 1409 if (!_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._colorExp.test(startValue)) { 1410 // colors don't have units 1411 startUnit = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.getUnit)(startValue); 1412 endUnit = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.getUnit)(endValue); 1413 endUnit ? startUnit !== endUnit && (startValue = _convertToUnit(target, p, startValue, endUnit) + endUnit) : startUnit && (endValue += startUnit); 1414 } 1415 1416 this.add(style, "setProperty", startValue, endValue, index, targets, 0, 0, p); 1417 props.push(p); 1418 inlineProps.push(p, 0, style[p]); 1419 } else if (type !== "undefined") { 1420 if (startAt && p in startAt) { 1421 // in case someone hard-codes a complex value as the start, like top: "calc(2vh / 2)". Without this, it'd use the computed value (always in px) 1422 startValue = typeof startAt[p] === "function" ? startAt[p].call(tween, index, target, targets) : startAt[p]; 1423 (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._isString)(startValue) && ~startValue.indexOf("random(") && (startValue = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._replaceRandom)(startValue)); 1424 (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.getUnit)(startValue + "") || startValue === "auto" || (startValue += _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._config.units[p] || (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.getUnit)(_get(target, p)) || ""); // for cases when someone passes in a unitless value like {x: 100}; if we try setting translate(100, 0px) it won't work. 1425 1426 (startValue + "").charAt(1) === "=" && (startValue = _get(target, p)); // can't work with relative values 1427 } else { 1428 startValue = _get(target, p); 1429 } 1430 1431 startNum = parseFloat(startValue); 1432 relative = type === "string" && endValue.charAt(1) === "=" && endValue.substr(0, 2); 1433 relative && (endValue = endValue.substr(2)); 1434 endNum = parseFloat(endValue); 1435 1436 if (p in _propertyAliases) { 1437 if (p === "autoAlpha") { 1438 //special case where we control the visibility along with opacity. We still allow the opacity value to pass through and get tweened. 1439 if (startNum === 1 && _get(target, "visibility") === "hidden" && endNum) { 1440 //if visibility is initially set to "hidden", we should interpret that as intent to make opacity 0 (a convenience) 1441 startNum = 0; 1442 } 1443 1444 inlineProps.push("visibility", 0, style.visibility); 1445 1446 _addNonTweeningPT(this, style, "visibility", startNum ? "inherit" : "hidden", endNum ? "inherit" : "hidden", !endNum); 1447 } 1448 1449 if (p !== "scale" && p !== "transform") { 1450 p = _propertyAliases[p]; 1451 ~p.indexOf(",") && (p = p.split(",")[0]); 1452 } 1453 } 1454
vendor: 4,710 bytes, lines 1455-1534
1455 isTransformRelated = p in _transformProps; //--- TRANSFORM-RELATED --- 1456 1457 if (isTransformRelated) { 1458 this.styles.save(p); 1459 finalTransformValue = endValue; // this is always the same as endValue except when it's a var(--) value, in which case we need to calculate the end value. 1460 1461 if (type === "string" && endValue.substring(0, 6) === "var(--") { 1462 endValue = _getComputedProperty(target, endValue.substring(4, endValue.indexOf(")"))); 1463 1464 if (endValue.substring(0, 5) === "calc(") { 1465 var origPerspective = target.style.perspective; 1466 target.style.perspective = endValue; 1467 endValue = _getComputedProperty(target, "perspective"); 1468 origPerspective ? target.style.perspective = origPerspective : _removeProperty(target, "perspective"); 1469 } 1470 1471 endNum = parseFloat(endValue); 1472 } 1473 1474 if (!transformPropTween) { 1475 cache = target._gsap; 1476 cache.renderTransform && !vars.parseTransform || _parseTransform(target, vars.parseTransform); // if, for example, gsap.set(... {transform:"translateX(50vw)"}), the _get() call doesn't parse the transform, thus cache.renderTransform won't be set yet so force the parsing of the transform here. 1477 1478 smooth = vars.smoothOrigin !== false && cache.smooth; 1479 transformPropTween = this._pt = new _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.PropTween(this._pt, style, _transformProp, 0, 1, cache.renderTransform, cache, 0, -1); //the first time through, create the rendering PropTween so that it runs LAST (in the linked list, we keep adding to the beginning) 1480 1481 transformPropTween.dep = 1; //flag it as dependent so that if things get killed/overwritten and this is the only PropTween left, we can safely kill the whole tween. 1482 } 1483 1484 if (p === "scale") { 1485 this._pt = new _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.PropTween(this._pt, cache, "scaleY", cache.scaleY, (relative ? (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._parseRelative)(cache.scaleY, relative + endNum) : endNum) - cache.scaleY || 0, _renderCSSProp); 1486 this._pt.u = 0; 1487 props.push("scaleY", p); 1488 p += "X"; 1489 } else if (p === "transformOrigin") { 1490 inlineProps.push(_transformOriginProp, 0, style[_transformOriginProp]); 1491 endValue = _convertKeywordsToPercentages(endValue); //in case something like "left top" or "bottom right" is passed in. Convert to percentages. 1492 1493 if (cache.svg) { 1494 _applySVGOrigin(target, endValue, 0, smooth, 0, this); 1495 } else { 1496 endUnit = parseFloat(endValue.split(" ")[2]) || 0; //handle the zOrigin separately! 1497 1498 endUnit !== cache.zOrigin && _addNonTweeningPT(this, cache, "zOrigin", cache.zOrigin, endUnit); 1499 1500 _addNonTweeningPT(this, style, p, _firstTwoOnly(startValue), _firstTwoOnly(endValue)); 1501 } 1502 1503 continue; 1504 } else if (p === "svgOrigin") { 1505 _applySVGOrigin(target, endValue, 1, smooth, 0, this); 1506 1507 continue; 1508 } else if (p in _rotationalProperties) { 1509 _addRotationalPropTween(this, cache, p, startNum, relative ? (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._parseRelative)(startNum, relative + endValue) : endValue); 1510 1511 continue; 1512 } else if (p === "smoothOrigin") { 1513 _addNonTweeningPT(this, cache, "smooth", cache.smooth, endValue); 1514 1515 continue; 1516 } else if (p === "force3D") { 1517 cache[p] = endValue; 1518 continue; 1519 } else if (p === "transform") { 1520 _addRawTransformPTs(this, endValue, target); 1521 1522 continue; 1523 } 1524 } else if (!(p in style)) { 1525 p = _checkPropPrefix(p) || p; 1526 } 1527 1528 if (isTransformRelated || (endNum || endNum === 0) && (startNum || startNum === 0) && !_complexExp.test(endValue) && p in style) { 1529 startUnit = (startValue + "").substr((startNum + "").length); 1530 endNum || (endNum = 0); // protect against NaN 1531 1532 endUnit = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.getUnit)(endValue) || (p in _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._config.units ? _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._config.units[p] : startUnit); 1533 startUnit !== endUnit && (startNum = _convertToUnit(target, p, startValue, endUnit)); 1534 this._pt = new _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.PropTween(this._pt, isTransformRelated ? cache : style, p, startNum, (relative ? (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._parseRelative)(startNum, relative + endNum) : endNum) - startNum,
vendor: 9,404 bytes, lines 1534-1757
1534!isTransformRelated && (endUnit === "px" || p === "zIndex") && vars.autoRound !== false ? _renderRoundedCSSProp : _renderCSSProp); 1535 this._pt.u = endUnit || 0; 1536 1537 if (isTransformRelated && finalTransformValue !== endValue) { 1538 this._pt.b = startValue; 1539 this._pt.e = finalTransformValue; 1540 this._pt.r = _renderCSSPropWithBeginningAndEnd; 1541 } else if (startUnit !== endUnit && endUnit !== "%") { 1542 //when the tween goes all the way back to the beginning, we need to revert it to the OLD/ORIGINAL value (with those units). We record that as a "b" (beginning) property and point to a render method that handles that. (performance optimization) 1543 this._pt.b = startValue; 1544 this._pt.r = _renderCSSPropWithBeginning; 1545 } 1546 } else if (!(p in style)) { 1547 if (p in target) { 1548 //maybe it's not a style - it could be a property added directly to an element in which case we'll try to animate that. 1549 this.add(target, p, startValue || target[p], relative ? relative + endValue : endValue, index, targets); 1550 } else if (p !== "parseTransform") { 1551 (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._missingPlugin)(p, endValue); 1552 1553 continue; 1554 } 1555 } else { 1556 _tweenComplexCSSString.call(this, target, p, startValue, relative ? relative + endValue : endValue); 1557 } 1558 1559 isTransformRelated || (p in style ? inlineProps.push(p, 0, style[p]) : typeof target[p] === "function" ? inlineProps.push(p, 2, target[p]()) : inlineProps.push(p, 1, startValue || target[p])); 1560 props.push(p); 1561 } 1562 } 1563 1564 hasPriority && (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._sortPropTweensByPriority)(this); 1565 }, 1566 render: function render(ratio, data) { 1567 if (data.tween._time || !_reverting()) { 1568 var pt = data._pt; 1569 1570 while (pt) { 1571 pt.r(ratio, pt.d); 1572 pt = pt._next; 1573 } 1574 } else { 1575 data.styles.revert(); 1576 } 1577 }, 1578 get: _get, 1579 aliases: _propertyAliases, 1580 getSetter: function getSetter(target, property, plugin) { 1581 //returns a setter function that accepts target, property, value and applies it accordingly. Remember, properties like "x" aren't as simple as target.style.property = value because they've got to be applied to a proxy object and then merged into a transform string in a renderer. 1582 var p = _propertyAliases[property]; 1583 p && p.indexOf(",") < 0 && (property = p); 1584 return property in _transformProps && property !== _transformOriginProp && (target._gsap.x || _get(target, "x")) ? plugin && _recentSetterPlugin === plugin ? property === "scale" ? _setterScale : _setterTransform : (_recentSetterPlugin = plugin || {}) && (property === "scale" ? _setterScaleWithRender : _setterTransformWithRender) : target.style && !(0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._isUndefined)(target.style[property]) ? _setterCSSStyle : ~property.indexOf("-") ? _setterCSSProp : (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._getSetter)(target, property); 1585 }, 1586 core: { 1587 _removeProperty: _removeProperty, 1588 _getMatrix: _getMatrix 1589 } 1590}; 1591_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.gsap.utils.checkPrefix = _checkPropPrefix; 1592_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.gsap.core.getStyleSaver = _getStyleSaver; 1593 1594(function (positionAndScale, rotation, others, aliases) { 1595 var all = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._forEachName)(positionAndScale + "," + rotation + "," + others, function (name) { 1596 _transformProps[name] = 1; 1597 }); 1598 1599 (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._forEachName)(rotation, function (name) { 1600 _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._config.units[name] = "deg"; 1601 _rotationalProperties[name] = 1; 1602 }); 1603 1604 _propertyAliases[all[13]] = positionAndScale + "," + rotation; 1605 1606 (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._forEachName)(aliases, function (name) { 1607 var split = name.split(":"); 1608 _propertyAliases[split[1]] = all[split[0]]; 1609 }); 1610})("x,y,z,scale,scaleX,scaleY,xPercent,yPercent", "rotation,rotationX,rotationY,skewX,skewY", "transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective", "0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY"); 1611 1612(0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._forEachName)("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective", function (name) { 1613 _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._config.units[name] = "px"; 1614}); 1615 1616_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.gsap.registerPlugin(CSSPlugin); 1617 1618 1619/***/ }, 1620 1621/***/ "./node_modules/gsap/ScrollToPlugin.js" 1622/*!*********************************************!*\ 1623 !*** ./node_modules/gsap/ScrollToPlugin.js ***! 1624 \*********************************************/ 1625(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 1626 1627__webpack_require__.r(__webpack_exports__); 1628/* harmony export */ __webpack_require__.d(__webpack_exports__, { 1629/* harmony export */ ScrollToPlugin: () => (/* binding */ ScrollToPlugin), 1630/* harmony export */ "default": () => (/* binding */ ScrollToPlugin) 1631/* harmony export */ }); 1632/*! 1633 * ScrollToPlugin 3.15.0 1634 * https://gsap.com 1635 * 1636 * @license Copyright 2008-2026, GreenSock. All rights reserved. 1637 * Subject to the terms at https://gsap.com/standard-license 1638 * @author: Jack Doyle, [email protected] 1639*/ 1640 1641/* eslint-disable */ 1642var gsap, 1643 _coreInitted, 1644 _window, 1645 _docEl, 1646 _body, 1647 _toArray, 1648 _config, 1649 ScrollTrigger, 1650 _windowExists = function _windowExists() { 1651 return typeof window !== "undefined"; 1652}, 1653 _getGSAP = function _getGSAP() { 1654 return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap; 1655}, 1656 _isString = function _isString(value) { 1657 return typeof value === "string"; 1658}, 1659 _isFunction = function _isFunction(value) { 1660 return typeof value === "function"; 1661}, 1662 _max = function _max(element, axis) { 1663 var dim = axis === "x" ? "Width" : "Height", 1664 scroll = "scroll" + dim, 1665 client = "client" + dim; 1666 return element === _window || element === _docEl || element === _body ? Math.max(_docEl[scroll], _body[scroll]) - (_window["inner" + dim] || _docEl[client] || _body[client]) : element[scroll] - element["offset" + dim]; 1667}, 1668 _buildGetter = function _buildGetter(e, axis) { 1669 //pass in an element and an axis ("x" or "y") and it'll return a getter function for the scroll position of that element (like scrollTop or scrollLeft, although if the element is the window, it'll use the pageXOffset/pageYOffset or the documentElement's scrollTop/scrollLeft or document.body's. Basically this streamlines things and makes a very fast getter across browsers. 1670 var p = "scroll" + (axis === "x" ? "Left" : "Top"); 1671 1672 if (e === _window) { 1673 if (e.pageXOffset != null) { 1674 p = "page" + axis.toUpperCase() + "Offset"; 1675 } else { 1676 e = _docEl[p] != null ? _docEl : _body; 1677 } 1678 } 1679 1680 return function () { 1681 return e[p]; 1682 }; 1683}, 1684 _clean = function _clean(value, index, target, targets) { 1685 _isFunction(value) && (value = value(index, target, targets)); 1686 1687 if (typeof value !== "object") { 1688 return _isString(value) && value !== "max" && value.charAt(1) !== "=" ? { 1689 x: value, 1690 y: value 1691 } : { 1692 y: value 1693 }; //if we don't receive an object as the parameter, assume the user intends "y". 1694 } else if (value.nodeType) { 1695 return { 1696 y: value, 1697 x: value 1698 }; 1699 } else { 1700 var result = {}, 1701 p; 1702 1703 for (p in value) { 1704 result[p] = p !== "onAutoKill" && _isFunction(value[p]) ? value[p](index, target, targets) : value[p]; 1705 } 1706 1707 return result; 1708 } 1709}, 1710 _getOffset = function _getOffset(element, container) { 1711 element = _toArray(element)[0]; 1712 1713 if (!element || !element.getBoundingClientRect) { 1714 return console.warn("scrollTo target doesn't exist. Using 0") || { 1715 x: 0, 1716 y: 0 1717 }; 1718 } 1719 1720 var rect = element.getBoundingClientRect(), 1721 isRoot = !container || container === _window || container === _body, 1722 cRect = isRoot ? { 1723 top: _docEl.clientTop - (_window.pageYOffset || _docEl.scrollTop || _body.scrollTop || 0), 1724 left: _docEl.clientLeft - (_window.pageXOffset || _docEl.scrollLeft || _body.scrollLeft || 0) 1725 } : container.getBoundingClientRect(), 1726 offsets = { 1727 x: rect.left - cRect.left, 1728 y: rect.top - cRect.top 1729 }; 1730 1731 if (!isRoot && container) { 1732 //only add the current scroll position if it's not the window/body. 1733 offsets.x += _buildGetter(container, "x")(); 1734 offsets.y += _buildGetter(container, "y")(); 1735 } 1736 1737 return offsets; 1738}, 1739 _parseVal = function _parseVal(value, target, axis, currentVal, offset) { 1740 return !isNaN(value) && typeof value !== "object" ? parseFloat(value) - offset : _isString(value) && value.charAt(1) === "=" ? parseFloat(value.substr(2)) * (value.charAt(0) === "-" ? -1 : 1) + currentVal - offset : value === "max" ? _max(target, axis) - offset : Math.min(_max(target, axis), _getOffset(value, target)[axis] - offset); 1741}, 1742 _initCore = function _initCore() { 1743 gsap = _getGSAP(); 1744 1745 if (_windowExists() && gsap && typeof document !== "undefined" && document.body) { 1746 _window = window; 1747 _body = document.body; 1748 _docEl = document.documentElement; 1749 _toArray = gsap.utils.toArray; 1750 gsap.config({ 1751 autoKillThreshold: 7 1752 }); 1753 _config = gsap.config(); 1754 _coreInitted = 1; 1755 } 1756}; 1757
vendor: 4,822 bytes, lines 1758-1911
1758var ScrollToPlugin = { 1759 version: "3.15.0", 1760 name: "scrollTo", 1761 rawVars: 1, 1762 register: function register(core) { 1763 gsap = core; 1764 1765 _initCore(); 1766 }, 1767 init: function init(target, value, tween, index, targets) { 1768 _coreInitted || _initCore(); 1769 var data = this, 1770 snapType = gsap.getProperty(target, "scrollSnapType"); 1771 data.isWin = target === _window; 1772 data.target = target; 1773 data.tween = tween; 1774 value = _clean(value, index, target, targets); 1775 data.vars = value; 1776 data.autoKill = !!("autoKill" in value ? value : _config).autoKill; 1777 data.getX = _buildGetter(target, "x"); 1778 data.getY = _buildGetter(target, "y"); 1779 data.x = data.xPrev = data.getX(); 1780 data.y = data.yPrev = data.getY(); 1781 ScrollTrigger || (ScrollTrigger = gsap.core.globals().ScrollTrigger); 1782 gsap.getProperty(target, "scrollBehavior") === "smooth" && gsap.set(target, { 1783 scrollBehavior: "auto" 1784 }); 1785 1786 if (snapType && snapType !== "none") { 1787 // disable scroll snapping to avoid strange behavior 1788 data.snap = 1; 1789 data.snapInline = target.style.scrollSnapType; 1790 target.style.scrollSnapType = "none"; 1791 } 1792 1793 if (value.x != null) { 1794 data.add(data, "x", data.x, _parseVal(value.x, target, "x", data.x, value.offsetX || 0), index, targets); 1795 1796 data._props.push("scrollTo_x"); 1797 } else { 1798 data.skipX = 1; 1799 } 1800 1801 if (value.y != null) { 1802 data.add(data, "y", data.y, _parseVal(value.y, target, "y", data.y, value.offsetY || 0), index, targets); 1803 1804 data._props.push("scrollTo_y"); 1805 } else { 1806 data.skipY = 1; 1807 } 1808 }, 1809 render: function render(ratio, data) { 1810 var pt = data._pt, 1811 target = data.target, 1812 tween = data.tween, 1813 autoKill = data.autoKill, 1814 xPrev = data.xPrev, 1815 yPrev = data.yPrev, 1816 isWin = data.isWin, 1817 snap = data.snap, 1818 snapInline = data.snapInline, 1819 x, 1820 y, 1821 yDif, 1822 xDif, 1823 threshold; 1824 1825 while (pt) { 1826 pt.r(ratio, pt.d); 1827 pt = pt._next; 1828 } 1829 1830 x = isWin || !data.skipX ? data.getX() : xPrev; 1831 y = isWin || !data.skipY ? data.getY() : yPrev; 1832 yDif = y - yPrev; 1833 xDif = x - xPrev; 1834 threshold = _config.autoKillThreshold; 1835 1836 if (data.x < 0) { 1837 //can't scroll to a position less than 0! Might happen if someone uses a Back.easeOut or Elastic.easeOut when scrolling back to the top of the page (for example) 1838 data.x = 0; 1839 } 1840 1841 if (data.y < 0) { 1842 data.y = 0; 1843 } 1844 1845 if (autoKill) { 1846 //note: iOS has a bug that throws off the scroll by several pixels, so we need to check if it's within 7 pixels of the previous one that we set instead of just looking for an exact match. 1847 if (!data.skipX && (xDif > threshold || xDif < -threshold) && x < _max(target, "x")) { 1848 data.skipX = 1; //if the user scrolls separately, we should stop tweening! 1849 } 1850 1851 if (!data.skipY && (yDif > threshold || yDif < -threshold) && y < _max(target, "y")) { 1852 data.skipY = 1; //if the user scrolls separately, we should stop tweening! 1853 } 1854 1855 if (data.skipX && data.skipY) { 1856 tween.kill(); 1857 data.vars.onAutoKill && data.vars.onAutoKill.apply(tween, data.vars.onAutoKillParams || []); 1858 } 1859 } 1860 1861 if (isWin) { 1862 _window.scrollTo(!data.skipX ? data.x : x, !data.skipY ? data.y : y); 1863 } else { 1864 data.skipY || (target.scrollTop = data.y); 1865 data.skipX || (target.scrollLeft = data.x); 1866 } 1867 1868 if (snap && (ratio === 1 || ratio === 0)) { 1869 y = target.scrollTop; 1870 x = target.scrollLeft; 1871 snapInline ? target.style.scrollSnapType = snapInline : target.style.removeProperty("scroll-snap-type"); 1872 target.scrollTop = y + 1; // bug in Safari causes the element to totally reset its scroll position when scroll-snap-type changes, so we need to set it to a slightly different value and then back again to work around this bug. 1873 1874 target.scrollLeft = x + 1; 1875 target.scrollTop = y; 1876 target.scrollLeft = x; 1877 } 1878 1879 data.xPrev = data.x; 1880 data.yPrev = data.y; 1881 ScrollTrigger && ScrollTrigger.update(); 1882 }, 1883 kill: function kill(property) { 1884 var both = property === "scrollTo", 1885 i = this._props.indexOf(property); 1886 1887 if (both || property === "scrollTo_x") { 1888 this.skipX = 1; 1889 } 1890 1891 if (both || property === "scrollTo_y") { 1892 this.skipY = 1; 1893 } 1894 1895 i > -1 && this._props.splice(i, 1); 1896 return !this._props.length; 1897 } 1898}; 1899ScrollToPlugin.max = _max; 1900ScrollToPlugin.getOffset = _getOffset; 1901ScrollToPlugin.buildGetter = _buildGetter; 1902 1903ScrollToPlugin.config = function (vars) { 1904 _config || _initCore() || (_config = gsap.config()); // in case the window hasn't been defined yet. 1905 1906 for (var p in vars) { 1907 _config[p] = vars[p]; 1908 } 1909}; 1910 1911_getGSAP() && gsap.registerPlugin(ScrollToPlugin);
1912 1913 1914/***/ }, 1915 1916/***/ "./node_modules/gsap/gsap-core.js" 1917/*!****************************************!*\ 1918 !*** ./node_modules/gsap/gsap-core.js ***! 1919 \****************************************/ 1920(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 1921 1922__webpack_require__.r(__webpack_exports__); 1923/* harmony export */ __webpack_require__.d(__webpack_exports__, { 1924/* harmony export */ Animation: () => (/* binding */ Animation), 1925/* harmony export */ Back: () => (/* binding */ Back), 1926/* harmony export */ Bounce: () => (/* binding */ Bounce), 1927/* harmony export */ Circ: () => (/* binding */ Circ), 1928/* harmony export */ Cubic: () => (/* binding */ Cubic), 1929/* harmony export */ Elastic: () => (/* binding */ Elastic), 1930/* harmony export */ Expo: () => (/* binding */ Expo), 1931/* harmony export */ GSCache: () => (/* binding */ GSCache), 1932/* harmony export */ Linear: () => (/* binding */ Linear), 1933/* harmony export */ Power0: () => (/* binding */ Power0), 1934/* harmony export */ Power1: () => (/* binding */ Power1), 1935/* harmony export */ Power2: () => (/* binding */ Power2), 1936/* harmony export */ Power3: () => (/* binding */ Power3), 1937/* harmony export */ Power4: () => (/* binding */ Power4), 1938/* harmony export */ PropTween: () => (/* binding */ PropTween), 1939/* harmony export */ Quad: () => (/* binding */ Quad), 1940/* harmony export */ Quart: () => (/* binding */ Quart), 1941/* harmony export */ Quint: () => (/* binding */ Quint), 1942/* harmony export */ Sine: () => (/* binding */ Sine), 1943/* harmony export */ SteppedEase: () => (/* binding */ SteppedEase), 1944/* harmony export */ Strong: () => (/* binding */ Strong), 1945/* harmony export */ Timeline: () => (/* binding */ Timeline), 1946/* harmony export */ TimelineLite: () => (/* binding */ Timeline), 1947/* harmony export */ TimelineMax: () => (/* binding */ Timeline), 1948/* harmony export */ Tween: () => (/* binding */ Tween), 1949/* harmony export */ TweenLite: () => (/* binding */ Tween), 1950/* harmony export */ TweenMax: () => (/* binding */ Tween), 1951/* harmony export */ _checkPlugin: () => (/* binding */ _checkPlugin), 1952/* harmony export */ _colorExp: () => (/* binding */ _colorExp), 1953/* harmony export */ _colorStringFilter: () => (/* binding */ _colorStringFilter), 1954/* harmony export */ _config: () => (/* binding */ _config), 1955/* harmony export */ _forEachName: () => (/* binding */ _forEachName), 1956/* harmony export */ _getCache: () => (/* binding */ _getCache), 1957/* harmony export */ _getProperty: () => (/* binding */ _getProperty), 1958/* harmony export */ _getSetter: () => (/* binding */ _getSetter), 1959/* harmony export */ _isString: () => (/* binding */ _isString), 1960/* harmony export */ _isUndefined: () => (/* binding */ _isUndefined), 1961/* harmony export */ _missingPlugin: () => (/* binding */ _missingPlugin), 1962/* harmony export */ _numExp: () => (/* binding */ _numExp), 1963/* harmony export */ _numWithUnitExp: () => (/* binding */ _numWithUnitExp), 1964/* harmony export */ _parseRelative: () => (/* binding */ _parseRelative), 1965/* harmony export */ _plugins: () => (/* binding */ _plugins), 1966/* harmony export */ _relExp: () => (/* binding */ _relExp), 1967/* harmony export */ _removeLinkedListItem: () => (/* binding */ _removeLinkedListItem), 1968/* harmony export */ _renderComplexString: () => (/* binding */ _renderComplexString), 1969/* harmony export */ _replaceRandom: () => (/* binding */ _replaceRandom), 1970/* harmony export */ _round: () => (/* binding */ _round), 1971/* harmony export */ _roundModifier: () => (/* binding */ _roundModifier), 1972/* harmony export */ _setDefaults: () => (/* binding */ _setDefaults), 1973/* harmony export */ _sortPropTweensByPriority: () => (/* binding */ _sortPropTweensByPriority), 1974/* harmony export */ _ticker: () => (/* binding */ _ticker), 1975/* harmony export */ clamp: () => (/* binding */ clamp), 1976/* harmony export */ "default": () => (/* binding */ gsap), 1977/* harmony export */ distribute: () => (/* binding */ distribute), 1978/* harmony export */ getUnit: () => (/* binding */ getUnit), 1979/* harmony export */ gsap: () => (/* binding */ gsap), 1980/* harmony export */ interpolate: () => (/* binding */ interpolate),
1981/* harmony export */ mapRange: () => (/* binding */ mapRange), 1982/* harmony export */ normalize: () => (/* binding */ normalize), 1983/* harmony export */ pipe: () => (/* binding */ pipe), 1984/* harmony export */ random: () => (/* binding */ random), 1985/* harmony export */ selector: () => (/* binding */ selector), 1986/* harmony export */ shuffle: () => (/* binding */ shuffle), 1987/* harmony export */ snap: () => (/* binding */ snap), 1988/* harmony export */ splitColor: () => (/* binding */ splitColor), 1989/* harmony export */ toArray: () => (/* binding */ toArray), 1990/* harmony export */ unitize: () => (/* binding */ unitize), 1991/* harmony export */ wrap: () => (/* binding */ wrap), 1992/* harmony export */ wrapYoyo: () => (/* binding */ wrapYoyo) 1993/* harmony export */ });
vendor: 59,597 bytes, lines 1994-3591
1994function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 1995 1996function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } 1997 1998/*! 1999 * GSAP 3.15.0 2000 * https://gsap.com 2001 * 2002 * @license Copyright 2008-2026, GreenSock. All rights reserved. 2003 * Subject to the terms at https://gsap.com/standard-license 2004 * @author: Jack Doyle, [email protected] 2005*/ 2006 2007/* eslint-disable */ 2008var _config = { 2009 autoSleep: 120, 2010 force3D: "auto", 2011 nullTargetWarn: 1, 2012 units: { 2013 lineHeight: "" 2014 } 2015}, 2016 _defaults = { 2017 duration: .5, 2018 overwrite: false, 2019 delay: 0 2020}, 2021 _suppressOverwrites, 2022 _reverting, 2023 _context, 2024 _bigNum = 1e8, 2025 _tinyNum = 1 / _bigNum, 2026 _2PI = Math.PI * 2, 2027 _HALF_PI = _2PI / 4, 2028 _gsID = 0, 2029 _sqrt = Math.sqrt, 2030 _cos = Math.cos, 2031 _sin = Math.sin, 2032 _isString = function _isString(value) { 2033 return typeof value === "string"; 2034}, 2035 _isFunction = function _isFunction(value) { 2036 return typeof value === "function"; 2037}, 2038 _isNumber = function _isNumber(value) { 2039 return typeof value === "number"; 2040}, 2041 _isUndefined = function _isUndefined(value) { 2042 return typeof value === "undefined"; 2043}, 2044 _isObject = function _isObject(value) { 2045 return typeof value === "object"; 2046}, 2047 _isNotFalse = function _isNotFalse(value) { 2048 return value !== false; 2049}, 2050 _windowExists = function _windowExists() { 2051 return typeof window !== "undefined"; 2052}, 2053 _isFuncOrString = function _isFuncOrString(value) { 2054 return _isFunction(value) || _isString(value); 2055}, 2056 _isTypedArray = typeof ArrayBuffer === "function" && ArrayBuffer.isView || function () {}, 2057 // note: IE10 has ArrayBuffer, but NOT ArrayBuffer.isView(). 2058_isArray = Array.isArray, 2059 _randomExp = /random\([^)]+\)/g, 2060 _commaDelimExp = /,\s*/g, 2061 _strictNumExp = /(?:-?\.?\d|\.)+/gi, 2062 //only numbers (including negatives and decimals) but NOT relative values. 2063_numExp = /[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g, 2064 //finds any numbers, including ones that start with += or -=, negative numbers, and ones in scientific notation like 1e-8. 2065_numWithUnitExp = /[-+=.]*\d+[.e-]*\d*[a-z%]*/g, 2066 _complexStringNumExp = /[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi, 2067 //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. 2068_relExp = /[+-]=-?[.\d]+/, 2069 _delimitedValueExp = /[^,'"\[\]\s]+/gi, 2070 // previously /[#\-+.]*\b[a-z\d\-=+%.]+/gi but didn't catch special characters. 2071_unitExp = /^[+\-=e\s\d]*\d+[.\d]*([a-z]*|%)\s*$/i, 2072 _globalTimeline, 2073 _win, 2074 _coreInitted, 2075 _doc, 2076 _globals = {}, 2077 _installScope = {}, 2078 _coreReady, 2079 _install = function _install(scope) { 2080 return (_installScope = _merge(scope, _globals)) && gsap; 2081}, 2082 _missingPlugin = function _missingPlugin(property, value) { 2083 return console.warn("Invalid property", property, "set to", value, "Missing plugin? gsap.registerPlugin()"); 2084}, 2085 _warn = function _warn(message, suppress) { 2086 return !suppress && console.warn(message); 2087}, 2088 _addGlobal = function _addGlobal(name, obj) { 2089 return name && (_globals[name] = obj) && _installScope && (_installScope[name] = obj) || _globals; 2090}, 2091 _emptyFunc = function _emptyFunc() { 2092 return 0; 2093}, 2094 _startAtRevertConfig = { 2095 suppressEvents: true, 2096 isStart: true, 2097 kill: false 2098}, 2099 _revertConfigNoKill = { 2100 suppressEvents: true, 2101 kill: false 2102}, 2103 _revertConfig = { 2104 suppressEvents: true 2105}, 2106 _reservedProps = {}, 2107 _lazyTweens = [], 2108 _lazyLookup = {}, 2109 _lastRenderedFrame, 2110 _plugins = {}, 2111 _effects = {}, 2112 _nextGCFrame = 30, 2113 _harnessPlugins = [], 2114 _callbackNames = "", 2115 _harness = function _harness(targets) { 2116 var target = targets[0], 2117 harnessPlugin, 2118 i; 2119 _isObject(target) || _isFunction(target) || (targets = [targets]); 2120 2121 if (!(harnessPlugin = (target._gsap || {}).harness)) { 2122 // 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) 2123 i = _harnessPlugins.length; 2124 2125 while (i-- && !_harnessPlugins[i].targetTest(target)) {} 2126 2127 harnessPlugin = _harnessPlugins[i]; 2128 } 2129 2130 i = targets.length; 2131 2132 while (i--) { 2133 targets[i] && (targets[i]._gsap || (targets[i]._gsap = new GSCache(targets[i], harnessPlugin))) || targets.splice(i, 1); 2134 } 2135 2136 return targets; 2137}, 2138 _getCache = function _getCache(target) { 2139 return target._gsap || _harness(toArray(target))[0]._gsap; 2140}, 2141 _getProperty = function _getProperty(target, property, v) { 2142 return (v = target[property]) && _isFunction(v) ? target[property]() : _isUndefined(v) && target.getAttribute && target.getAttribute(property) || v; 2143}, 2144 _forEachName = function _forEachName(names, func) { 2145 return (names = names.split(",")).forEach(func) || names; 2146}, 2147 //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). 2148_round = function _round(value) { 2149 return Math.round(value * 100000) / 100000 || 0; 2150}, 2151 _roundPrecise = function _roundPrecise(value) { 2152 return Math.round(value * 10000000) / 10000000 || 0; 2153}, 2154 // increased precision mostly for timing values. 2155_parseRelative = function _parseRelative(start, value) { 2156 var operator = value.charAt(0), 2157 end = parseFloat(value.substr(2)); 2158 start = parseFloat(start); 2159 return operator === "+" ? start + end : operator === "-" ? start - end : operator === "*" ? start * end : start / end; 2160}, 2161 _arrayContainsAny = function _arrayContainsAny(toSearch, toFind) { 2162 //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. 2163 var l = toFind.length, 2164 i = 0; 2165 2166 for (; toSearch.indexOf(toFind[i]) < 0 && ++i < l;) {} 2167 2168 return i < l; 2169}, 2170 _lazyRender = function _lazyRender() { 2171 var l = _lazyTweens.length, 2172 a = _lazyTweens.slice(0), 2173 i, 2174 tween; 2175 2176 _lazyLookup = {}; 2177 _lazyTweens.length = 0; 2178 2179 for (i = 0; i < l; i++) { 2180 tween = a[i]; 2181 tween && tween._lazy && (tween.render(tween._lazy[0], tween._lazy[1], true)._lazy = 0); 2182 } 2183}, 2184 _isRevertWorthy = function _isRevertWorthy(animation) { 2185 return !!(animation._initted || animation._startAt || animation.add); 2186}, 2187 _lazySafeRender = function _lazySafeRender(animation, time, suppressEvents, force) { 2188 _lazyTweens.length && !_reverting && _lazyRender(); 2189 animation.render(time, suppressEvents, force || !!(_reverting && time < 0 && _isRevertWorthy(animation))); 2190 _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. 2191}, 2192 _numericIfPossible = function _numericIfPossible(value) { 2193 var n = parseFloat(value); 2194 return (n || n === 0) && (value + "").match(_delimitedValueExp).length < 2 ? n : _isString(value) ? value.trim() : value; 2195}, 2196 _passThrough = function _passThrough(p) { 2197 return p; 2198}, 2199 _setDefaults = function _setDefaults(obj, defaults) { 2200 for (var p in defaults) { 2201 p in obj || (obj[p] = defaults[p]); 2202 } 2203 2204 return obj; 2205}, 2206 _setKeyframeDefaults = function _setKeyframeDefaults(excludeDuration) { 2207 return function (obj, defaults) { 2208 for (var p in defaults) { 2209 p in obj || p === "duration" && excludeDuration || p === "ease" || (obj[p] = defaults[p]); 2210 } 2211 }; 2212}, 2213 _merge = function _merge(base, toMerge) { 2214 for (var p in toMerge) { 2215 base[p] = toMerge[p]; 2216 } 2217 2218 return base; 2219}, 2220 _mergeDeep = function _mergeDeep(base, toMerge) { 2221 for (var p in toMerge) { 2222 p !== "__proto__" && p !== "constructor" && p !== "prototype" && (base[p] = _isObject(toMerge[p]) ? _mergeDeep(base[p] || (base[p] = {}), toMerge[p]) : toMerge[p]); 2223 } 2224 2225 return base; 2226}, 2227 _copyExcluding = function _copyExcluding(obj, excluding) { 2228 var copy = {}, 2229 p; 2230 2231 for (p in obj) { 2232 p in excluding || (copy[p] = obj[p]); 2233 } 2234 2235 return copy; 2236}, 2237 _inheritDefaults = function _inheritDefaults(vars) { 2238 var parent = vars.parent || _globalTimeline, 2239 func = vars.keyframes ? _setKeyframeDefaults(_isArray(vars.keyframes)) : _setDefaults; 2240 2241 if (_isNotFalse(vars.inherit)) { 2242 while (parent) { 2243 func(vars, parent.vars.defaults); 2244 parent = parent.parent || parent._dp; 2245 } 2246 } 2247 2248 return vars; 2249}, 2250 _arraysMatch = function _arraysMatch(a1, a2) { 2251 var i = a1.length, 2252 match = i === a2.length; 2253 2254 while (match && i-- && a1[i] === a2[i]) {} 2255 2256 return i < 0; 2257}, 2258 _addLinkedListItem = function _addLinkedListItem(parent, child, firstProp, lastProp, sortBy) { 2259 if (firstProp === void 0) { 2260 firstProp = "_first"; 2261 } 2262 2263 if (lastProp === void 0) { 2264 lastProp = "_last"; 2265 } 2266 2267 var prev = parent[lastProp], 2268 t; 2269 2270 if (sortBy) { 2271 t = child[sortBy]; 2272 2273 while (prev && prev[sortBy] > t) { 2274 prev = prev._prev; 2275 } 2276 } 2277 2278 if (prev) { 2279 child._next = prev._next; 2280 prev._next = child; 2281 } else { 2282 child._next = parent[firstProp]; 2283 parent[firstProp] = child; 2284 } 2285 2286 if (child._next) { 2287 child._next._prev = child; 2288 } else { 2289 parent[lastProp] = child; 2290 } 2291 2292 child._prev = prev; 2293 child.parent = child._dp = parent; 2294 return child; 2295}, 2296 _removeLinkedListItem = function _removeLinkedListItem(parent, child, firstProp, lastProp) { 2297 if (firstProp === void 0) { 2298 firstProp = "_first"; 2299 } 2300 2301 if (lastProp === void 0) { 2302 lastProp = "_last"; 2303 } 2304 2305 var prev = child._prev, 2306 next = child._next; 2307 2308 if (prev) { 2309 prev._next = next; 2310 } else if (parent[firstProp] === child) { 2311 parent[firstProp] = next; 2312 } 2313 2314 if (next) { 2315 next._prev = prev; 2316 } else if (parent[lastProp] === child) { 2317 parent[lastProp] = prev; 2318 } 2319 2320 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. 2321}, 2322 _removeFromParent = function _removeFromParent(child, onlyIfParentHasAutoRemove) { 2323 child.parent && (!onlyIfParentHasAutoRemove || child.parent.autoRemoveChildren) && child.parent.remove && child.parent.remove(child); 2324 child._act = 0; 2325}, 2326 _uncache = function _uncache(animation, child) { 2327 if (animation && (!child || child._end > animation._dur || child._start < 0)) { 2328 // 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) 2329 var a = animation; 2330 2331 while (a) { 2332 a._dirty = 1; 2333 a = a.parent; 2334 } 2335 } 2336 2337 return animation; 2338}, 2339 _recacheAncestors = function _recacheAncestors(animation) { 2340 var parent = animation.parent; 2341 2342 while (parent && parent.parent) { 2343 //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. 2344 parent._dirty = 1; 2345 parent.totalDuration(); 2346 parent = parent.parent; 2347 } 2348 2349 return animation; 2350}, 2351 _rewindStartAt = function _rewindStartAt(tween, totalTime, suppressEvents, force) { 2352 return tween._startAt && (_reverting ? tween._startAt.revert(_revertConfigNoKill) : tween.vars.immediateRender && !tween.vars.autoRevert || tween._startAt.render(totalTime, true, force)); 2353}, 2354 _hasNoPausedAncestors = function _hasNoPausedAncestors(animation) { 2355 return !animation || animation._ts && _hasNoPausedAncestors(animation.parent); 2356}, 2357 _elapsedCycleDuration = function _elapsedCycleDuration(animation) { 2358 return animation._repeat ? _animationCycle(animation._tTime, animation = animation.duration() + animation._rDelay) * animation : 0; 2359}, 2360 // 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. 2361_animationCycle = function _animationCycle(tTime, cycleDuration) { 2362 var whole = Math.floor(tTime = _roundPrecise(tTime / cycleDuration)); 2363 return tTime && whole === tTime ? whole - 1 : whole; 2364}, 2365 _parentToChildTotalTime = function _parentToChildTotalTime(parentTime, child) { 2366 return (parentTime - child._start) * child._ts + (child._ts >= 0 ? 0 : child._dirty ? child.totalDuration() : child._tDur); 2367}, 2368 _setEnd = function _setEnd(animation) { 2369 return animation._end = _roundPrecise(animation._start + (animation._tDur / Math.abs(animation._ts || animation._rts || _tinyNum) || 0)); 2370}, 2371 _alignPlayhead = function _alignPlayhead(animation, totalTime) { 2372 // 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. 2373 var parent = animation._dp; 2374 2375 if (parent && parent.smoothChildTiming && animation._ts) { 2376 animation._start = _roundPrecise(parent._time - (animation._ts > 0 ? totalTime / animation._ts : ((animation._dirty ? animation.totalDuration() : animation._tDur) - totalTime) / -animation._ts)); 2377 2378 _setEnd(animation); 2379 2380 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. 2381 } 2382 2383 return animation; 2384}, 2385 2386/* 2387_totalTimeToTime = (clampedTotalTime, duration, repeat, repeatDelay, yoyo) => { 2388 let cycleDuration = duration + repeatDelay, 2389 time = _round(clampedTotalTime % cycleDuration); 2390 if (time > duration) { 2391 time = duration; 2392 } 2393 return (yoyo && (~~(clampedTotalTime / cycleDuration) & 1)) ? duration - time : time; 2394}, 2395*/ 2396_postAddChecks = function _postAddChecks(timeline, child) { 2397 var t; 2398 2399 if (child._time || !child._dur && child._initted || child._start < timeline._time && (child._dur || !child.add)) { 2400 // 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). 2401 t = _parentToChildTotalTime(timeline.rawTime(), child); 2402 2403 if (!child._dur || _clamp(0, child.totalDuration(), t) - child._tTime > _tinyNum) { 2404 child.render(t, true); 2405 } 2406 } //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. 2407 2408 2409 if (_uncache(timeline, child)._dp && timeline._initted && timeline._time >= timeline._dur && timeline._ts) { 2410 //in case any of the ancestors had completed but should now be enabled... 2411 if (timeline._dur < timeline.duration()) { 2412 t = timeline; 2413 2414 while (t._dp) { 2415 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. 2416 2417 t = t._dp; 2418 } 2419 } 2420 2421 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. 2422 } 2423}, 2424 _addToTimeline = function _addToTimeline(timeline, child, position, skipChecks) { 2425 child.parent && _removeFromParent(child); 2426 child._start = _roundPrecise((_isNumber(position) ? position : position || timeline !== _globalTimeline ? _parsePosition(timeline, position, child) : timeline._time) + child._delay); 2427 child._end = _roundPrecise(child._start + (child.totalDuration() / Math.abs(child.timeScale()) || 0)); 2428 2429 _addLinkedListItem(timeline, child, "_first", "_last", timeline._sort ? "_start" : 0); 2430 2431 _isFromOrFromStart(child) || (timeline._recent = child); 2432 skipChecks || _postAddChecks(timeline, child); 2433 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) 2434 2435 return timeline; 2436}, 2437 _scrollTrigger = function _scrollTrigger(animation, trigger) { 2438 return (_globals.ScrollTrigger || _missingPlugin("scrollTrigger", trigger)) && _globals.ScrollTrigger.create(trigger, animation); 2439}, 2440 _attemptInitTween = function _attemptInitTween(tween, time, force, suppressEvents, tTime) { 2441 _initTween(tween, time, tTime); 2442 2443 if (!tween._initted) { 2444 return 1; 2445 } 2446 2447 if (!force && tween._pt && !_reverting && (tween._dur && tween.vars.lazy !== false || !tween._dur && tween.vars.lazy) && _lastRenderedFrame !== _ticker.frame) { 2448 _lazyTweens.push(tween); 2449 2450 tween._lazy = [tTime, suppressEvents]; 2451 return 1; 2452 } 2453}, 2454 _parentPlayheadIsBeforeStart = function _parentPlayheadIsBeforeStart(_ref) { 2455 var parent = _ref.parent; 2456 return parent && parent._ts && parent._initted && !parent._lock && (parent.rawTime() < 0 || _parentPlayheadIsBeforeStart(parent)); 2457}, 2458 // check parent's _lock because when a timeline repeats/yoyos and does its artificial wrapping, we shouldn't force the ratio back to 0 2459_isFromOrFromStart = function _isFromOrFromStart(_ref2) { 2460 var data = _ref2.data; 2461 return data === "isFromStart" || data === "isStart"; 2462}, 2463 _renderZeroDurationTween = function _renderZeroDurationTween(tween, totalTime, suppressEvents, force) { 2464 var prevRatio = tween.ratio, 2465 ratio = totalTime < 0 || !totalTime && (!tween._start && _parentPlayheadIsBeforeStart(tween) && !(!tween._initted && _isFromOrFromStart(tween)) || (tween._ts < 0 || tween._dp._ts < 0) && !_isFromOrFromStart(tween)) ? 0 : 1, 2466 // 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. 2467 repeatDelay = tween._rDelay, 2468 tTime = 0, 2469 pt, 2470 iteration, 2471 prevIteration; 2472 2473 if (repeatDelay && tween._repeat) { 2474 // in case there's a zero-duration tween that has a repeat with a repeatDelay 2475 tTime = _clamp(0, tween._tDur, totalTime); 2476 iteration = _animationCycle(tTime, repeatDelay); 2477 tween._yoyo && iteration & 1 && (ratio = 1 - ratio); 2478 2479 if (iteration !== _animationCycle(tween._tTime, repeatDelay)) { 2480 // if iteration changed 2481 prevRatio = 1 - ratio; 2482 tween.vars.repeatRefresh && tween._initted && tween.invalidate(); 2483 } 2484 } 2485 2486 if (ratio !== prevRatio || _reverting || force || tween._zTime === _tinyNum || !totalTime && tween._zTime) { 2487 if (!tween._initted && _attemptInitTween(tween, totalTime, force, suppressEvents, tTime)) { 2488 // 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. 2489 return; 2490 } 2491 2492 prevIteration = tween._zTime; 2493 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. 2494 2495 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. 2496 2497 tween.ratio = ratio; 2498 tween._from && (ratio = 1 - ratio); 2499 tween._time = 0; 2500 tween._tTime = tTime; 2501 pt = tween._pt; 2502 2503 while (pt) { 2504 pt.r(ratio, pt.d); 2505 pt = pt._next; 2506 } 2507 2508 totalTime < 0 && _rewindStartAt(tween, totalTime, suppressEvents, true); 2509 tween._onUpdate && !suppressEvents && _callback(tween, "onUpdate"); 2510 tTime && tween._repeat && !suppressEvents && tween.parent && _callback(tween, "onRepeat"); 2511 2512 if ((totalTime >= tween._tDur || totalTime < 0) && tween.ratio === ratio) { 2513 ratio && _removeFromParent(tween, 1); 2514 2515 if (!suppressEvents && !_reverting) { 2516 _callback(tween, ratio ? "onComplete" : "onReverseComplete", true); 2517 2518 tween._prom && tween._prom(); 2519 } 2520 } 2521 } else if (!tween._zTime) { 2522 tween._zTime = totalTime; 2523 } 2524}, 2525 _findNextPauseTween = function _findNextPauseTween(animation, prevTime, time) { 2526 var child; 2527 2528 if (time > prevTime) { 2529 child = animation._first; 2530 2531 while (child && child._start <= time) { 2532 if (child.data === "isPause" && child._start > prevTime) { 2533 return child; 2534 } 2535 2536 child = child._next; 2537 } 2538 } else { 2539 child = animation._last; 2540 2541 while (child && child._start >= time) { 2542 if (child.data === "isPause" && child._start < prevTime) { 2543 return child; 2544 } 2545 2546 child = child._prev; 2547 } 2548 } 2549}, 2550 _setDuration = function _setDuration(animation, duration, skipUncache, leavePlayhead) { 2551 var repeat = animation._repeat, 2552 dur = _roundPrecise(duration) || 0, 2553 totalProgress = animation._tTime / animation._tDur; 2554 totalProgress && !leavePlayhead && (animation._time *= dur / animation._dur); 2555 animation._dur = dur; 2556 animation._tDur = !repeat ? dur : repeat < 0 ? 1e10 : _roundPrecise(dur * (repeat + 1) + animation._rDelay * repeat); 2557 totalProgress > 0 && !leavePlayhead && _alignPlayhead(animation, animation._tTime = animation._tDur * totalProgress); 2558 animation.parent && _setEnd(animation); 2559 skipUncache || _uncache(animation.parent, animation); 2560 return animation; 2561}, 2562 _onUpdateTotalDuration = function _onUpdateTotalDuration(animation) { 2563 return animation instanceof Timeline ? _uncache(animation) : _setDuration(animation, animation._dur); 2564}, 2565 _zeroPosition = { 2566 _start: 0, 2567 endTime: _emptyFunc, 2568 totalDuration: _emptyFunc 2569}, 2570 _parsePosition = function _parsePosition(animation, position, percentAnimation) { 2571 var labels = animation.labels, 2572 recent = animation._recent || _zeroPosition, 2573 clippedDuration = animation.duration() >= _bigNum ? recent.endTime(false) : animation._dur, 2574 //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. 2575 i, 2576 offset, 2577 isPercent; 2578 2579 if (_isString(position) && (isNaN(position) || position in labels)) { 2580 //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). 2581 offset = position.charAt(0); 2582 isPercent = position.substr(-1) === "%"; 2583 i = position.indexOf("="); 2584 2585 if (offset === "<" || offset === ">") { 2586 i >= 0 && (position = position.replace(/=/, "")); 2587 return (offset === "<" ? recent._start : recent.endTime(recent._repeat >= 0)) + (parseFloat(position.substr(1)) || 0) * (isPercent ? (i < 0 ? recent : percentAnimation).totalDuration() / 100 : 1); 2588 } 2589 2590 if (i < 0) { 2591 position in labels || (labels[position] = clippedDuration); 2592 return labels[position]; 2593 } 2594 2595 offset = parseFloat(position.charAt(i - 1) + position.substr(i + 1)); 2596 2597 if (isPercent && percentAnimation) { 2598 offset = offset / 100 * (_isArray(percentAnimation) ? percentAnimation[0] : percentAnimation).totalDuration(); 2599 } 2600 2601 return i > 1 ? _parsePosition(animation, position.substr(0, i - 1), percentAnimation) + offset : clippedDuration + offset; 2602 } 2603 2604 return position == null ? clippedDuration : +position; 2605}, 2606 _createTweenType = function _createTweenType(type, params, timeline) { 2607 var isLegacy = _isNumber(params[1]), 2608 varsIndex = (isLegacy ? 2 : 1) + (type < 2 ? 0 : 1), 2609 vars = params[varsIndex], 2610 irVars, 2611 parent; 2612 2613 isLegacy && (vars.duration = params[1]); 2614 vars.parent = timeline; 2615 2616 if (type) { 2617 irVars = vars; 2618 parent = timeline; 2619 2620 while (parent && !("immediateRender" in irVars)) { 2621 // 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. 2622 irVars = parent.vars.defaults || {}; 2623 parent = _isNotFalse(parent.vars.inherit) && parent.parent; 2624 } 2625 2626 vars.immediateRender = _isNotFalse(irVars.immediateRender); 2627 type < 2 ? vars.runBackwards = 1 : vars.startAt = params[varsIndex - 1]; // "from" vars 2628 } 2629 2630 return new Tween(params[0], vars, params[varsIndex + 1]); 2631}, 2632 _conditionalReturn = function _conditionalReturn(value, func) { 2633 return value || value === 0 ? func(value) : func; 2634}, 2635 _clamp = function _clamp(min, max, value) { 2636 return value < min ? min : value > max ? max : value; 2637}, 2638 getUnit = function getUnit(value, v) { 2639 return !_isString(value) || !(v = _unitExp.exec(value)) ? "" : v[1]; 2640}, 2641 // 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. 2642clamp = function clamp(min, max, value) { 2643 return _conditionalReturn(value, function (v) { 2644 return _clamp(min, max, v); 2645 }); 2646}, 2647 _slice = [].slice, 2648 _isArrayLike = function _isArrayLike(value, nonEmpty) { 2649 return value && _isObject(value) && "length" in value && (!nonEmpty && !value.length || value.length - 1 in value && _isObject(value[0])) && !value.nodeType && value !== _win; 2650}, 2651 _flatten = function _flatten(ar, leaveStrings, accumulator) { 2652 if (accumulator === void 0) { 2653 accumulator = []; 2654 } 2655 2656 return ar.forEach(function (value) { 2657 var _accumulator; 2658 2659 return _isString(value) && !leaveStrings || _isArrayLike(value, 1) ? (_accumulator = accumulator).push.apply(_accumulator, toArray(value)) : accumulator.push(value); 2660 }) || accumulator; 2661}, 2662 // takes 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. 2663toArray = function toArray(value, scope, leaveStrings) { 2664 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] : []; 2665}, 2666 selector = function selector(value) { 2667 value = toArray(value)[0] || _warn("Invalid scope") || {}; 2668 return function (v) { 2669 var el = value.current || value.nativeElement || value; 2670 return toArray(v, el.querySelectorAll ? el : el === value ? _warn("Invalid scope") || _doc.createElement("div") : value); 2671 }; 2672}, 2673 shuffle = function shuffle(a) { 2674 return a.sort(function () { 2675 return .5 - Math.random(); 2676 }); 2677}, 2678 // alternative that's a bit faster and more reliably diverse but bigger: for (let j, v, i = a.length; i; j = (Math.random() * i) | 0, v = a[--i], a[i] = a[j], a[j] = v); return a; 2679// for distributing values across an Array. Can accept a number, a function or (most commonly) an object 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. 2680distribute = function distribute(v) { 2681 if (_isFunction(v)) { 2682 return v; 2683 } 2684 2685 var vars = _isObject(v) ? v : { 2686 each: v 2687 }, 2688 //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. 2689 ease = _parseEase(vars.ease), 2690 from = vars.from || 0, 2691 base = parseFloat(vars.base) || 0, 2692 cache = {}, 2693 isDecimal = from > 0 && from < 1, 2694 ratios = isNaN(from) || isDecimal, 2695 axis = vars.axis, 2696 ratioX = from, 2697 ratioY = from; 2698 2699 if (_isString(from)) { 2700 ratioX = ratioY = { 2701 center: .5, 2702 edges: .5, 2703 end: 1 2704 }[from] || 0; 2705 } else if (!isDecimal && ratios) { 2706 ratioX = from[0]; 2707 ratioY = from[1]; 2708 } 2709 2710 return function (i, target, a) { 2711 var l = (a || vars).length, 2712 distances = cache[l], 2713 originX, 2714 originY, 2715 x, 2716 y, 2717 d, 2718 j, 2719 max, 2720 min, 2721 wrapAt; 2722 2723 if (!distances) { 2724 wrapAt = vars.grid === "auto" ? 0 : (vars.grid || [1, _bigNum])[1]; 2725 2726 if (!wrapAt) { 2727 max = -_bigNum; 2728 2729 while (max < (max = a[wrapAt++].getBoundingClientRect().left) && wrapAt < l) {} 2730 2731 wrapAt < l && wrapAt--; 2732 } 2733 2734 distances = cache[l] = []; 2735 originX = ratios ? Math.min(wrapAt, l) * ratioX - .5 : from % wrapAt; 2736 originY = wrapAt === _bigNum ? 0 : ratios ? l * ratioY / wrapAt - .5 : from / wrapAt | 0; 2737 max = 0; 2738 min = _bigNum; 2739 2740 for (j = 0; j < l; j++) { 2741 x = j % wrapAt - originX; 2742 y = originY - (j / wrapAt | 0); 2743 distances[j] = d = !axis ? _sqrt(x * x + y * y) : Math.abs(axis === "y" ? y : x); 2744 d > max && (max = d); 2745 d < min && (min = d); 2746 } 2747 2748 from === "random" && shuffle(distances); 2749 distances.max = max - min; 2750 distances.min = min; 2751 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); 2752 distances.b = l < 0 ? base - l : base; 2753 distances.u = getUnit(vars.amount || vars.each) || 0; //unit 2754 2755 ease = ease && l < 0 ? _invertEase(ease) : ease; 2756 } 2757 2758 l = (distances[i] - distances.min) / distances.max || 0; 2759 return _roundPrecise(distances.b + (ease ? ease(l) : l) * distances.v) + distances.u; //round in order to work around floating point errors 2760 }; 2761}, 2762 _roundModifier = function _roundModifier(v) { 2763 //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. 2764 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()) 2765 2766 return function (raw) { 2767 var n = _roundPrecise(Math.round(parseFloat(raw) / v) * v * p); 2768 2769 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! 2770 }; 2771}, 2772 snap = function snap(snapTo, value) { 2773 var isArray = _isArray(snapTo), 2774 radius, 2775 is2D; 2776 2777 if (!isArray && _isObject(snapTo)) { 2778 radius = isArray = snapTo.radius || _bigNum; 2779 2780 if (snapTo.values) { 2781 snapTo = toArray(snapTo.values); 2782 2783 if (is2D = !_isNumber(snapTo[0])) { 2784 radius *= radius; //performance optimization so we don't have to Math.sqrt() in the loop. 2785 } 2786 } else { 2787 snapTo = _roundModifier(snapTo.increment); 2788 } 2789 } 2790 2791 return _conditionalReturn(value, !isArray ? _roundModifier(snapTo) : _isFunction(snapTo) ? function (raw) { 2792 is2D = snapTo(raw); 2793 return Math.abs(is2D - raw) <= radius ? is2D : raw; 2794 } : function (raw) { 2795 var x = parseFloat(is2D ? raw.x : raw), 2796 y = parseFloat(is2D ? raw.y : 0), 2797 min = _bigNum, 2798 closest = 0, 2799 i = snapTo.length, 2800 dx, 2801 dy; 2802 2803 while (i--) { 2804 if (is2D) { 2805 dx = snapTo[i].x - x; 2806 dy = snapTo[i].y - y; 2807 dx = dx * dx + dy * dy; 2808 } else { 2809 dx = Math.abs(snapTo[i] - x); 2810 } 2811 2812 if (dx < min) { 2813 min = dx; 2814 closest = i; 2815 } 2816 } 2817 2818 closest = !radius || min <= radius ? snapTo[closest] : raw; 2819 return is2D || closest === raw || _isNumber(raw) ? closest : closest + getUnit(raw); 2820 }); 2821}, 2822 random = function random(min, max, roundingIncrement, returnFunction) { 2823 return _conditionalReturn(_isArray(min) ? !max : roundingIncrement === true ? !!(roundingIncrement = 0) : !returnFunction, function () { 2824 return _isArray(min) ? min[~~(Math.random() * min.length)] : (roundingIncrement = roundingIncrement || 1e-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; 2825 }); 2826}, 2827 pipe = function pipe() { 2828 for (var _len = arguments.length, functions = new Array(_len), _key = 0; _key < _len; _key++) { 2829 functions[_key] = arguments[_key]; 2830 } 2831 2832 return function (value) { 2833 return functions.reduce(function (v, f) { 2834 return f(v); 2835 }, value); 2836 }; 2837}, 2838 unitize = function unitize(func, unit) { 2839 return function (value) { 2840 return func(parseFloat(value)) + (unit || getUnit(value)); 2841 }; 2842}, 2843 normalize = function normalize(min, max, value) { 2844 return mapRange(min, max, 0, 1, value); 2845}, 2846 _wrapArray = function _wrapArray(a, wrapper, value) { 2847 return _conditionalReturn(value, function (index) { 2848 return a[~~wrapper(index)]; 2849 }); 2850}, 2851 wrap = function wrap(min, max, value) { 2852 // NOTE: wrap() CANNOT be an arrow function! A very odd compiling bug causes problems (unrelated to GSAP). 2853 var range = max - min; 2854 return _isArray(min) ? _wrapArray(min, wrap(0, min.length), max) : _conditionalReturn(value, function (value) { 2855 return (range + (value - min) % range) % range + min; 2856 }); 2857}, 2858 wrapYoyo = function wrapYoyo(min, max, value) { 2859 var range = max - min, 2860 total = range * 2; 2861 return _isArray(min) ? _wrapArray(min, wrapYoyo(0, min.length - 1), max) : _conditionalReturn(value, function (value) { 2862 value = (total + (value - min) % total) % total || 0; 2863 return min + (value > range ? total - value : value); 2864 }); 2865}, 2866 _replaceRandom = function _replaceRandom(s) { 2867 return s.replace(_randomExp, function (match) { 2868 //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]) 2869 var arIndex = match.indexOf("[") + 1, 2870 values = match.substring(arIndex || 7, arIndex ? match.indexOf("]") : match.length - 1).split(_commaDelimExp); 2871 return random(arIndex ? values : +values[0], arIndex ? 0 : +values[1], +values[2] || 1e-5); 2872 }); 2873}, 2874 mapRange = function mapRange(inMin, inMax, outMin, outMax, value) { 2875 var inRange = inMax - inMin, 2876 outRange = outMax - outMin; 2877 return _conditionalReturn(value, function (value) { 2878 return outMin + ((value - inMin) / inRange * outRange || 0); 2879 }); 2880}, 2881 interpolate = function interpolate(start, end, progress, mutate) { 2882 var func = isNaN(start + end) ? 0 : function (p) { 2883 return (1 - p) * start + p * end; 2884 }; 2885 2886 if (!func) { 2887 var isString = _isString(start), 2888 master = {}, 2889 p, 2890 i, 2891 interpolators, 2892 l, 2893 il; 2894 2895 progress === true && (mutate = 1) && (progress = null); 2896 2897 if (isString) { 2898 start = { 2899 p: start 2900 }; 2901 end = { 2902 p: end 2903 }; 2904 } else if (_isArray(start) && !_isArray(end)) { 2905 interpolators = []; 2906 l = start.length; 2907 il = l - 2; 2908 2909 for (i = 1; i < l; i++) { 2910 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. 2911 } 2912 2913 l--; 2914 2915 func = function func(p) { 2916 p *= l; 2917 var i = Math.min(il, ~~p); 2918 return interpolators[i](p - i); 2919 }; 2920 2921 progress = end; 2922 } else if (!mutate) { 2923 start = _merge(_isArray(start) ? [] : {}, start); 2924 } 2925 2926 if (!interpolators) { 2927 for (p in end) { 2928 _addPropTween.call(master, start, p, "get", end[p]); 2929 } 2930 2931 func = function func(p) { 2932 return _renderPropTweens(p, master) || (isString ? start.p : start); 2933 }; 2934 } 2935 } 2936 2937 return _conditionalReturn(progress, func); 2938}, 2939 _getLabelInDirection = function _getLabelInDirection(timeline, fromTime, backward) { 2940 //used for nextLabel() and previousLabel() 2941 var labels = timeline.labels, 2942 min = _bigNum, 2943 p, 2944 distance, 2945 label; 2946 2947 for (p in labels) { 2948 distance = labels[p] - fromTime; 2949 2950 if (distance < 0 === !!backward && distance && min > (distance = Math.abs(distance))) { 2951 label = p; 2952 min = distance; 2953 } 2954 } 2955 2956 return label; 2957}, 2958 _callback = function _callback(animation, type, executeLazyFirst) { 2959 var v = animation.vars, 2960 callback = v[type], 2961 prevContext = _context, 2962 context = animation._ctx, 2963 params, 2964 scope, 2965 result; 2966 2967 if (!callback) { 2968 return; 2969 } 2970 2971 params = v[type + "Params"]; 2972 scope = v.callbackScope || animation; 2973 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. 2974 2975 context && (_context = context); 2976 result = params ? callback.apply(scope, params) : callback.call(scope); 2977 _context = prevContext; 2978 return result; 2979}, 2980 _interrupt = function _interrupt(animation) { 2981 _removeFromParent(animation); 2982 2983 animation.scrollTrigger && animation.scrollTrigger.kill(!!_reverting); 2984 animation.progress() < 1 && _callback(animation, "onInterrupt"); 2985 return animation; 2986}, 2987 _quickTween, 2988 _registerPluginQueue = [], 2989 _createPlugin = function _createPlugin(config) { 2990 if (!config) return; 2991 config = !config.name && config["default"] || config; // UMD packaging wraps things oddly, so for example MotionPathHelper becomes {MotionPathHelper:MotionPathHelper, default:MotionPathHelper}. 2992 2993 if (_windowExists() || config.headless) { 2994 // edge case: some build tools may pass in a null/undefined value 2995 var name = config.name, 2996 isFunc = _isFunction(config), 2997 Plugin = name && !isFunc && config.init ? function () { 2998 this._props = []; 2999 } : config, 3000 //in case someone passes in an object that's not a plugin, like CustomEase 3001 instanceDefaults = { 3002 init: _emptyFunc, 3003 render: _renderPropTweens, 3004 add: _addPropTween, 3005 kill: _killPropTweensOf, 3006 modifier: _addPluginModifier, 3007 rawVars: 0 3008 }, 3009 statics = { 3010 targetTest: 0, 3011 get: 0, 3012 getSetter: _getSetter, 3013 aliases: {}, 3014 register: 0 3015 }; 3016 3017 _wake(); 3018 3019 if (config !== Plugin) { 3020 if (_plugins[name]) { 3021 return; 3022 } 3023 3024 _setDefaults(Plugin, _setDefaults(_copyExcluding(config, instanceDefaults), statics)); //static methods 3025 3026 3027 _merge(Plugin.prototype, _merge(instanceDefaults, _copyExcluding(config, statics))); //instance methods 3028 3029 3030 _plugins[Plugin.prop = name] = Plugin; 3031 3032 if (config.targetTest) { 3033 _harnessPlugins.push(Plugin); 3034 3035 _reservedProps[name] = 1; 3036 } 3037 3038 name = (name === "css" ? "CSS" : name.charAt(0).toUpperCase() + name.substr(1)) + "Plugin"; //for the global name. "motionPath" should become MotionPathPlugin 3039 } 3040 3041 _addGlobal(name, Plugin); 3042 3043 config.register && config.register(gsap, Plugin, PropTween); 3044 } else { 3045 _registerPluginQueue.push(config); 3046 } 3047}, 3048 3049/* 3050 * -------------------------------------------------------------------------------------- 3051 * COLORS 3052 * -------------------------------------------------------------------------------------- 3053 */ 3054_255 = 255, 3055 _colorLookup = { 3056 aqua: [0, _255, _255], 3057 lime: [0, _255, 0], 3058 silver: [192, 192, 192], 3059 black: [0, 0, 0], 3060 maroon: [128, 0, 0], 3061 teal: [0, 128, 128], 3062 blue: [0, 0, _255], 3063 navy: [0, 0, 128], 3064 white: [_255, _255, _255], 3065 olive: [128, 128, 0], 3066 yellow: [_255, _255, 0], 3067 orange: [_255, 165, 0], 3068 gray: [128, 128, 128], 3069 purple: [128, 0, 128], 3070 green: [0, 128, 0], 3071 red: [_255, 0, 0], 3072 pink: [_255, 192, 203], 3073 cyan: [0, _255, _255], 3074 transparent: [_255, _255, _255, 0] 3075}, 3076 // possible future idea to replace the hard-coded color name values - put this in the ticker.wake() where we set the _doc: 3077// let ctx = _doc.createElement("canvas").getContext("2d"); 3078// _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)}); 3079_hue = function _hue(h, m1, m2) { 3080 h += h < 0 ? 1 : h > 1 ? -1 : 0; 3081 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; 3082}, 3083 splitColor = function splitColor(v, toHSL, forceAlpha) { 3084 var a = !v ? _colorLookup.black : _isNumber(v) ? [v >> 16, v >> 8 & _255, v & _255] : 0, 3085 r, 3086 g, 3087 b, 3088 h, 3089 s, 3090 l, 3091 max, 3092 min, 3093 d, 3094 wasHSL; 3095 3096 if (!a) { 3097 if (v.substr(-1) === ",") { 3098 //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. 3099 v = v.substr(0, v.length - 1); 3100 } 3101 3102 if (_colorLookup[v]) { 3103 a = _colorLookup[v]; 3104 } else if (v.charAt(0) === "#") { 3105 if (v.length < 6) { 3106 //for shorthand like #9F0 or #9F0F (could have alpha) 3107 r = v.charAt(1); 3108 g = v.charAt(2); 3109 b = v.charAt(3); 3110 v = "#" + r + r + g + g + b + b + (v.length === 5 ? v.charAt(4) + v.charAt(4) : ""); 3111 } 3112 3113 if (v.length === 9) { 3114 // hex with alpha, like #fd5e53ff 3115 a = parseInt(v.substr(1, 6), 16); 3116 return [a >> 16, a >> 8 & _255, a & _255, parseInt(v.substr(7), 16) / 255]; 3117 } 3118 3119 v = parseInt(v.substr(1), 16); 3120 a = [v >> 16, v >> 8 & _255, v & _255]; 3121 } else if (v.substr(0, 3) === "hsl") { 3122 a = wasHSL = v.match(_strictNumExp); 3123 3124 if (!toHSL) { 3125 h = +a[0] % 360 / 360; 3126 s = +a[1] / 100; 3127 l = +a[2] / 100; 3128 g = l <= .5 ? l * (s + 1) : l + s - l * s; 3129 r = l * 2 - g; 3130 a.length > 3 && (a[3] *= 1); //cast as number 3131 3132 a[0] = _hue(h + 1 / 3, r, g); 3133 a[1] = _hue(h, r, g); 3134 a[2] = _hue(h - 1 / 3, r, g); 3135 } else if (~v.indexOf("=")) { 3136 //if relative values are found, just return the raw strings with the relative prefixes in place. 3137 a = v.match(_numExp); 3138 forceAlpha && a.length < 4 && (a[3] = 1); 3139 return a; 3140 } 3141 } else { 3142 a = v.match(_strictNumExp) || _colorLookup.transparent; 3143 } 3144 3145 a = a.map(Number); 3146 } 3147 3148 if (toHSL && !wasHSL) { 3149 r = a[0] / _255; 3150 g = a[1] / _255; 3151 b = a[2] / _255; 3152 max = Math.max(r, g, b); 3153 min = Math.min(r, g, b); 3154 l = (max + min) / 2; 3155 3156 if (max === min) { 3157 h = s = 0; 3158 } else { 3159 d = max - min; 3160 s = l > 0.5 ? d / (2 - max - min) : d / (max + min); 3161 h = max === r ? (g - b) / d + (g < b ? 6 : 0) : max === g ? (b - r) / d + 2 : (r - g) / d + 4; 3162 h *= 60; 3163 } 3164 3165 a[0] = ~~(h + .5); 3166 a[1] = ~~(s * 100 + .5); 3167 a[2] = ~~(l * 100 + .5); 3168 } 3169 3170 forceAlpha && a.length < 4 && (a[3] = 1); 3171 return a; 3172}, 3173 _colorOrderData = function _colorOrderData(v) { 3174 // 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() 3175 var values = [], 3176 c = [], 3177 i = -1; 3178 v.split(_colorExp).forEach(function (v) { 3179 var a = v.match(_numWithUnitExp) || []; 3180 values.push.apply(values, a); 3181 c.push(i += a.length + 1); 3182 }); 3183 values.c = c; 3184 return values; 3185}, 3186 _formatColors = function _formatColors(s, toHSL, orderMatchData) { 3187 var result = "", 3188 colors = (s + result).match(_colorExp), 3189 type = toHSL ? "hsla(" : "rgba(", 3190 i = 0, 3191 c, 3192 shell, 3193 d, 3194 l; 3195 3196 if (!colors) { 3197 return s; 3198 } 3199 3200 colors = colors.map(function (color) { 3201 return (color = splitColor(color, toHSL, 1)) && type + (toHSL ? color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : color.join(",")) + ")"; 3202 }); 3203 3204 if (orderMatchData) { 3205 d = _colorOrderData(s); 3206 c = orderMatchData.c; 3207 3208 if (c.join(result) !== d.c.join(result)) { 3209 shell = s.replace(_colorExp, "1").split(_numWithUnitExp); 3210 l = shell.length - 1; 3211 3212 for (; i < l; i++) { 3213 result += shell[i] + (~c.indexOf(i) ? colors.shift() || type + "0,0,0,0)" : (d.length ? d : colors.length ? colors : orderMatchData).shift()); 3214 } 3215 } 3216 } 3217 3218 if (!shell) { 3219 shell = s.split(_colorExp); 3220 l = shell.length - 1; 3221 3222 for (; i < l; i++) { 3223 result += shell[i] + colors[i]; 3224 } 3225 } 3226 3227 return result + shell[l]; 3228}, 3229 _colorExp = function () { 3230 var s = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3,4}){1,2}\\b", 3231 //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., 3232 p; 3233 3234 for (p in _colorLookup) { 3235 s += "|" + p + "\\b"; 3236 } 3237 3238 return new RegExp(s + ")", "gi"); 3239}(), 3240 _hslExp = /hsl[a]?\(/, 3241 _colorStringFilter = function _colorStringFilter(a) { 3242 var combined = a.join(" "), 3243 toHSL; 3244 _colorExp.lastIndex = 0; 3245 3246 if (_colorExp.test(combined)) { 3247 toHSL = _hslExp.test(combined); 3248 a[1] = _formatColors(a[1], toHSL); 3249 a[0] = _formatColors(a[0], toHSL, _colorOrderData(a[1])); // make sure the order of numbers/colors match with the END value. 3250 3251 return true; 3252 } 3253}, 3254 3255/* 3256 * -------------------------------------------------------------------------------------- 3257 * TICKER 3258 * -------------------------------------------------------------------------------------- 3259 */ 3260_tickerActive, 3261 _ticker = function () { 3262 var _getTime = Date.now, 3263 _lagThreshold = 500, 3264 _adjustedLag = 33, 3265 _startTime = _getTime(), 3266 _lastUpdate = _startTime, 3267 _gap = 1000 / 240, 3268 _nextTime = _gap, 3269 _listeners = [], 3270 _id, 3271 _req, 3272 _raf, 3273 _self, 3274 _delta, 3275 _i, 3276 _tick = function _tick(v) { 3277 var elapsed = _getTime() - _lastUpdate, 3278 manual = v === true, 3279 overlap, 3280 dispatch, 3281 time, 3282 frame; 3283 3284 (elapsed > _lagThreshold || elapsed < 0) && (_startTime += elapsed - _adjustedLag); 3285 _lastUpdate += elapsed; 3286 time = _lastUpdate - _startTime; 3287 overlap = time - _nextTime; 3288 3289 if (overlap > 0 || manual) { 3290 frame = ++_self.frame; 3291 _delta = time - _self.time * 1000; 3292 _self.time = time = time / 1000; 3293 _nextTime += overlap + (overlap >= _gap ? 4 : _gap - overlap); 3294 dispatch = 1; 3295 } 3296 3297 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. 3298 3299 if (dispatch) { 3300 for (_i = 0; _i < _listeners.length; _i++) { 3301 // 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. 3302 _listeners[_i](time, _delta, frame, v); 3303 } 3304 } 3305 }; 3306 3307 _self = { 3308 time: 0, 3309 frame: 0, 3310 tick: function tick() { 3311 _tick(true); 3312 }, 3313 deltaRatio: function deltaRatio(fps) { 3314 return _delta / (1000 / (fps || 60)); 3315 }, 3316 wake: function wake() { 3317 if (_coreReady) { 3318 if (!_coreInitted && _windowExists()) { 3319 _win = _coreInitted = window; 3320 _doc = _win.document || {}; 3321 _globals.gsap = gsap; 3322 (_win.gsapVersions || (_win.gsapVersions = [])).push(gsap.version); 3323 3324 _install(_installScope || _win.GreenSockGlobals || !_win.gsap && _win || {}); 3325 3326 _registerPluginQueue.forEach(_createPlugin); 3327 } 3328 3329 _raf = typeof requestAnimationFrame !== "undefined" && requestAnimationFrame; 3330 _id && _self.sleep(); 3331 3332 _req = _raf || function (f) { 3333 return setTimeout(f, _nextTime - _self.time * 1000 + 1 | 0); 3334 }; 3335 3336 _tickerActive = 1; 3337 3338 _tick(2); 3339 } 3340 }, 3341 sleep: function sleep() { 3342 (_raf ? cancelAnimationFrame : clearTimeout)(_id); 3343 _tickerActive = 0; 3344 _req = _emptyFunc; 3345 }, 3346 lagSmoothing: function lagSmoothing(threshold, adjustedLag) { 3347 _lagThreshold = threshold || Infinity; // zero should be interpreted as basically unlimited 3348 3349 _adjustedLag = Math.min(adjustedLag || 33, _lagThreshold); 3350 }, 3351 fps: function fps(_fps) { 3352 _gap = 1000 / (_fps || 240); 3353 _nextTime = _self.time * 1000 + _gap; 3354 }, 3355 add: function add(callback, once, prioritize) { 3356 var func = once ? function (t, d, f, v) { 3357 callback(t, d, f, v); 3358 3359 _self.remove(func); 3360 } : callback; 3361 3362 _self.remove(callback); 3363 3364 _listeners[prioritize ? "unshift" : "push"](func); 3365 3366 _wake(); 3367 3368 return func; 3369 }, 3370 remove: function remove(callback, i) { 3371 ~(i = _listeners.indexOf(callback)) && _listeners.splice(i, 1) && _i >= i && _i--; 3372 }, 3373 _listeners: _listeners 3374 }; 3375 return _self; 3376}(), 3377 _wake = function _wake() { 3378 return !_tickerActive && _ticker.wake(); 3379}, 3380 //also ensures the core classes are initialized. 3381 3382/* 3383* ------------------------------------------------- 3384* EASING 3385* ------------------------------------------------- 3386*/ 3387_easeMap = {}, 3388 _customEaseExp = /^[\d.\-M][\d.\-,\s]/, 3389 _quotesExp = /["']/g, 3390 _parseObjectInString = function _parseObjectInString(value) { 3391 //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. 3392 var obj = {}, 3393 split = value.substr(1, value.length - 3).split(":"), 3394 key = split[0], 3395 i = 1, 3396 l = split.length, 3397 index, 3398 val, 3399 parsedVal; 3400 3401 for (; i < l; i++) { 3402 val = split[i]; 3403 index = i !== l - 1 ? val.lastIndexOf(",") : val.length; 3404 parsedVal = val.substr(0, index); 3405 obj[key] = isNaN(parsedVal) ? parsedVal.replace(_quotesExp, "").trim() : +parsedVal; 3406 key = val.substr(index + 1).trim(); 3407 } 3408 3409 return obj; 3410}, 3411 _valueInParentheses = function _valueInParentheses(value) { 3412 var open = value.indexOf("(") + 1, 3413 close = value.indexOf(")"), 3414 nested = value.indexOf("(", open); 3415 return value.substring(open, ~nested && nested < close ? value.indexOf(")", close + 1) : close); 3416}, 3417 _configEaseFromString = function _configEaseFromString(name) { 3418 //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). 3419 var split = (name + "").split("("), 3420 ease = _easeMap[split[0]]; 3421 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; 3422}, 3423 _invertEase = function _invertEase(ease) { 3424 return function (p) { 3425 return 1 - ease(1 - p); 3426 }; 3427}, 3428 _parseEase = function _parseEase(ease, defaultEase) { 3429 return !ease ? defaultEase : (_isFunction(ease) ? ease : _easeMap[ease] || _configEaseFromString(ease)) || defaultEase; 3430}, 3431 _insertEase = function _insertEase(names, easeIn, easeOut, easeInOut) { 3432 if (easeOut === void 0) { 3433 easeOut = function easeOut(p) { 3434 return 1 - easeIn(1 - p); 3435 }; 3436 } 3437 3438 if (easeInOut === void 0) { 3439 easeInOut = function easeInOut(p) { 3440 return p < .5 ? easeIn(p * 2) / 2 : 1 - easeIn((1 - p) * 2) / 2; 3441 }; 3442 } 3443 3444 var ease = { 3445 easeIn: easeIn, 3446 easeOut: easeOut, 3447 easeInOut: easeInOut 3448 }, 3449 lowercaseName; 3450 3451 _forEachName(names, function (name) { 3452 _easeMap[name] = _globals[name] = ease; 3453 _easeMap[lowercaseName = name.toLowerCase()] = easeOut; 3454 3455 for (var p in ease) { 3456 _easeMap[lowercaseName + (p === "easeIn" ? ".in" : p === "easeOut" ? ".out" : ".inOut")] = _easeMap[name + "." + p] = ease[p]; 3457 } 3458 }); 3459 3460 return ease; 3461}, 3462 _easeInOutFromOut = function _easeInOutFromOut(easeOut) { 3463 return function (p) { 3464 return p < .5 ? (1 - easeOut(1 - p * 2)) / 2 : .5 + easeOut((p - .5) * 2) / 2; 3465 }; 3466}, 3467 _configElastic = function _configElastic(type, amplitude, period) { 3468 var p1 = amplitude >= 1 ? amplitude : 1, 3469 //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. 3470 p2 = (period || (type ? .3 : .45)) / (amplitude < 1 ? amplitude : 1), 3471 p3 = p2 / _2PI * (Math.asin(1 / p1) || 0), 3472 easeOut = function easeOut(p) { 3473 return p === 1 ? 1 : p1 * Math.pow(2, -10 * p) * _sin((p - p3) * p2) + 1; 3474 }, 3475 ease = type === "out" ? easeOut : type === "in" ? function (p) { 3476 return 1 - easeOut(1 - p); 3477 } : _easeInOutFromOut(easeOut); 3478 3479 p2 = _2PI / p2; //precalculate to optimize 3480 3481 ease.config = function (amplitude, period) { 3482 return _configElastic(type, amplitude, period); 3483 }; 3484 3485 return ease; 3486}, 3487 _configBack = function _configBack(type, overshoot) { 3488 if (overshoot === void 0) { 3489 overshoot = 1.70158; 3490 } 3491 3492 var easeOut = function easeOut(p) { 3493 return p ? --p * p * ((overshoot + 1) * p + overshoot) + 1 : 0; 3494 }, 3495 ease = type === "out" ? easeOut : type === "in" ? function (p) { 3496 return 1 - easeOut(1 - p); 3497 } : _easeInOutFromOut(easeOut); 3498 3499 ease.config = function (overshoot) { 3500 return _configBack(type, overshoot); 3501 }; 3502 3503 return ease; 3504}; // 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. 3505// _weightedEase = ratio => { 3506// let y = 0.5 + ratio / 2; 3507// return p => (2 * (1 - p) * p * y + p * p); 3508// }, 3509// 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. 3510// _weightedEaseStrong = ratio => { 3511// ratio = .5 + ratio / 2; 3512// let o = 1 / 3 * (ratio < .5 ? ratio : 1 - ratio), 3513// b = ratio - o, 3514// c = ratio + o; 3515// return p => p === 1 ? p : 3 * b * (1 - p) * (1 - p) * p + 3 * c * (1 - p) * p * p + p * p * p; 3516// }; 3517 3518 3519_forEachName("Linear,Quad,Cubic,Quart,Quint,Strong", function (name, i) { 3520 var power = i < 5 ? i + 1 : i; 3521 3522 _insertEase(name + ",Power" + (power - 1), i ? function (p) { 3523 return Math.pow(p, power); 3524 } : function (p) { 3525 return p; 3526 }, function (p) { 3527 return 1 - Math.pow(1 - p, power); 3528 }, function (p) { 3529 return p < .5 ? Math.pow(p * 2, power) / 2 : 1 - Math.pow((1 - p) * 2, power) / 2; 3530 }); 3531}); 3532 3533_easeMap.Linear.easeNone = _easeMap.none = _easeMap.Linear.easeIn; 3534 3535_insertEase("Elastic", _configElastic("in"), _configElastic("out"), _configElastic()); 3536 3537(function (n, c) { 3538 var n1 = 1 / c, 3539 n2 = 2 * n1, 3540 n3 = 2.5 * n1, 3541 easeOut = function easeOut(p) { 3542 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; 3543 }; 3544 3545 _insertEase("Bounce", function (p) { 3546 return 1 - easeOut(1 - p); 3547 }, easeOut); 3548})(7.5625, 2.75); 3549 3550_insertEase("Expo", function (p) { 3551 return Math.pow(2, 10 * (p - 1)) * p + p * p * p * p * p * p * (1 - p); 3552}); // previously 2 ** (10 * (p - 1)) but that doesn't end up with the value quite at the right spot so we do a blended ease to ensure it lands where it should perfectly. 3553 3554 3555_insertEase("Circ", function (p) { 3556 return -(_sqrt(1 - p * p) - 1); 3557}); 3558 3559_insertEase("Sine", function (p) { 3560 return p === 1 ? 1 : -_cos(p * _HALF_PI) + 1; 3561}); 3562 3563_insertEase("Back", _configBack("in"), _configBack("out"), _configBack()); 3564 3565_easeMap.SteppedEase = _easeMap.steps = _globals.SteppedEase = { 3566 config: function config(steps, immediateStart) { 3567 if (steps === void 0) { 3568 steps = 1; 3569 } 3570 3571 var p1 = 1 / steps, 3572 p2 = steps + (immediateStart ? 0 : 1), 3573 p3 = immediateStart ? 1 : 0, 3574 max = 1 - _tinyNum; 3575 return function (p) { 3576 return ((p2 * _clamp(0, max, p) | 0) + p3) * p1; 3577 }; 3578 } 3579}; 3580_defaults.ease = _easeMap["quad.out"]; 3581 3582_forEachName("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt", function (name) { 3583 return _callbackNames += name + "," + name + "Params,"; 3584}); 3585/* 3586 * -------------------------------------------------------------------------------------- 3587 * CACHE 3588 * -------------------------------------------------------------------------------------- 3589 */ 3590 3591
3592var GSCache = function GSCache(target, harness) { 3593 this.id = _gsID++; 3594 target._gsap = this; 3595 this.target = target; 3596 this.harness = harness; 3597 this.get = harness ? harness.get : _getProperty; 3598 this.set = harness ? harness.getSetter : _getSetter; 3599}; 3600/* 3601 * -------------------------------------------------------------------------------------- 3602 * ANIMATION 3603 * -------------------------------------------------------------------------------------- 3604 */ 3605
vendor: 108,904 bytes, lines 3606-6413
3606var Animation = /*#__PURE__*/function () { 3607 function Animation(vars) { 3608 this.vars = vars; 3609 this._delay = +vars.delay || 0; 3610 3611 if (this._repeat = vars.repeat === Infinity ? -2 : vars.repeat || 0) { 3612 // 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. 3613 this._rDelay = vars.repeatDelay || 0; 3614 this._yoyo = !!vars.yoyo || !!vars.yoyoEase; 3615 } 3616 3617 this._ts = 1; 3618 3619 _setDuration(this, +vars.duration, 1, 1); 3620 3621 this.data = vars.data; 3622 3623 if (_context) { 3624 this._ctx = _context; 3625 3626 _context.data.push(this); 3627 } 3628 3629 _tickerActive || _ticker.wake(); 3630 } 3631 3632 var _proto = Animation.prototype; 3633 3634 _proto.delay = function delay(value) { 3635 if (value || value === 0) { 3636 this.parent && this.parent.smoothChildTiming && this.startTime(this._start + value - this._delay); 3637 this._delay = value; 3638 return this; 3639 } 3640 3641 return this._delay; 3642 }; 3643 3644 _proto.duration = function duration(value) { 3645 return arguments.length ? this.totalDuration(this._repeat > 0 ? value + (value + this._rDelay) * this._repeat : value) : this.totalDuration() && this._dur; 3646 }; 3647 3648 _proto.totalDuration = function totalDuration(value) { 3649 if (!arguments.length) { 3650 return this._tDur; 3651 } 3652 3653 this._dirty = 0; 3654 return _setDuration(this, this._repeat < 0 ? value : (value - this._repeat * this._rDelay) / (this._repeat + 1)); 3655 }; 3656 3657 _proto.totalTime = function totalTime(_totalTime, suppressEvents) { 3658 _wake(); 3659 3660 if (!arguments.length) { 3661 return this._tTime; 3662 } 3663 3664 var parent = this._dp; 3665 3666 if (parent && parent.smoothChildTiming && this._ts) { 3667 _alignPlayhead(this, _totalTime); 3668 3669 !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. 3670 //in case any of the ancestor timelines had completed but should now be enabled, we should reset their totalTime() which will also ensure that they're lined up properly and enabled. Skip for animations that are on the root (wasteful). Example: a TimelineLite.exportRoot() is performed when there's a paused tween on the root, the export will not complete until that tween is unpaused, but imagine a child gets restarted later, after all [unpaused] tweens have completed. The start of that child would get pushed out, but one of the ancestors may have completed. 3671 3672 while (parent && parent.parent) { 3673 if (parent.parent._time !== parent._start + (parent._ts >= 0 ? parent._tTime / parent._ts : (parent.totalDuration() - parent._tTime) / -parent._ts)) { 3674 parent.totalTime(parent._tTime, true); 3675 } 3676 3677 parent = parent.parent; 3678 } 3679 3680 if (!this.parent && this._dp.autoRemoveChildren && (this._ts > 0 && _totalTime < this._tDur || this._ts < 0 && _totalTime > 0 || !this._tDur && !_totalTime)) { 3681 //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. 3682 _addToTimeline(this._dp, this, this._start - this._delay); 3683 } 3684 } 3685 3686 if (this._tTime !== _totalTime || !this._dur && !suppressEvents || this._initted && Math.abs(this._zTime) === _tinyNum || !this._initted && this._dur && _totalTime || !_totalTime && !this._initted && (this.add || this._ptLookup)) { 3687 // 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) 3688 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 3689 //if (!this._lock) { // avoid endless recursion (not sure we need this yet or if it's worth the performance hit) 3690 // this._lock = 1; 3691 3692 _lazySafeRender(this, _totalTime, suppressEvents); // this._lock = 0; 3693 //} 3694 3695 } 3696 3697 return this; 3698 }; 3699 3700 _proto.time = function time(value, suppressEvents) { 3701 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! 3702 }; 3703 3704 _proto.totalProgress = function totalProgress(value, suppressEvents) { 3705 return arguments.length ? this.totalTime(this.totalDuration() * value, suppressEvents) : this.totalDuration() ? Math.min(1, this._tTime / this._tDur) : this.rawTime() >= 0 && this._initted ? 1 : 0; 3706 }; 3707 3708 _proto.progress = function progress(value, suppressEvents) { 3709 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; 3710 }; 3711 3712 _proto.iteration = function iteration(value, suppressEvents) { 3713 var cycleDuration = this.duration() + this._rDelay; 3714 3715 return arguments.length ? this.totalTime(this._time + (value - 1) * cycleDuration, suppressEvents) : this._repeat ? _animationCycle(this._tTime, cycleDuration) + 1 : 1; 3716 } // potential future addition: 3717 // isPlayingBackwards() { 3718 // let animation = this, 3719 // orientation = 1; // 1 = forward, -1 = backward 3720 // while (animation) { 3721 // orientation *= animation.reversed() || (animation.repeat() && !(animation.iteration() & 1)) ? -1 : 1; 3722 // animation = animation.parent; 3723 // } 3724 // return orientation < 0; 3725 // } 3726 ; 3727 3728 _proto.timeScale = function timeScale(value, suppressEvents) { 3729 if (!arguments.length) { 3730 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. 3731 } 3732 3733 if (this._rts === value) { 3734 return this; 3735 } 3736 3737 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. 3738 // 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. 3739 //(+value < 0 && this._rts >= 0) && _callback(this, "onReverse", true); 3740 // 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. 3741 3742 this._rts = +value || 0; 3743 this._ts = this._ps || value === -_tinyNum ? 0 : this._rts; // _ts is the functional timeScale which would be 0 if the animation is paused. 3744 3745 this.totalTime(_clamp(-Math.abs(this._delay), this.totalDuration(), tTime), suppressEvents !== false); 3746 3747 _setEnd(this); // if parent.smoothChildTiming was false, the end time didn't get updated in the _alignPlayhead() method, so do it here. 3748 3749 3750 return _recacheAncestors(this); 3751 }; 3752 3753 _proto.paused = function paused(value) { 3754 if (!arguments.length) { 3755 return this._ps; 3756 } // possible future addition - if an animation is removed from its parent and then .restart() or .play() or .resume() is called, perhaps we should force it back into the globalTimeline but be careful because what if it's already at its end? We don't want it to just persist forever and not get released for GC. 3757 // !this.parent && !value && this._tTime < this._tDur && this !== _globalTimeline && _globalTimeline.add(this); 3758 3759 3760 if (this._ps !== value) { 3761 this._ps = value; 3762 3763 if (value) { 3764 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. 3765 3766 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) 3767 } else { 3768 _wake(); 3769 3770 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. 3771 3772 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. 3773 } 3774 } 3775 3776 return this; 3777 }; 3778 3779 _proto.startTime = function startTime(value) { 3780 if (arguments.length) { 3781 this._start = _roundPrecise(value); 3782 var parent = this.parent || this._dp; 3783 parent && (parent._sort || !this.parent) && _addToTimeline(parent, this, this._start - this._delay); 3784 return this; 3785 } 3786 3787 return this._start; 3788 }; 3789 3790 _proto.endTime = function endTime(includeRepeats) { 3791 return this._start + (_isNotFalse(includeRepeats) ? this.totalDuration() : this.duration()) / Math.abs(this._ts || 1); 3792 }; 3793 3794 _proto.rawTime = function rawTime(wrapRepeats) { 3795 var parent = this.parent || this._dp; // _dp = detached parent 3796 3797 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); 3798 }; 3799 3800 _proto.revert = function revert(config) { 3801 if (config === void 0) { 3802 config = _revertConfig; 3803 } 3804 3805 var prevIsReverting = _reverting; 3806 _reverting = config; 3807 3808 if (_isRevertWorthy(this)) { 3809 this.timeline && this.timeline.revert(config); 3810 this.totalTime(-0.01, config.suppressEvents); 3811 } 3812 3813 this.data !== "nested" && config.kill !== false && this.kill(); 3814 _reverting = prevIsReverting; 3815 return this; 3816 }; 3817 3818 _proto.globalTime = function globalTime(rawTime) { 3819 var animation = this, 3820 time = arguments.length ? rawTime : animation.rawTime(); 3821 3822 while (animation) { 3823 time = animation._start + time / (Math.abs(animation._ts) || 1); 3824 animation = animation._dp; 3825 } 3826 3827 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(). 3828 }; 3829 3830 _proto.repeat = function repeat(value) { 3831 if (arguments.length) { 3832 this._repeat = value === Infinity ? -2 : value; 3833 return _onUpdateTotalDuration(this); 3834 } 3835 3836 return this._repeat === -2 ? Infinity : this._repeat; 3837 }; 3838 3839 _proto.repeatDelay = function repeatDelay(value) { 3840 if (arguments.length) { 3841 var time = this._time; 3842 this._rDelay = value; 3843 3844 _onUpdateTotalDuration(this); 3845 3846 return time ? this.time(time) : this; 3847 } 3848 3849 return this._rDelay; 3850 }; 3851 3852 _proto.yoyo = function yoyo(value) { 3853 if (arguments.length) { 3854 this._yoyo = value; 3855 return this; 3856 } 3857 3858 return this._yoyo; 3859 }; 3860 3861 _proto.seek = function seek(position, suppressEvents) { 3862 return this.totalTime(_parsePosition(this, position), _isNotFalse(suppressEvents)); 3863 }; 3864 3865 _proto.restart = function restart(includeDelay, suppressEvents) { 3866 this.play().totalTime(includeDelay ? -this._delay : 0, _isNotFalse(suppressEvents)); 3867 this._dur || (this._zTime = -_tinyNum); // ensures onComplete fires on a zero-duration animation that gets restarted. 3868 3869 return this; 3870 }; 3871 3872 _proto.play = function play(from, suppressEvents) { 3873 from != null && this.seek(from, suppressEvents); 3874 return this.reversed(false).paused(false); 3875 }; 3876 3877 _proto.reverse = function reverse(from, suppressEvents) { 3878 from != null && this.seek(from || this.totalDuration(), suppressEvents); 3879 return this.reversed(true).paused(false); 3880 }; 3881 3882 _proto.pause = function pause(atTime, suppressEvents) { 3883 atTime != null && this.seek(atTime, suppressEvents); 3884 return this.paused(true); 3885 }; 3886 3887 _proto.resume = function resume() { 3888 return this.paused(false); 3889 }; 3890 3891 _proto.reversed = function reversed(value) { 3892 if (arguments.length) { 3893 !!value !== this.reversed() && this.timeScale(-this._rts || (value ? -_tinyNum : 0)); // in case timeScale is zero, reversing would have no effect so we use _tinyNum. 3894 3895 return this; 3896 } 3897 3898 return this._rts < 0; 3899 }; 3900 3901 _proto.invalidate = function invalidate() { 3902 this._initted = this._act = 0; 3903 this._zTime = -_tinyNum; 3904 return this; 3905 }; 3906 3907 _proto.isActive = function isActive() { 3908 var parent = this.parent || this._dp, 3909 start = this._start, 3910 rawTime; 3911 return !!(!parent || this._ts && this._initted && parent.isActive() && (rawTime = parent.rawTime(true)) >= start && rawTime < this.endTime(true) - _tinyNum); 3912 }; 3913 3914 _proto.eventCallback = function eventCallback(type, callback, params) { 3915 var vars = this.vars; 3916 3917 if (arguments.length > 1) { 3918 if (!callback) { 3919 delete vars[type]; 3920 } else { 3921 vars[type] = callback; 3922 params && (vars[type + "Params"] = params); 3923 type === "onUpdate" && (this._onUpdate = callback); 3924 } 3925 3926 return this; 3927 } 3928 3929 return vars[type]; 3930 }; 3931 3932 _proto.then = function then(onFulfilled) { 3933 var self = this, 3934 prevProm = self._prom; 3935 return new Promise(function (resolve) { 3936 var f = _isFunction(onFulfilled) ? onFulfilled : _passThrough, 3937 _resolve = function _resolve() { 3938 var _then = self.then; 3939 self.then = null; // temporarily null the then() method to avoid an infinite loop (see https://github.com/greensock/GSAP/issues/322) 3940 3941 prevProm && prevProm(); 3942 _isFunction(f) && (f = f(self)) && (f.then || f === self) && (self.then = _then); 3943 resolve(f); 3944 self.then = _then; 3945 }; 3946 3947 if (self._initted && self.totalProgress() === 1 && self._ts >= 0 || !self._tTime && self._ts < 0) { 3948 _resolve(); 3949 } else { 3950 self._prom = _resolve; 3951 } 3952 }); 3953 }; 3954 3955 _proto.kill = function kill() { 3956 _interrupt(this); 3957 }; 3958 3959 return Animation; 3960}(); 3961 3962_setDefaults(Animation.prototype, { 3963 _time: 0, 3964 _start: 0, 3965 _end: 0, 3966 _tTime: 0, 3967 _tDur: 0, 3968 _dirty: 0, 3969 _repeat: 0, 3970 _yoyo: false, 3971 parent: null, 3972 _initted: false, 3973 _rDelay: 0, 3974 _ts: 1, 3975 _dp: 0, 3976 ratio: 0, 3977 _zTime: -_tinyNum, 3978 _prom: 0, 3979 _ps: false, 3980 _rts: 1 3981}); 3982/* 3983 * ------------------------------------------------- 3984 * TIMELINE 3985 * ------------------------------------------------- 3986 */ 3987 3988 3989var Timeline = /*#__PURE__*/function (_Animation) { 3990 _inheritsLoose(Timeline, _Animation); 3991 3992 function Timeline(vars, position) { 3993 var _this; 3994 3995 if (vars === void 0) { 3996 vars = {}; 3997 } 3998 3999 _this = _Animation.call(this, vars) || this; 4000 _this.labels = {}; 4001 _this.smoothChildTiming = !!vars.smoothChildTiming; 4002 _this.autoRemoveChildren = !!vars.autoRemoveChildren; 4003 _this._sort = _isNotFalse(vars.sortChildren); 4004 _globalTimeline && _addToTimeline(vars.parent || _globalTimeline, _assertThisInitialized(_this), position); 4005 vars.reversed && _this.reverse(); 4006 vars.paused && _this.paused(true); 4007 vars.scrollTrigger && _scrollTrigger(_assertThisInitialized(_this), vars.scrollTrigger); 4008 return _this; 4009 } 4010 4011 var _proto2 = Timeline.prototype; 4012 4013 _proto2.to = function to(targets, vars, position) { 4014 _createTweenType(0, arguments, this); 4015 4016 return this; 4017 }; 4018 4019 _proto2.from = function from(targets, vars, position) { 4020 _createTweenType(1, arguments, this); 4021 4022 return this; 4023 }; 4024 4025 _proto2.fromTo = function fromTo(targets, fromVars, toVars, position) { 4026 _createTweenType(2, arguments, this); 4027 4028 return this; 4029 }; 4030 4031 _proto2.set = function set(targets, vars, position) { 4032 vars.duration = 0; 4033 vars.parent = this; 4034 _inheritDefaults(vars).repeatDelay || (vars.repeat = 0); 4035 vars.immediateRender = !!vars.immediateRender; 4036 new Tween(targets, vars, _parsePosition(this, position), 1); 4037 return this; 4038 }; 4039 4040 _proto2.call = function call(callback, params, position) { 4041 return _addToTimeline(this, Tween.delayedCall(0, callback, params), position); 4042 } //ONLY for backward compatibility! Maybe delete? 4043 ; 4044 4045 _proto2.staggerTo = function staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) { 4046 vars.duration = duration; 4047 vars.stagger = vars.stagger || stagger; 4048 vars.onComplete = onCompleteAll; 4049 vars.onCompleteParams = onCompleteAllParams; 4050 vars.parent = this; 4051 new Tween(targets, vars, _parsePosition(this, position)); 4052 return this; 4053 }; 4054 4055 _proto2.staggerFrom = function staggerFrom(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) { 4056 vars.runBackwards = 1; 4057 _inheritDefaults(vars).immediateRender = _isNotFalse(vars.immediateRender); 4058 return this.staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams); 4059 }; 4060 4061 _proto2.staggerFromTo = function staggerFromTo(targets, duration, fromVars, toVars, stagger, position, onCompleteAll, onCompleteAllParams) { 4062 toVars.startAt = fromVars; 4063 _inheritDefaults(toVars).immediateRender = _isNotFalse(toVars.immediateRender); 4064 return this.staggerTo(targets, duration, toVars, stagger, position, onCompleteAll, onCompleteAllParams); 4065 }; 4066 4067 _proto2.render = function render(totalTime, suppressEvents, force) { 4068 var prevTime = this._time, 4069 tDur = this._dirty ? this.totalDuration() : this._tDur, 4070 dur = this._dur, 4071 tTime = totalTime <= 0 ? 0 : _roundPrecise(totalTime), 4072 // 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. 4073 crossingStart = this._zTime < 0 !== totalTime < 0 && (this._initted || !dur), 4074 time, 4075 child, 4076 next, 4077 iteration, 4078 cycleDuration, 4079 prevPaused, 4080 pauseTween, 4081 timeScale, 4082 prevStart, 4083 prevIteration, 4084 yoyo, 4085 isYoyo; 4086 this !== _globalTimeline && tTime > tDur && totalTime >= 0 && (tTime = tDur); 4087 4088 if (tTime !== this._tTime || force || crossingStart) { 4089 if (prevTime !== this._time && dur) { 4090 //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). 4091 tTime += this._time - prevTime; 4092 totalTime += this._time - prevTime; 4093 } 4094 4095 time = tTime; 4096 prevStart = this._start; 4097 timeScale = this._ts; 4098 prevPaused = !timeScale; 4099 4100 if (crossingStart) { 4101 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. 4102 4103 (totalTime || !suppressEvents) && (this._zTime = totalTime); 4104 } 4105 4106 if (this._repeat) { 4107 //adjust the time for repeats and yoyos 4108 yoyo = this._yoyo; 4109 cycleDuration = dur + this._rDelay; 4110 4111 if (this._repeat < -1 && totalTime < 0) { 4112 return this.totalTime(cycleDuration * 100 + totalTime, suppressEvents, force); 4113 } 4114 4115 time = _roundPrecise(tTime % cycleDuration); //round to avoid floating point errors. (4 % 0.8 should be 0 but some browsers report it as 0.79999999!) 4116 4117 if (tTime === tDur) { 4118 // 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) 4119 iteration = this._repeat; 4120 time = dur; 4121 } else { 4122 prevIteration = _roundPrecise(tTime / cycleDuration); // full decimal version of iterations, not the previous iteration (we're reusing prevIteration variable for efficiency) 4123 4124 iteration = ~~prevIteration; 4125 4126 if (iteration && iteration === prevIteration) { 4127 time = dur; 4128 iteration--; 4129 } 4130 4131 time > dur && (time = dur); 4132 } 4133 4134 prevIteration = _animationCycle(this._tTime, cycleDuration); 4135 !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 4136 4137 if (yoyo && iteration & 1) { 4138 time = dur - time; 4139 isYoyo = 1; 4140 } 4141 /* 4142 make sure children at the end/beginning of the timeline are rendered properly. If, for example, 4143 a 3-second long timeline rendered at 2.9 seconds previously, and now renders at 3.2 seconds (which 4144 would get translated to 2.8 seconds if the timeline yoyos or 0.2 seconds if it just repeats), there 4145 could be a callback or a short tween that's at 2.95 or 3 seconds in which wouldn't render. So 4146 we need to push the timeline to the end (and/or beginning depending on its yoyo value). Also we must 4147 ensure that zero-duration tweens at the very beginning or end of the Timeline work. 4148 */ 4149 4150 4151 if (iteration !== prevIteration && !this._lock) { 4152 var rewinding = yoyo && prevIteration & 1, 4153 doesWrap = rewinding === (yoyo && iteration & 1); 4154 iteration < prevIteration && (rewinding = !rewinding); 4155 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. 4156 4157 this._lock = 1; 4158 this.render(prevTime || (isYoyo ? 0 : _roundPrecise(iteration * cycleDuration)), suppressEvents, !dur)._lock = 0; 4159 this._tTime = tTime; // if a user gets the iteration() inside the onRepeat, for example, it should be accurate. 4160 4161 !suppressEvents && this.parent && _callback(this, "onRepeat"); 4162 4163 if (this.vars.repeatRefresh && !isYoyo) { 4164 this.invalidate()._lock = 1; 4165 prevIteration = iteration; // otherwise, the onStart() may fire on the 2nd iteration. 4166 } 4167 4168 if (prevTime && prevTime !== this._time || prevPaused !== !this._ts || this.vars.onRepeat && !this.parent && !this._act) { 4169 // 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. 4170 return this; 4171 } 4172 4173 dur = this._dur; // in case the duration changed in the onRepeat 4174 4175 tDur = this._tDur; 4176 4177 if (doesWrap) { 4178 this._lock = 2; 4179 prevTime = rewinding ? dur : -0.0001; 4180 this.render(prevTime, true); 4181 this.vars.repeatRefresh && !isYoyo && this.invalidate(); 4182 } 4183 4184 this._lock = 0; 4185 4186 if (!this._ts && !prevPaused) { 4187 return this; 4188 } 4189 } 4190 } 4191 4192 if (this._hasPause && !this._forcing && this._lock < 2) { 4193 pauseTween = _findNextPauseTween(this, _roundPrecise(prevTime), _roundPrecise(time)); 4194 4195 if (pauseTween) { 4196 tTime -= time - (time = pauseTween._start); 4197 } 4198 } 4199 4200 this._tTime = tTime; 4201 this._time = time; 4202 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. 4203 4204 if (!this._initted) { 4205 this._onUpdate = this.vars.onUpdate; 4206 this._initted = 1; 4207 this._zTime = totalTime; 4208 prevTime = 0; // upon init, the playhead should always go forward; 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}). 4209 } 4210 4211 if (!prevTime && tTime && dur && !suppressEvents && !prevIteration) { 4212 _callback(this, "onStart"); 4213 4214 if (this._tTime !== tTime) { 4215 // 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. 4216 return this; 4217 } 4218 } 4219 4220 if (time >= prevTime && totalTime >= 0) { 4221 child = this._first; 4222 4223 while (child) { 4224 next = child._next; 4225 4226 if ((child._act || time >= child._start) && child._ts && pauseTween !== child) { 4227 if (child.parent !== this) { 4228 // 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. 4229 return this.render(totalTime, suppressEvents, force); 4230 } 4231 4232 child.render(child._ts > 0 ? (time - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (time - child._start) * child._ts, suppressEvents, force); 4233 4234 if (time !== this._time || !this._ts && !prevPaused) { 4235 //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete 4236 pauseTween = 0; 4237 next && (tTime += this._zTime = -_tinyNum); // it didn't finish rendering, so flag zTime as negative so that the next time render() is called it'll be forced (to render any remaining children) 4238 4239 break; 4240 } 4241 } 4242 4243 child = next; 4244 } 4245 } else { 4246 child = this._last; 4247 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. 4248 4249 while (child) { 4250 next = child._prev; 4251 4252 if ((child._act || adjustedTime <= child._end) && child._ts && pauseTween !== child) { 4253 if (child.parent !== this) { 4254 // 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. 4255 return this.render(totalTime, suppressEvents, force); 4256 } 4257 4258 child.render(child._ts > 0 ? (adjustedTime - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (adjustedTime - child._start) * child._ts, suppressEvents, force || _reverting && _isRevertWorthy(child)); // 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. 4259 4260 if (time !== this._time || !this._ts && !prevPaused) { 4261 //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete 4262 pauseTween = 0; 4263 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) 4264 4265 break; 4266 } 4267 } 4268 4269 child = next; 4270 } 4271 } 4272 4273 if (pauseTween && !suppressEvents) { 4274 this.pause(); 4275 pauseTween.render(time >= prevTime ? 0 : -_tinyNum)._zTime = time >= prevTime ? 1 : -1; 4276 4277 if (this._ts) { 4278 //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). 4279 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. 4280 4281 _setEnd(this); 4282 4283 return this.render(totalTime, suppressEvents, force); 4284 } 4285 } 4286 4287 this._onUpdate && !suppressEvents && _callback(this, "onUpdate", true); 4288 if (tTime === tDur && this._tTime >= this.totalDuration() || !tTime && prevTime) if (prevStart === this._start || Math.abs(timeScale) !== Math.abs(this._ts)) if (!this._lock) { 4289 // remember, a child's callback may alter this timeline's playhead or timeScale which is why we need to add some of these checks. 4290 (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. 4291 4292 if (!suppressEvents && !(totalTime < 0 && !prevTime) && (tTime || prevTime || !tDur)) { 4293 _callback(this, tTime === tDur && totalTime >= 0 ? "onComplete" : "onReverseComplete", true); 4294 4295 this._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom(); 4296 } 4297 } 4298 } 4299 4300 return this; 4301 }; 4302 4303 _proto2.add = function add(child, position) { 4304 var _this2 = this; 4305 4306 _isNumber(position) || (position = _parsePosition(this, position, child)); 4307 4308 if (!(child instanceof Animation)) { 4309 if (_isArray(child)) { 4310 child.forEach(function (obj) { 4311 return _this2.add(obj, position); 4312 }); 4313 return this; 4314 } 4315 4316 if (_isString(child)) { 4317 return this.addLabel(child, position); 4318 } 4319 4320 if (_isFunction(child)) { 4321 child = Tween.delayedCall(0, child); 4322 } else { 4323 return this; 4324 } 4325 } 4326 4327 return this !== child ? _addToTimeline(this, child, position) : this; //don't allow a timeline to be added to itself as a child! 4328 }; 4329 4330 _proto2.getChildren = function getChildren(nested, tweens, timelines, ignoreBeforeTime) { 4331 if (nested === void 0) { 4332 nested = true; 4333 } 4334 4335 if (tweens === void 0) { 4336 tweens = true; 4337 } 4338 4339 if (timelines === void 0) { 4340 timelines = true; 4341 } 4342 4343 if (ignoreBeforeTime === void 0) { 4344 ignoreBeforeTime = -_bigNum; 4345 } 4346 4347 var a = [], 4348 child = this._first; 4349 4350 while (child) { 4351 if (child._start >= ignoreBeforeTime) { 4352 if (child instanceof Tween) { 4353 tweens && a.push(child); 4354 } else { 4355 timelines && a.push(child); 4356 nested && a.push.apply(a, child.getChildren(true, tweens, timelines)); 4357 } 4358 } 4359 4360 child = child._next; 4361 } 4362 4363 return a; 4364 }; 4365 4366 _proto2.getById = function getById(id) { 4367 var animations = this.getChildren(1, 1, 1), 4368 i = animations.length; 4369 4370 while (i--) { 4371 if (animations[i].vars.id === id) { 4372 return animations[i]; 4373 } 4374 } 4375 }; 4376 4377 _proto2.remove = function remove(child) { 4378 if (_isString(child)) { 4379 return this.removeLabel(child); 4380 } 4381 4382 if (_isFunction(child)) { 4383 return this.killTweensOf(child); 4384 } 4385 4386 child.parent === this && _removeLinkedListItem(this, child); 4387 4388 if (child === this._recent) { 4389 this._recent = this._last; 4390 } 4391 4392 return _uncache(this); 4393 }; 4394 4395 _proto2.totalTime = function totalTime(_totalTime2, suppressEvents) { 4396 if (!arguments.length) { 4397 return this._tTime; 4398 } 4399 4400 this._forcing = 1; 4401 4402 if (!this._dp && this._ts) { 4403 //special case for the global timeline (or any other that has no parent or detached parent). 4404 this._start = _roundPrecise(_ticker.time - (this._ts > 0 ? _totalTime2 / this._ts : (this.totalDuration() - _totalTime2) / -this._ts)); 4405 } 4406 4407 _Animation.prototype.totalTime.call(this, _totalTime2, suppressEvents); 4408 4409 this._forcing = 0; 4410 return this; 4411 }; 4412 4413 _proto2.addLabel = function addLabel(label, position) { 4414 this.labels[label] = _parsePosition(this, position); 4415 return this; 4416 }; 4417 4418 _proto2.removeLabel = function removeLabel(label) { 4419 delete this.labels[label]; 4420 return this; 4421 }; 4422 4423 _proto2.addPause = function addPause(position, callback, params) { 4424 var t = Tween.delayedCall(0, callback || _emptyFunc, params); 4425 t.data = "isPause"; 4426 this._hasPause = 1; 4427 return _addToTimeline(this, t, _parsePosition(this, position)); 4428 }; 4429 4430 _proto2.removePause = function removePause(position) { 4431 var child = this._first; 4432 position = _parsePosition(this, position); 4433 4434 while (child) { 4435 if (child._start === position && child.data === "isPause") { 4436 _removeFromParent(child); 4437 } 4438 4439 child = child._next; 4440 } 4441 }; 4442 4443 _proto2.killTweensOf = function killTweensOf(targets, props, onlyActive) { 4444 var tweens = this.getTweensOf(targets, onlyActive), 4445 i = tweens.length; 4446 4447 while (i--) { 4448 _overwritingTween !== tweens[i] && tweens[i].kill(targets, props); 4449 } 4450 4451 return this; 4452 }; 4453 4454 _proto2.getTweensOf = function getTweensOf(targets, onlyActive) { 4455 var a = [], 4456 parsedTargets = toArray(targets), 4457 child = this._first, 4458 isGlobalTime = _isNumber(onlyActive), 4459 // a number is interpreted as a global time. If the animation spans 4460 children; 4461 4462 while (child) { 4463 if (child instanceof Tween) { 4464 if (_arrayContainsAny(child._targets, parsedTargets) && (isGlobalTime ? (!_overwritingTween || child._initted && child._ts) && child.globalTime(0) <= onlyActive && child.globalTime(child.totalDuration()) > onlyActive : !onlyActive || child.isActive())) { 4465 // note: if this is for overwriting, it should only be for tweens that aren't paused and are initted. 4466 a.push(child); 4467 } 4468 } else if ((children = child.getTweensOf(parsedTargets, onlyActive)).length) { 4469 a.push.apply(a, children); 4470 } 4471 4472 child = child._next; 4473 } 4474 4475 return a; 4476 } // potential future feature - targets() on timelines 4477 // targets() { 4478 // let result = []; 4479 // this.getChildren(true, true, false).forEach(t => result.push(...t.targets())); 4480 // return result.filter((v, i) => result.indexOf(v) === i); 4481 // } 4482 ; 4483 4484 _proto2.tweenTo = function tweenTo(position, vars) { 4485 vars = vars || {}; 4486 4487 var tl = this, 4488 endTime = _parsePosition(tl, position), 4489 _vars = vars, 4490 startAt = _vars.startAt, 4491 _onStart = _vars.onStart, 4492 onStartParams = _vars.onStartParams, 4493 immediateRender = _vars.immediateRender, 4494 initted, 4495 tween = Tween.to(tl, _setDefaults({ 4496 ease: vars.ease || "none", 4497 lazy: false, 4498 immediateRender: false, 4499 time: endTime, 4500 overwrite: "auto", 4501 duration: vars.duration || Math.abs((endTime - (startAt && "time" in startAt ? startAt.time : tl._time)) / tl.timeScale()) || _tinyNum, 4502 onStart: function onStart() { 4503 tl.pause(); 4504 4505 if (!initted) { 4506 var duration = vars.duration || Math.abs((endTime - (startAt && "time" in startAt ? startAt.time : tl._time)) / tl.timeScale()); 4507 tween._dur !== duration && _setDuration(tween, duration, 0, 1).render(tween._time, true, true); 4508 initted = 1; 4509 } 4510 4511 _onStart && _onStart.apply(tween, onStartParams || []); //in case the user had an onStart in the vars - we don't want to overwrite it. 4512 } 4513 }, vars)); 4514 4515 return immediateRender ? tween.render(0) : tween; 4516 }; 4517 4518 _proto2.tweenFromTo = function tweenFromTo(fromPosition, toPosition, vars) { 4519 return this.tweenTo(toPosition, _setDefaults({ 4520 startAt: { 4521 time: _parsePosition(this, fromPosition) 4522 } 4523 }, vars)); 4524 }; 4525 4526 _proto2.recent = function recent() { 4527 return this._recent; 4528 }; 4529 4530 _proto2.nextLabel = function nextLabel(afterTime) { 4531 if (afterTime === void 0) { 4532 afterTime = this._time; 4533 } 4534 4535 return _getLabelInDirection(this, _parsePosition(this, afterTime)); 4536 }; 4537 4538 _proto2.previousLabel = function previousLabel(beforeTime) { 4539 if (beforeTime === void 0) { 4540 beforeTime = this._time; 4541 } 4542 4543 return _getLabelInDirection(this, _parsePosition(this, beforeTime), 1); 4544 }; 4545 4546 _proto2.currentLabel = function currentLabel(value) { 4547 return arguments.length ? this.seek(value, true) : this.previousLabel(this._time + _tinyNum); 4548 }; 4549 4550 _proto2.shiftChildren = function shiftChildren(amount, adjustLabels, ignoreBeforeTime) { 4551 if (ignoreBeforeTime === void 0) { 4552 ignoreBeforeTime = 0; 4553 } 4554 4555 var child = this._first, 4556 labels = this.labels, 4557 p; 4558 amount = _roundPrecise(amount); 4559 4560 while (child) { 4561 if (child._start >= ignoreBeforeTime) { 4562 child._start += amount; 4563 child._end += amount; 4564 } 4565 4566 child = child._next; 4567 } 4568 4569 if (adjustLabels) { 4570 for (p in labels) { 4571 if (labels[p] >= ignoreBeforeTime) { 4572 labels[p] += amount; 4573 } 4574 } 4575 } 4576 4577 return _uncache(this); 4578 }; 4579 4580 _proto2.invalidate = function invalidate(soft) { 4581 var child = this._first; 4582 this._lock = 0; 4583 4584 while (child) { 4585 child.invalidate(soft); 4586 child = child._next; 4587 } 4588 4589 return _Animation.prototype.invalidate.call(this, soft); 4590 }; 4591 4592 _proto2.clear = function clear(includeLabels) { 4593 if (includeLabels === void 0) { 4594 includeLabels = true; 4595 } 4596 4597 var child = this._first, 4598 next; 4599 4600 while (child) { 4601 next = child._next; 4602 this.remove(child); 4603 child = next; 4604 } 4605 4606 this._dp && (this._time = this._tTime = this._pTime = 0); 4607 includeLabels && (this.labels = {}); 4608 return _uncache(this); 4609 }; 4610 4611 _proto2.totalDuration = function totalDuration(value) { 4612 var max = 0, 4613 self = this, 4614 child = self._last, 4615 prevStart = _bigNum, 4616 prev, 4617 start, 4618 parent; 4619 4620 if (arguments.length) { 4621 return self.timeScale((self._repeat < 0 ? self.duration() : self.totalDuration()) / (self.reversed() ? -value : value)); 4622 } 4623 4624 if (self._dirty) { 4625 parent = self.parent; 4626 4627 while (child) { 4628 prev = child._prev; //record it here in case the tween changes position in the sequence... 4629 4630 child._dirty && child.totalDuration(); //could change the tween._startTime, so make sure the animation's cache is clean before analyzing it. 4631 4632 start = child._start; 4633 4634 if (start > prevStart && self._sort && child._ts && !self._lock) { 4635 //in case one of the tweens shifted out of order, it needs to be re-inserted into the correct position in the sequence 4636 self._lock = 1; //prevent endless recursive calls - there are methods that get triggered that check duration/totalDuration when we add(). 4637 4638 _addToTimeline(self, child, start - child._delay, 1)._lock = 0; 4639 } else { 4640 prevStart = start; 4641 } 4642 4643 if (start < 0 && child._ts) { 4644 //children aren't allowed to have negative startTimes unless smoothChildTiming is true, so adjust here if one is found. 4645 max -= start; 4646 4647 if (!parent && !self._dp || parent && parent.smoothChildTiming) { 4648 self._start += _roundPrecise(start / self._ts); 4649 self._time -= start; 4650 self._tTime -= start; 4651 } 4652 4653 self.shiftChildren(-start, false, -1e999); 4654 prevStart = 0; 4655 } 4656 4657 child._end > max && child._ts && (max = child._end); 4658 child = prev; 4659 } 4660 4661 _setDuration(self, self === _globalTimeline && self._time > max ? self._time : max, 1, 1); 4662 4663 self._dirty = 0; 4664 } 4665 4666 return self._tDur; 4667 }; 4668 4669 Timeline.updateRoot = function updateRoot(time) { 4670 if (_globalTimeline._ts) { 4671 _lazySafeRender(_globalTimeline, _parentToChildTotalTime(time, _globalTimeline)); 4672 4673 _lastRenderedFrame = _ticker.frame; 4674 } 4675 4676 if (_ticker.frame >= _nextGCFrame) { 4677 _nextGCFrame += _config.autoSleep || 120; 4678 var child = _globalTimeline._first; 4679 if (!child || !child._ts) if (_config.autoSleep && _ticker._listeners.length < 2) { 4680 while (child && !child._ts) { 4681 child = child._next; 4682 } 4683 4684 child || _ticker.sleep(); 4685 } 4686 } 4687 }; 4688 4689 return Timeline; 4690}(Animation); 4691 4692_setDefaults(Timeline.prototype, { 4693 _lock: 0, 4694 _hasPause: 0, 4695 _forcing: 0 4696}); 4697 4698var _addComplexStringPropTween = function _addComplexStringPropTween(target, prop, start, end, setter, stringFilter, funcParam) { 4699 //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. 4700 var pt = new PropTween(this._pt, target, prop, 0, 1, _renderComplexString, null, setter), 4701 index = 0, 4702 matchIndex = 0, 4703 result, 4704 startNums, 4705 color, 4706 endNum, 4707 chunk, 4708 startNum, 4709 hasRandom, 4710 a; 4711 pt.b = start; 4712 pt.e = end; 4713 start += ""; //ensure values are strings 4714 4715 end += ""; 4716 4717 if (hasRandom = ~end.indexOf("random(")) { 4718 end = _replaceRandom(end); 4719 } 4720 4721 if (stringFilter) { 4722 a = [start, end]; 4723 stringFilter(a, target, prop); //pass an array with the starting and ending values and let the filter do whatever it needs to the values. 4724 4725 start = a[0]; 4726 end = a[1]; 4727 } 4728 4729 startNums = start.match(_complexStringNumExp) || []; 4730 4731 while (result = _complexStringNumExp.exec(end)) { 4732 endNum = result[0]; 4733 chunk = end.substring(index, result.index); 4734 4735 if (color) { 4736 color = (color + 1) % 5; 4737 } else if (chunk.substr(-5) === "rgba(") { 4738 color = 1; 4739 } 4740 4741 if (endNum !== startNums[matchIndex++]) { 4742 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. 4743 4744 pt._pt = { 4745 _next: pt._pt, 4746 p: chunk || matchIndex === 1 ? chunk : ",", 4747 //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. 4748 s: startNum, 4749 c: endNum.charAt(1) === "=" ? _parseRelative(startNum, endNum) - startNum : parseFloat(endNum) - startNum, 4750 m: color && color < 4 ? Math.round : 0 4751 }; 4752 index = _complexStringNumExp.lastIndex; 4753 } 4754 } 4755 4756 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) 4757 4758 pt.fp = funcParam; 4759 4760 if (_relExp.test(end) || hasRandom) { 4761 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). 4762 } 4763 4764 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. 4765 4766 return pt; 4767}, 4768 _addPropTween = function _addPropTween(target, prop, start, end, index, targets, modifier, stringFilter, funcParam, optional) { 4769 _isFunction(end) && (end = end(index || 0, target, targets)); 4770 var currentValue = target[prop], 4771 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](), 4772 setter = !_isFunction(currentValue) ? _setterPlain : funcParam ? _setterFuncWithParam : _setterFunc, 4773 pt; 4774 4775 if (_isString(end)) { 4776 if (~end.indexOf("random(")) { 4777 end = _replaceRandom(end); 4778 } 4779 4780 if (end.charAt(1) === "=") { 4781 pt = _parseRelative(parsedStart, end) + (getUnit(parsedStart) || 0); 4782 4783 if (pt || pt === 0) { 4784 // to avoid isNaN, like if someone passes in a value like "!= whatever" 4785 end = pt; 4786 } 4787 } 4788 } 4789 4790 if (!optional || parsedStart !== end || _forceAllPropTweens) { 4791 if (!isNaN(parsedStart * end) && end !== "") { 4792 // fun fact: any number multiplied by "" is evaluated as the number 0! 4793 pt = new PropTween(this._pt, target, prop, +parsedStart || 0, end - (parsedStart || 0), typeof currentValue === "boolean" ? _renderBoolean : _renderPlain, 0, setter); 4794 funcParam && (pt.fp = funcParam); 4795 modifier && pt.modifier(modifier, this, target); 4796 return this._pt = pt; 4797 } 4798 4799 !currentValue && !(prop in target) && _missingPlugin(prop, end); 4800 return _addComplexStringPropTween.call(this, target, prop, parsedStart, end, setter, stringFilter || _config.stringFilter, funcParam); 4801 } 4802}, 4803 //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. 4804_processVars = function _processVars(vars, index, target, targets, tween) { 4805 _isFunction(vars) && (vars = _parseFuncOrString(vars, tween, index, target, targets)); 4806 4807 if (!_isObject(vars) || vars.style && vars.nodeType || _isArray(vars) || _isTypedArray(vars)) { 4808 return _isString(vars) ? _parseFuncOrString(vars, tween, index, target, targets) : vars; 4809 } 4810 4811 var copy = {}, 4812 p; 4813 4814 for (p in vars) { 4815 copy[p] = _parseFuncOrString(vars[p], tween, index, target, targets); 4816 } 4817 4818 return copy; 4819}, 4820 _checkPlugin = function _checkPlugin(property, vars, tween, index, target, targets) { 4821 var plugin, pt, ptLookup, i; 4822 4823 if (_plugins[property] && (plugin = new _plugins[property]()).init(target, plugin.rawVars ? vars[property] : _processVars(vars[property], index, target, targets, tween), tween, index, targets) !== false) { 4824 tween._pt = pt = new PropTween(tween._pt, target, property, 0, 1, plugin.render, plugin, 0, plugin.priority); 4825 4826 if (tween !== _quickTween) { 4827 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. 4828 4829 i = plugin._props.length; 4830 4831 while (i--) { 4832 ptLookup[plugin._props[i]] = pt; 4833 } 4834 } 4835 } 4836 4837 return plugin; 4838}, 4839 _overwritingTween, 4840 //store a reference temporarily so we can avoid overwriting itself. 4841_forceAllPropTweens, 4842 _initTween = function _initTween(tween, time, tTime) { 4843 var vars = tween.vars, 4844 ease = vars.ease, 4845 startAt = vars.startAt, 4846 immediateRender = vars.immediateRender, 4847 lazy = vars.lazy, 4848 onUpdate = vars.onUpdate, 4849 runBackwards = vars.runBackwards, 4850 yoyoEase = vars.yoyoEase, 4851 keyframes = vars.keyframes, 4852 autoRevert = vars.autoRevert, 4853 dur = tween._dur, 4854 prevStartAt = tween._startAt, 4855 targets = tween._targets, 4856 parent = tween.parent, 4857 fullTargets = parent && parent.data === "nested" ? parent.vars.targets : targets, 4858 autoOverwrite = tween._overwrite === "auto" && !_suppressOverwrites, 4859 tl = tween.timeline, 4860 reverseEase = vars.easeReverse || yoyoEase, 4861 cleanVars, 4862 i, 4863 p, 4864 pt, 4865 target, 4866 hasPriority, 4867 gsData, 4868 harness, 4869 plugin, 4870 ptLookup, 4871 index, 4872 harnessVars, 4873 overwritten; 4874 tl && (!keyframes || !ease) && (ease = "none"); 4875 tween._ease = _parseEase(ease, _defaults.ease); 4876 tween._rEase = reverseEase && (_parseEase(reverseEase) || tween._ease); 4877 tween._from = !tl && !!vars.runBackwards; //nested timelines should never run backwards - the backwards-ness is in the child tweens. 4878 4879 if (tween._from) tween.ratio = 1; 4880 4881 if (!tl || keyframes && !vars.stagger) { 4882 //if there's an internal timeline, skip all the parsing because we passed that task down the chain. 4883 harness = targets[0] ? _getCache(targets[0]).harness : 0; 4884 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. 4885 4886 cleanVars = _copyExcluding(vars, _reservedProps); 4887 4888 if (prevStartAt) { 4889 prevStartAt._zTime < 0 && prevStartAt.progress(1); // in case it's a lazy startAt that hasn't rendered yet. 4890 4891 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) 4892 // 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. 4893 4894 prevStartAt._lazy = 0; 4895 } 4896 4897 if (startAt) { 4898 _removeFromParent(tween._startAt = Tween.set(targets, _setDefaults({ 4899 data: "isStart", 4900 overwrite: false, 4901 parent: parent, 4902 immediateRender: true, 4903 lazy: !prevStartAt && _isNotFalse(lazy), 4904 startAt: null, 4905 delay: 0, 4906 onUpdate: onUpdate && function () { 4907 return _callback(tween, "onUpdate"); 4908 }, 4909 stagger: 0 4910 }, 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); 4911 4912 4913 tween._startAt._dp = 0; // don't allow it to get put back into root timeline! Like when revert() is called and totalTime() gets set. 4914 4915 tween._startAt._sat = tween; // used in globalTime(). _sat stands for _startAtTween 4916 4917 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. 4918 4919 if (immediateRender) { 4920 if (dur && time <= 0 && tTime <= 0) { 4921 // 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. 4922 time && (tween._zTime = time); 4923 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. 4924 } 4925 } 4926 } else if (runBackwards && dur) { 4927 // from() 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) 4928 if (!prevStartAt) { 4929 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 4930 4931 p = _setDefaults({ 4932 overwrite: false, 4933 data: "isFromStart", 4934 //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. 4935 lazy: immediateRender && !prevStartAt && _isNotFalse(lazy), 4936 immediateRender: immediateRender, 4937 //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) 4938 stagger: 0, 4939 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}) 4940 4941 }, cleanVars); 4942 harnessVars && (p[harness.prop] = harnessVars); // in case someone does something like .from(..., {css:{}}) 4943 4944 _removeFromParent(tween._startAt = Tween.set(targets, p)); 4945 4946 tween._startAt._dp = 0; // don't allow it to get put back into root timeline! 4947 4948 tween._startAt._sat = tween; // used in globalTime() 4949 4950 time < 0 && (_reverting ? tween._startAt.revert(_revertConfigNoKill) : tween._startAt.render(-1, true)); 4951 tween._zTime = time; 4952 4953 if (!immediateRender) { 4954 _initTween(tween._startAt, _tinyNum, _tinyNum); //ensures that the initial values are recorded 4955 4956 } else if (!time) { 4957 return; 4958 } 4959 } 4960 } 4961 4962 tween._pt = tween._ptCache = 0; 4963 lazy = dur && _isNotFalse(lazy) || lazy && !dur; 4964 4965 for (i = 0; i < targets.length; i++) { 4966 target = targets[i]; 4967 gsData = target._gsap || _harness(targets)[i]._gsap; 4968 tween._ptLookup[i] = ptLookup = {}; 4969 _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) 4970 4971 index = fullTargets === targets ? i : fullTargets.indexOf(target); 4972 4973 if (harness && (plugin = new harness()).init(target, harnessVars || cleanVars, tween, index, fullTargets) !== false) { 4974 tween._pt = pt = new PropTween(tween._pt, target, plugin.name, 0, 1, plugin.render, plugin, 0, plugin.priority); 4975 4976 plugin._props.forEach(function (name) { 4977 ptLookup[name] = pt; 4978 }); 4979 4980 plugin.priority && (hasPriority = 1); 4981 } 4982 4983 if (!harness || harnessVars) { 4984 for (p in cleanVars) { 4985 if (_plugins[p] && (plugin = _checkPlugin(p, cleanVars, tween, index, target, fullTargets))) { 4986 plugin.priority && (hasPriority = 1); 4987 } else { 4988 ptLookup[p] = pt = _addPropTween.call(tween, target, p, "get", cleanVars[p], index, fullTargets, 0, vars.stringFilter); 4989 } 4990 } 4991 } 4992 4993 tween._op && tween._op[i] && tween.kill(target, tween._op[i]); 4994 4995 if (autoOverwrite && tween._pt) { 4996 _overwritingTween = tween; 4997 4998 _globalTimeline.killTweensOf(target, ptLookup, tween.globalTime(time)); // make sure the overwriting doesn't overwrite THIS tween!!! 4999 5000 5001 overwritten = !tween.parent; 5002 _overwritingTween = 0; 5003 } 5004 5005 tween._pt && lazy && (_lazyLookup[gsData.id] = 1); 5006 } 5007 5008 hasPriority && _sortPropTweensByPriority(tween); 5009 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. 5010 } 5011 5012 tween._onUpdate = onUpdate; 5013 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. 5014 5015 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. 5016}, 5017 _updatePropTweens = function _updatePropTweens(tween, property, value, start, startIsRelative, ratio, time, skipRecursion) { 5018 var ptCache = (tween._pt && tween._ptCache || (tween._ptCache = {}))[property], 5019 pt, 5020 rootPT, 5021 lookup, 5022 i; 5023 5024 if (!ptCache) { 5025 ptCache = tween._ptCache[property] = []; 5026 lookup = tween._ptLookup; 5027 i = tween._targets.length; 5028 5029 while (i--) { 5030 pt = lookup[i][property]; 5031 5032 if (pt && pt.d && pt.d._pt) { 5033 // it's a plugin, so find the nested PropTween 5034 pt = pt.d._pt; 5035 5036 while (pt && pt.p !== property && pt.fp !== property) { 5037 // "fp" is functionParam for things like setting CSS variables which require .setProperty("--var-name", value) 5038 pt = pt._next; 5039 } 5040 } 5041 5042 if (!pt) { 5043 // there is no PropTween associated with that property, so we must FORCE one to be created and ditch out of this 5044 // 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. 5045 _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. 5046 5047 tween.vars[property] = "+=0"; 5048 5049 _initTween(tween, time); 5050 5051 _forceAllPropTweens = 0; 5052 return skipRecursion ? _warn(property + " not eligible for reset. Try splitting into individual properties") : 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(). 5053 } 5054 5055 ptCache.push(pt); 5056 } 5057 } 5058 5059 i = ptCache.length; 5060 5061 while (i--) { 5062 rootPT = ptCache[i]; 5063 pt = rootPT._pt || rootPT; // complex values may have nested PropTweens. We only accommodate the FIRST value. 5064 5065 pt.s = (start || start === 0) && !startIsRelative ? start : pt.s + (start || 0) + ratio * pt.c; 5066 pt.c = value - pt.s; 5067 rootPT.e && (rootPT.e = _round(value) + getUnit(rootPT.e)); // mainly for CSSPlugin (end value) 5068 5069 rootPT.b && (rootPT.b = pt.s + getUnit(rootPT.b)); // (beginning value) 5070 } 5071}, 5072 _addAliasesToVars = function _addAliasesToVars(targets, vars) { 5073 var harness = targets[0] ? _getCache(targets[0]).harness : 0, 5074 propertyAliases = harness && harness.aliases, 5075 copy, 5076 p, 5077 i, 5078 aliases; 5079 5080 if (!propertyAliases) { 5081 return vars; 5082 } 5083 5084 copy = _merge({}, vars); 5085 5086 for (p in propertyAliases) { 5087 if (p in copy) { 5088 aliases = propertyAliases[p].split(","); 5089 i = aliases.length; 5090 5091 while (i--) { 5092 copy[aliases[i]] = copy[p]; 5093 } 5094 } 5095 } 5096 5097 return copy; 5098}, 5099 // 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. 5100_parseKeyframe = function _parseKeyframe(prop, obj, allProps, easeEach) { 5101 var ease = obj.ease || easeEach || "power1.inOut", 5102 p, 5103 a; 5104 5105 if (_isArray(obj)) { 5106 a = allProps[prop] || (allProps[prop] = []); // t = time (out of 100), v = value, e = ease 5107 5108 obj.forEach(function (value, i) { 5109 return a.push({ 5110 t: i / (obj.length - 1) * 100, 5111 v: value, 5112 e: ease 5113 }); 5114 }); 5115 } else { 5116 for (p in obj) { 5117 a = allProps[p] || (allProps[p] = []); 5118 p === "ease" || a.push({ 5119 t: parseFloat(prop), 5120 v: obj[p], 5121 e: ease 5122 }); 5123 } 5124 } 5125}, 5126 _parseFuncOrString = function _parseFuncOrString(value, tween, i, target, targets) { 5127 return _isFunction(value) ? value.call(tween, i, target, targets) : _isString(value) && ~value.indexOf("random(") ? _replaceRandom(value) : value; 5128}, 5129 _staggerTweenProps = _callbackNames + "repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase,easeReverse,autoRevert", 5130 _staggerPropsToSkip = {}; 5131 5132_forEachName(_staggerTweenProps + ",id,stagger,delay,duration,paused,scrollTrigger", function (name) { 5133 return _staggerPropsToSkip[name] = 1; 5134}); 5135/* 5136 * -------------------------------------------------------------------------------------- 5137 * TWEEN 5138 * -------------------------------------------------------------------------------------- 5139 */ 5140 5141 5142var Tween = /*#__PURE__*/function (_Animation2) { 5143 _inheritsLoose(Tween, _Animation2); 5144 5145 function Tween(targets, vars, position, skipInherit) { 5146 var _this3; 5147 5148 if (typeof vars === "number") { 5149 position.duration = vars; 5150 vars = position; 5151 position = null; 5152 } 5153 5154 _this3 = _Animation2.call(this, skipInherit ? vars : _inheritDefaults(vars)) || this; 5155 var _this3$vars = _this3.vars, 5156 duration = _this3$vars.duration, 5157 delay = _this3$vars.delay, 5158 immediateRender = _this3$vars.immediateRender, 5159 stagger = _this3$vars.stagger, 5160 overwrite = _this3$vars.overwrite, 5161 keyframes = _this3$vars.keyframes, 5162 defaults = _this3$vars.defaults, 5163 scrollTrigger = _this3$vars.scrollTrigger, 5164 parent = vars.parent || _globalTimeline, 5165 parsedTargets = (_isArray(targets) || _isTypedArray(targets) ? _isNumber(targets[0]) : "length" in vars) ? [targets] : toArray(targets), 5166 tl, 5167 i, 5168 copy, 5169 l, 5170 p, 5171 curTarget, 5172 staggerFunc, 5173 staggerVarsToMerge; 5174 _this3._targets = parsedTargets.length ? _harness(parsedTargets) : _warn("GSAP target " + targets + " not found. https://gsap.com", !_config.nullTargetWarn) || []; 5175 _this3._ptLookup = []; //PropTween lookup. An array containing an object for each target, having keys for each tweening property 5176 5177 _this3._overwrite = overwrite; 5178 5179 if (keyframes || stagger || _isFuncOrString(duration) || _isFuncOrString(delay)) { 5180 vars = _this3.vars; 5181 var easeReverse = vars.easeReverse || vars.yoyoEase; 5182 tl = _this3.timeline = new Timeline({ 5183 data: "nested", 5184 defaults: defaults || {}, 5185 targets: parent && parent.data === "nested" ? parent.vars.targets : parsedTargets 5186 }); // 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. 5187 5188 tl.kill(); 5189 tl.parent = tl._dp = _assertThisInitialized(_this3); 5190 tl._start = 0; 5191 5192 if (stagger || _isFuncOrString(duration) || _isFuncOrString(delay)) { 5193 l = parsedTargets.length; 5194 staggerFunc = stagger && distribute(stagger); 5195 5196 if (_isObject(stagger)) { 5197 //users can pass in callbacks like onStart/onComplete in the stagger object. These should fire with each individual tween. 5198 for (p in stagger) { 5199 if (~_staggerTweenProps.indexOf(p)) { 5200 staggerVarsToMerge || (staggerVarsToMerge = {}); 5201 staggerVarsToMerge[p] = stagger[p]; 5202 } 5203 } 5204 } 5205 5206 for (i = 0; i < l; i++) { 5207 copy = _copyExcluding(vars, _staggerPropsToSkip); 5208 copy.stagger = 0; 5209 easeReverse && (copy.easeReverse = easeReverse); 5210 staggerVarsToMerge && _merge(copy, staggerVarsToMerge); 5211 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. 5212 5213 copy.duration = +_parseFuncOrString(duration, _assertThisInitialized(_this3), i, curTarget, parsedTargets); 5214 copy.delay = (+_parseFuncOrString(delay, _assertThisInitialized(_this3), i, curTarget, parsedTargets) || 0) - _this3._delay; 5215 5216 if (!stagger && l === 1 && copy.delay) { 5217 // if someone does delay:"random(1, 5)", repeat:-1, for example, the delay shouldn't be inside the repeat. 5218 _this3._delay = delay = copy.delay; 5219 _this3._start += delay; 5220 copy.delay = 0; 5221 } 5222 5223 tl.to(curTarget, copy, staggerFunc ? staggerFunc(i, curTarget, parsedTargets) : 0); 5224 tl._ease = _easeMap.none; 5225 } 5226 5227 tl.duration() ? duration = delay = 0 : _this3.timeline = 0; // if the timeline's duration is 0, we don't need a timeline internally! 5228 } else if (keyframes) { 5229 _inheritDefaults(_setDefaults(tl.vars.defaults, { 5230 ease: "none" 5231 })); 5232 5233 tl._ease = _parseEase(keyframes.ease || vars.ease || "none"); 5234 var time = 0, 5235 a, 5236 kf, 5237 v; 5238 5239 if (_isArray(keyframes)) { 5240 keyframes.forEach(function (frame) { 5241 return tl.to(parsedTargets, frame, ">"); 5242 }); 5243 tl.duration(); // to ensure tl._dur is cached because we tap into it for performance purposes in the render() method. 5244 } else { 5245 copy = {}; 5246 5247 for (p in keyframes) { 5248 p === "ease" || p === "easeEach" || _parseKeyframe(p, keyframes[p], copy, keyframes.easeEach); 5249 } 5250 5251 for (p in copy) { 5252 a = copy[p].sort(function (a, b) { 5253 return a.t - b.t; 5254 }); 5255 time = 0; 5256 5257 for (i = 0; i < a.length; i++) { 5258 kf = a[i]; 5259 v = { 5260 ease: kf.e, 5261 duration: (kf.t - (i ? a[i - 1].t : 0)) / 100 * duration 5262 }; 5263 v[p] = kf.v; 5264 tl.to(parsedTargets, v, time); 5265 time += v.duration; 5266 } 5267 } 5268 5269 tl.duration() < duration && tl.to({}, { 5270 duration: duration - tl.duration() 5271 }); // in case keyframes didn't go to 100% 5272 } 5273 } 5274 5275 duration || _this3.duration(duration = tl.duration()); 5276 } else { 5277 _this3.timeline = 0; //speed optimization, faster lookups (no going up the prototype chain) 5278 } 5279 5280 if (overwrite === true && !_suppressOverwrites) { 5281 _overwritingTween = _assertThisInitialized(_this3); 5282 5283 _globalTimeline.killTweensOf(parsedTargets); 5284 5285 _overwritingTween = 0; 5286 } 5287 5288 _addToTimeline(parent, _assertThisInitialized(_this3), position); 5289 5290 vars.reversed && _this3.reverse(); 5291 vars.paused && _this3.paused(true); 5292 5293 if (immediateRender || !duration && !keyframes && _this3._start === _roundPrecise(parent._time) && _isNotFalse(immediateRender) && _hasNoPausedAncestors(_assertThisInitialized(_this3)) && parent.data !== "nested") { 5294 _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) 5295 5296 _this3.render(Math.max(0, -delay) || 0); //in case delay is negative 5297 5298 } 5299 5300 scrollTrigger && _scrollTrigger(_assertThisInitialized(_this3), scrollTrigger); 5301 return _this3; 5302 } 5303 5304 var _proto3 = Tween.prototype; 5305 5306 _proto3.render = function render(totalTime, suppressEvents, force) { 5307 var prevTime = this._time, 5308 tDur = this._tDur, 5309 dur = this._dur, 5310 isNegative = totalTime < 0, 5311 tTime = totalTime > tDur - _tinyNum && !isNegative ? tDur : totalTime < _tinyNum ? 0 : totalTime, 5312 time, 5313 pt, 5314 iteration, 5315 cycleDuration, 5316 prevIteration, 5317 isYoyo, 5318 ratio, 5319 timeline; 5320 5321 if (!dur) { 5322 _renderZeroDurationTween(this, totalTime, suppressEvents, force); 5323 } else if (tTime !== this._tTime || !totalTime || force || !this._initted && this._tTime || this._startAt && this._zTime < 0 !== isNegative || this._lazy) { 5324 // 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) 5325 time = tTime; 5326 timeline = this.timeline; 5327 5328 if (this._repeat) { 5329 //adjust the time for repeats and yoyos 5330 cycleDuration = dur + this._rDelay; 5331 5332 if (this._repeat < -1 && isNegative) { 5333 return this.totalTime(cycleDuration * 100 + totalTime, suppressEvents, force); 5334 } 5335 5336 time = _roundPrecise(tTime % cycleDuration); //round to avoid floating point errors. (4 % 0.8 should be 0 but some browsers report it as 0.79999999!) 5337 5338 if (tTime === tDur) { 5339 // 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) 5340 iteration = this._repeat; 5341 time = dur; 5342 } else { 5343 prevIteration = _roundPrecise(tTime / cycleDuration); // full decimal version of iterations, not the previous iteration (we're reusing prevIteration variable for efficiency) 5344 5345 iteration = ~~prevIteration; 5346 5347 if (iteration && iteration === prevIteration) { 5348 time = dur; 5349 iteration--; 5350 } else if (time > dur) { 5351 time = dur; 5352 } 5353 } 5354 5355 isYoyo = this._yoyo && iteration & 1; 5356 if (isYoyo) time = dur - time; 5357 prevIteration = _animationCycle(this._tTime, cycleDuration); 5358 5359 if (time === prevTime && !force && this._initted && iteration === prevIteration) { 5360 //could be during the repeatDelay part. No need to render and fire callbacks. 5361 this._tTime = tTime; 5362 return this; 5363 } 5364 5365 if (iteration !== prevIteration) { 5366 //repeatRefresh functionality 5367 if (this.vars.repeatRefresh && !isYoyo && !this._lock && time !== cycleDuration && this._initted) { 5368 // 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). 5369 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. 5370 5371 this.render(_roundPrecise(cycleDuration * iteration), true).invalidate()._lock = 0; 5372 } 5373 } 5374 } 5375 5376 if (!this._initted) { 5377 if (_attemptInitTween(this, isNegative ? totalTime : time, force, suppressEvents, tTime)) { 5378 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. 5379 5380 return this; 5381 } 5382 5383 if (prevTime !== this._time && !(force && this.vars.repeatRefresh && iteration !== prevIteration)) { 5384 // 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! 5385 return this; 5386 } 5387 5388 if (dur !== this._dur) { 5389 // while initting, a plugin like InertiaPlugin might alter the duration, so rerun from the start to ensure everything renders as it should. 5390 return this.render(totalTime, suppressEvents, force); 5391 } 5392 } 5393 5394 if (this._rEase) { 5395 var inv = time < prevTime; 5396 5397 if (inv !== this._inv) { 5398 var segDur = inv ? prevTime : dur - prevTime; 5399 this._inv = inv; 5400 if (this._from) this.ratio = 1 - this.ratio; 5401 this._invRatio = this.ratio; 5402 this._invTime = prevTime; 5403 this._invRecip = segDur ? (inv ? -1 : 1) / segDur : 0; 5404 this._invScale = inv ? -this.ratio : 1 - this.ratio; 5405 this._invEase = inv ? this._rEase : this._ease; 5406 } 5407 5408 this.ratio = ratio = this._invRatio + this._invScale * this._invEase((time - this._invTime) * this._invRecip); 5409 } else { 5410 this.ratio = ratio = this._ease(time / dur); 5411 } 5412 5413 if (this._from) this.ratio = ratio = 1 - ratio; 5414 this._tTime = tTime; 5415 this._time = time; 5416 5417 if (!this._act && this._ts) { 5418 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. 5419 5420 this._lazy = 0; 5421 } 5422 5423 if (!prevTime && tTime && !suppressEvents && !prevIteration) { 5424 _callback(this, "onStart"); 5425 5426 if (this._tTime !== tTime) { 5427 // 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. 5428 return this; 5429 } 5430 } 5431 5432 pt = this._pt; 5433 5434 while (pt) { 5435 pt.r(ratio, pt.d); 5436 pt = pt._next; 5437 } 5438 5439 timeline && timeline.render(totalTime < 0 ? totalTime : timeline._dur * timeline._ease(time / this._dur), suppressEvents, force) || this._startAt && (this._zTime = totalTime); 5440 5441 if (this._onUpdate && !suppressEvents) { 5442 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. 5443 5444 _callback(this, "onUpdate"); 5445 } 5446 5447 this._repeat && iteration !== prevIteration && this.vars.onRepeat && !suppressEvents && this.parent && _callback(this, "onRepeat"); 5448 5449 if ((tTime === this._tDur || !tTime) && this._tTime === tTime) { 5450 isNegative && !this._onUpdate && _rewindStartAt(this, totalTime, true, true); 5451 (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. 5452 5453 if (!suppressEvents && !(isNegative && !prevTime) && (tTime || prevTime || isYoyo)) { 5454 // if prevTime and tTime are zero, we shouldn't fire the onReverseComplete. This could happen if you gsap.to(... {paused:true}).play(); 5455 _callback(this, tTime === tDur ? "onComplete" : "onReverseComplete", true); 5456 5457 this._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom(); 5458 } 5459 } 5460 } 5461 5462 return this; 5463 }; 5464 5465 _proto3.targets = function targets() { 5466 return this._targets; 5467 }; 5468 5469 _proto3.invalidate = function invalidate(soft) { 5470 // "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. 5471 (!soft || !this.vars.runBackwards) && (this._startAt = 0); 5472 this._pt = this._op = this._onUpdate = this._lazy = this.ratio = 0; 5473 this._ptLookup = []; 5474 this.timeline && this.timeline.invalidate(soft); 5475 return _Animation2.prototype.invalidate.call(this, soft); 5476 }; 5477 5478 _proto3.resetTo = function resetTo(property, value, start, startIsRelative, skipRecursion) { 5479 _tickerActive || _ticker.wake(); 5480 this._ts || this.play(); 5481 var time = Math.min(this._dur, (this._dp._time - this._start) * this._ts), 5482 ratio; 5483 this._initted || _initTween(this, time); 5484 ratio = this._ease(time / this._dur); // don't just get tween.ratio because it may not have rendered yet. 5485 // 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. 5486 // if (_isObject(property)) { // performance optimization 5487 // for (p in property) { 5488 // if (_updatePropTweens(this, p, property[p], value ? value[p] : null, start, ratio, time)) { 5489 // 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. 5490 // } 5491 // } 5492 // } else { 5493 5494 if (_updatePropTweens(this, property, value, start, startIsRelative, ratio, time, skipRecursion)) { 5495 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. 5496 } //} 5497 5498 5499 _alignPlayhead(this, 0); 5500 5501 this.parent || _addLinkedListItem(this._dp, this, "_first", "_last", this._dp._sort ? "_start" : 0); 5502 return this.render(0); 5503 }; 5504 5505 _proto3.kill = function kill(targets, vars) { 5506 if (vars === void 0) { 5507 vars = "all"; 5508 } 5509 5510 if (!targets && (!vars || vars === "all")) { 5511 this._lazy = this._pt = 0; 5512 this.parent ? _interrupt(this) : this.scrollTrigger && this.scrollTrigger.kill(!!_reverting); 5513 return this; 5514 } 5515 5516 if (this.timeline) { 5517 var tDur = this.timeline.totalDuration(); 5518 this.timeline.killTweensOf(targets, vars, _overwritingTween && _overwritingTween.vars.overwrite !== true)._first || _interrupt(this); // if nothing is left tweening, interrupt. 5519 5520 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. 5521 5522 return this; 5523 } 5524 5525 var parsedTargets = this._targets, 5526 killingTargets = targets ? toArray(targets) : parsedTargets, 5527 propTweenLookup = this._ptLookup, 5528 firstPT = this._pt, 5529 overwrittenProps, 5530 curLookup, 5531 curOverwriteProps, 5532 props, 5533 p, 5534 pt, 5535 i; 5536 5537 if ((!vars || vars === "all") && _arraysMatch(parsedTargets, killingTargets)) { 5538 vars === "all" && (this._pt = 0); 5539 return _interrupt(this); 5540 } 5541 5542 overwrittenProps = this._op = this._op || []; 5543 5544 if (vars !== "all") { 5545 //so people can pass in a comma-delimited list of property names 5546 if (_isString(vars)) { 5547 p = {}; 5548 5549 _forEachName(vars, function (name) { 5550 return p[name] = 1; 5551 }); 5552 5553 vars = p; 5554 } 5555 5556 vars = _addAliasesToVars(parsedTargets, vars); 5557 } 5558 5559 i = parsedTargets.length; 5560 5561 while (i--) { 5562 if (~killingTargets.indexOf(parsedTargets[i])) { 5563 curLookup = propTweenLookup[i]; 5564 5565 if (vars === "all") { 5566 overwrittenProps[i] = vars; 5567 props = curLookup; 5568 curOverwriteProps = {}; 5569 } else { 5570 curOverwriteProps = overwrittenProps[i] = overwrittenProps[i] || {}; 5571 props = vars; 5572 } 5573 5574 for (p in props) { 5575 pt = curLookup && curLookup[p]; 5576 5577 if (pt) { 5578 if (!("kill" in pt.d) || pt.d.kill(p) === true) { 5579 _removeLinkedListItem(this, pt, "_pt"); 5580 } 5581 5582 delete curLookup[p]; 5583 } 5584 5585 if (curOverwriteProps !== "all") { 5586 curOverwriteProps[p] = 1; 5587 } 5588 } 5589 } 5590 } 5591 5592 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. 5593 5594 return this; 5595 }; 5596 5597 Tween.to = function to(targets, vars) { 5598 return new Tween(targets, vars, arguments[2]); 5599 }; 5600 5601 Tween.from = function from(targets, vars) { 5602 return _createTweenType(1, arguments); 5603 }; 5604 5605 Tween.delayedCall = function delayedCall(delay, callback, params, scope) { 5606 return new Tween(callback, 0, { 5607 immediateRender: false, 5608 lazy: false, 5609 overwrite: false, 5610 delay: delay, 5611 onComplete: callback, 5612 onReverseComplete: callback, 5613 onCompleteParams: params, 5614 onReverseCompleteParams: params, 5615 callbackScope: scope 5616 }); // we must use onReverseComplete too for things like timeline.add(() => {...}) which should be triggered in BOTH directions (forward and reverse) 5617 }; 5618 5619 Tween.fromTo = function fromTo(targets, fromVars, toVars) { 5620 return _createTweenType(2, arguments); 5621 }; 5622 5623 Tween.set = function set(targets, vars) { 5624 vars.duration = 0; 5625 vars.repeatDelay || (vars.repeat = 0); 5626 return new Tween(targets, vars); 5627 }; 5628 5629 Tween.killTweensOf = function killTweensOf(targets, props, onlyActive) { 5630 return _globalTimeline.killTweensOf(targets, props, onlyActive); 5631 }; 5632 5633 return Tween; 5634}(Animation); 5635 5636_setDefaults(Tween.prototype, { 5637 _targets: [], 5638 _lazy: 0, 5639 _startAt: 0, 5640 _op: 0, 5641 _onInit: 0 5642}); //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) 5643// _forEachName("to,from,fromTo,set,call,add,addLabel,addPause", name => { 5644// Tween.prototype[name] = function() { 5645// let tl = new Timeline(); 5646// return _addToTimeline(tl, this)[name].apply(tl, toArray(arguments)); 5647// } 5648// }); 5649//for backward compatibility. Leverage the timeline calls. 5650 5651 5652_forEachName("staggerTo,staggerFrom,staggerFromTo", function (name) { 5653 Tween[name] = function () { 5654 var tl = new Timeline(), 5655 params = _slice.call(arguments, 0); 5656 5657 params.splice(name === "staggerFromTo" ? 5 : 4, 0, 0); 5658 return tl[name].apply(tl, params); 5659 }; 5660}); 5661/* 5662 * -------------------------------------------------------------------------------------- 5663 * PROPTWEEN 5664 * -------------------------------------------------------------------------------------- 5665 */ 5666 5667 5668var _setterPlain = function _setterPlain(target, property, value) { 5669 return target[property] = value; 5670}, 5671 _setterFunc = function _setterFunc(target, property, value) { 5672 return target[property](value); 5673}, 5674 _setterFuncWithParam = function _setterFuncWithParam(target, property, value, data) { 5675 return target[property](data.fp, value); 5676}, 5677 _setterAttribute = function _setterAttribute(target, property, value) { 5678 return target.setAttribute(property, value); 5679}, 5680 _getSetter = function _getSetter(target, property) { 5681 return _isFunction(target[property]) ? _setterFunc : _isUndefined(target[property]) && target.setAttribute ? _setterAttribute : _setterPlain; 5682}, 5683 _renderPlain = function _renderPlain(ratio, data) { 5684 return data.set(data.t, data.p, Math.round((data.s + data.c * ratio) * 1000000) / 1000000, data); 5685}, 5686 _renderBoolean = function _renderBoolean(ratio, data) { 5687 return data.set(data.t, data.p, !!(data.s + data.c * ratio), data); 5688}, 5689 _renderComplexString = function _renderComplexString(ratio, data) { 5690 var pt = data._pt, 5691 s = ""; 5692 5693 if (!ratio && data.b) { 5694 //b = beginning string 5695 s = data.b; 5696 } else if (ratio === 1 && data.e) { 5697 //e = ending string 5698 s = data.e; 5699 } else { 5700 while (pt) { 5701 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. 5702 5703 pt = pt._next; 5704 } 5705 5706 s += data.c; //we use the "c" of the PropTween to store the final chunk of non-numeric text. 5707 } 5708 5709 data.set(data.t, data.p, s, data); 5710}, 5711 _renderPropTweens = function _renderPropTweens(ratio, data) { 5712 var pt = data._pt; 5713 5714 while (pt) { 5715 pt.r(ratio, pt.d); 5716 pt = pt._next; 5717 } 5718}, 5719 _addPluginModifier = function _addPluginModifier(modifier, tween, target, property) { 5720 var pt = this._pt, 5721 next; 5722 5723 while (pt) { 5724 next = pt._next; 5725 pt.p === property && pt.modifier(modifier, tween, target); 5726 pt = next; 5727 } 5728}, 5729 _killPropTweensOf = function _killPropTweensOf(property) { 5730 var pt = this._pt, 5731 hasNonDependentRemaining, 5732 next; 5733 5734 while (pt) { 5735 next = pt._next; 5736 5737 if (pt.p === property && !pt.op || pt.op === property) { 5738 _removeLinkedListItem(this, pt, "_pt"); 5739 } else if (!pt.dep) { 5740 hasNonDependentRemaining = 1; 5741 } 5742 5743 pt = next; 5744 } 5745 5746 return !hasNonDependentRemaining; 5747}, 5748 _setterWithModifier = function _setterWithModifier(target, property, value, data) { 5749 data.mSet(target, property, data.m.call(data.tween, value, data.mt), data); 5750}, 5751 _sortPropTweensByPriority = function _sortPropTweensByPriority(parent) { 5752 var pt = parent._pt, 5753 next, 5754 pt2, 5755 first, 5756 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) 5757 5758 while (pt) { 5759 next = pt._next; 5760 pt2 = first; 5761 5762 while (pt2 && pt2.pr > pt.pr) { 5763 pt2 = pt2._next; 5764 } 5765 5766 if (pt._prev = pt2 ? pt2._prev : last) { 5767 pt._prev._next = pt; 5768 } else { 5769 first = pt; 5770 } 5771 5772 if (pt._next = pt2) { 5773 pt2._prev = pt; 5774 } else { 5775 last = pt; 5776 } 5777 5778 pt = next; 5779 } 5780 5781 parent._pt = first; 5782}; //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) 5783 5784 5785var PropTween = /*#__PURE__*/function () { 5786 function PropTween(next, target, prop, start, change, renderer, data, setter, priority) { 5787 this.t = target; 5788 this.s = start; 5789 this.c = change; 5790 this.p = prop; 5791 this.r = renderer || _renderPlain; 5792 this.d = data || this; 5793 this.set = setter || _setterPlain; 5794 this.pr = priority || 0; 5795 this._next = next; 5796 5797 if (next) { 5798 next._prev = this; 5799 } 5800 } 5801 5802 var _proto4 = PropTween.prototype; 5803 5804 _proto4.modifier = function modifier(func, tween, target) { 5805 this.mSet = this.mSet || this.set; //in case it was already set (a PropTween can only have one modifier) 5806 5807 this.set = _setterWithModifier; 5808 this.m = func; 5809 this.mt = target; //modifier target 5810 5811 this.tween = tween; 5812 }; 5813 5814 return PropTween; 5815}(); //Initialization tasks 5816 5817_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,easeReverse", function (name) { 5818 return _reservedProps[name] = 1; 5819}); 5820 5821_globals.TweenMax = _globals.TweenLite = Tween; 5822_globals.TimelineLite = _globals.TimelineMax = Timeline; 5823_globalTimeline = new Timeline({ 5824 sortChildren: false, 5825 defaults: _defaults, 5826 autoRemoveChildren: true, 5827 id: "root", 5828 smoothChildTiming: true 5829}); 5830_config.stringFilter = _colorStringFilter; 5831 5832var _media = [], 5833 _listeners = {}, 5834 _emptyArray = [], 5835 _lastMediaTime = 0, 5836 _contextID = 0, 5837 _dispatch = function _dispatch(type) { 5838 return (_listeners[type] || _emptyArray).map(function (f) { 5839 return f(); 5840 }); 5841}, 5842 _onMediaChange = function _onMediaChange() { 5843 var time = Date.now(), 5844 matches = []; 5845 5846 if (time - _lastMediaTime > 2) { 5847 _dispatch("matchMediaInit"); 5848 5849 _media.forEach(function (c) { 5850 var queries = c.queries, 5851 conditions = c.conditions, 5852 match, 5853 p, 5854 anyMatch, 5855 toggled; 5856 5857 for (p in queries) { 5858 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. 5859 5860 match && (anyMatch = 1); 5861 5862 if (match !== conditions[p]) { 5863 conditions[p] = match; 5864 toggled = 1; 5865 } 5866 } 5867 5868 if (toggled) { 5869 c.revert(); 5870 anyMatch && matches.push(c); 5871 } 5872 }); 5873 5874 _dispatch("matchMediaRevert"); 5875 5876 matches.forEach(function (c) { 5877 return c.onMatch(c, function (func) { 5878 return c.add(null, func); 5879 }); 5880 }); 5881 _lastMediaTime = time; 5882 5883 _dispatch("matchMedia"); 5884 } 5885}; 5886 5887var Context = /*#__PURE__*/function () { 5888 function Context(func, scope) { 5889 this.selector = scope && selector(scope); 5890 this.data = []; 5891 this._r = []; // returned/cleanup functions 5892 5893 this.isReverted = false; 5894 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 5895 5896 func && this.add(func); 5897 } 5898 5899 var _proto5 = Context.prototype; 5900 5901 _proto5.add = function add(name, func, scope) { 5902 // 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. 5903 // if (name && _isFunction(name.revert)) { 5904 // this.data.push(name); 5905 // return (name._ctx = this); 5906 // } 5907 if (_isFunction(name)) { 5908 scope = func; 5909 func = name; 5910 name = _isFunction; 5911 } 5912 5913 var self = this, 5914 f = function f() { 5915 var prev = _context, 5916 prevSelector = self.selector, 5917 result; 5918 prev && prev !== self && prev.data.push(self); 5919 scope && (self.selector = selector(scope)); 5920 _context = self; 5921 result = func.apply(self, arguments); 5922 _isFunction(result) && self._r.push(result); 5923 _context = prev; 5924 self.selector = prevSelector; 5925 self.isReverted = false; 5926 return result; 5927 }; 5928 5929 self.last = f; 5930 return name === _isFunction ? f(self, function (func) { 5931 return self.add(null, func); 5932 }) : name ? self[name] = f : f; 5933 }; 5934 5935 _proto5.ignore = function ignore(func) { 5936 var prev = _context; 5937 _context = null; 5938 func(this); 5939 _context = prev; 5940 }; 5941 5942 _proto5.getTweens = function getTweens() { 5943 var a = []; 5944 this.data.forEach(function (e) { 5945 return e instanceof Context ? a.push.apply(a, e.getTweens()) : e instanceof Tween && !(e.parent && e.parent.data === "nested") && a.push(e); 5946 }); 5947 return a; 5948 }; 5949 5950 _proto5.clear = function clear() { 5951 this._r.length = this.data.length = 0; 5952 }; 5953 5954 _proto5.kill = function kill(revert, matchMedia) { 5955 var _this4 = this; 5956 5957 if (revert) { 5958 (function () { 5959 var tweens = _this4.getTweens(), 5960 i = _this4.data.length, 5961 t; 5962 5963 while (i--) { 5964 // 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. 5965 t = _this4.data[i]; 5966 5967 if (t.data === "isFlip") { 5968 t.revert(); 5969 t.getChildren(true, true, false).forEach(function (tween) { 5970 return tweens.splice(tweens.indexOf(tween), 1); 5971 }); 5972 } 5973 } // save as an object so that we can cache the globalTime for each tween to optimize performance during the sort 5974 5975 5976 tweens.map(function (t) { 5977 return { 5978 g: t._dur || t._delay || t._sat && !t._sat.vars.immediateRender ? t.globalTime(0) : -Infinity, 5979 t: t 5980 }; 5981 }).sort(function (a, b) { 5982 return b.g - a.g || -Infinity; 5983 }).forEach(function (o) { 5984 return o.t.revert(revert); 5985 }); // 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. 5986 5987 i = _this4.data.length; 5988 5989 while (i--) { 5990 // make sure we loop backwards so that, for example, SplitTexts that were created later on the same element get reverted first 5991 t = _this4.data[i]; 5992 5993 if (t instanceof Timeline) { 5994 if (t.data !== "nested") { 5995 t.scrollTrigger && t.scrollTrigger.revert(); 5996 t.kill(); // don't revert() the timeline because that's duplicating efforts since we already reverted all the tweens 5997 } 5998 } else { 5999 !(t instanceof Tween) && t.revert && t.revert(revert); 6000 } 6001 } 6002 6003 _this4._r.forEach(function (f) { 6004 return f(revert, _this4); 6005 }); 6006 6007 _this4.isReverted = true; 6008 })(); 6009 } else { 6010 this.data.forEach(function (e) { 6011 return e.kill && e.kill(); 6012 }); 6013 } 6014 6015 this.clear(); 6016 6017 if (matchMedia) { 6018 var i = _media.length; 6019 6020 while (i--) { 6021 // 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. 6022 _media[i].id === this.id && _media.splice(i, 1); 6023 } 6024 } 6025 } // killWithCleanup() { 6026 // this.kill(); 6027 // this._r.forEach(f => f(false, this)); 6028 // } 6029 ; 6030 6031 _proto5.revert = function revert(config) { 6032 this.kill(config || {}); 6033 }; 6034 6035 return Context; 6036}(); 6037 6038var MatchMedia = /*#__PURE__*/function () { 6039 function MatchMedia(scope) { 6040 this.contexts = []; 6041 this.scope = scope; 6042 _context && _context.data.push(this); 6043 } 6044 6045 var _proto6 = MatchMedia.prototype; 6046 6047 _proto6.add = function add(conditions, func, scope) { 6048 _isObject(conditions) || (conditions = { 6049 matches: conditions 6050 }); 6051 var context = new Context(0, scope || this.scope), 6052 cond = context.conditions = {}, 6053 mq, 6054 p, 6055 active; 6056 _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() 6057 6058 this.contexts.push(context); 6059 func = context.add("onMatch", func); 6060 context.queries = conditions; 6061 6062 for (p in conditions) { 6063 if (p === "all") { 6064 active = 1; 6065 } else { 6066 mq = _win.matchMedia(conditions[p]); 6067 6068 if (mq) { 6069 _media.indexOf(context) < 0 && _media.push(context); 6070 (cond[p] = mq.matches) && (active = 1); 6071 mq.addListener ? mq.addListener(_onMediaChange) : mq.addEventListener("change", _onMediaChange); 6072 } 6073 } 6074 } 6075 6076 active && func(context, function (f) { 6077 return context.add(null, f); 6078 }); 6079 return this; 6080 } // refresh() { 6081 // let time = _lastMediaTime, 6082 // media = _media; 6083 // _lastMediaTime = -1; 6084 // _media = this.contexts; 6085 // _onMediaChange(); 6086 // _lastMediaTime = time; 6087 // _media = media; 6088 // } 6089 ; 6090 6091 _proto6.revert = function revert(config) { 6092 this.kill(config || {}); 6093 }; 6094 6095 _proto6.kill = function kill(revert) { 6096 this.contexts.forEach(function (c) { 6097 return c.kill(revert, true); 6098 }); 6099 }; 6100 6101 return MatchMedia; 6102}(); 6103/* 6104 * -------------------------------------------------------------------------------------- 6105 * GSAP 6106 * -------------------------------------------------------------------------------------- 6107 */ 6108 6109 6110var _gsap = { 6111 registerPlugin: function registerPlugin() { 6112 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { 6113 args[_key2] = arguments[_key2]; 6114 } 6115 6116 args.forEach(function (config) { 6117 return _createPlugin(config); 6118 }); 6119 }, 6120 timeline: function timeline(vars) { 6121 return new Timeline(vars); 6122 }, 6123 getTweensOf: function getTweensOf(targets, onlyActive) { 6124 return _globalTimeline.getTweensOf(targets, onlyActive); 6125 }, 6126 getProperty: function getProperty(target, property, unit, uncache) { 6127 _isString(target) && (target = toArray(target)[0]); //in case selector text or an array is passed in 6128 6129 var getter = _getCache(target || {}).get, 6130 format = unit ? _passThrough : _numericIfPossible; 6131 6132 unit === "native" && (unit = ""); 6133 return !target ? target : !property ? function (property, unit, uncache) { 6134 return format((_plugins[property] && _plugins[property].get || getter)(target, property, unit, uncache)); 6135 } : format((_plugins[property] && _plugins[property].get || getter)(target, property, unit, uncache)); 6136 }, 6137 quickSetter: function quickSetter(target, property, unit) { 6138 target = toArray(target); 6139 6140 if (target.length > 1) { 6141 var setters = target.map(function (t) { 6142 return gsap.quickSetter(t, property, unit); 6143 }), 6144 l = setters.length; 6145 return function (value) { 6146 var i = l; 6147 6148 while (i--) { 6149 setters[i](value); 6150 } 6151 }; 6152 } 6153 6154 target = target[0] || {}; 6155 6156 var Plugin = _plugins[property], 6157 cache = _getCache(target), 6158 p = cache.harness && (cache.harness.aliases || {})[property] || property, 6159 // in case it's an alias, like "rotate" for "rotation". 6160 setter = Plugin ? function (value) { 6161 var p = new Plugin(); 6162 _quickTween._pt = 0; 6163 p.init(target, unit ? value + unit : value, _quickTween, 0, [target]); 6164 p.render(1, p); 6165 _quickTween._pt && _renderPropTweens(1, _quickTween); 6166 } : cache.set(target, p); 6167 6168 return Plugin ? setter : function (value) { 6169 return setter(target, p, unit ? value + unit : value, cache, 1); 6170 }; 6171 }, 6172 quickTo: function quickTo(target, property, vars) { 6173 var _setDefaults2; 6174 6175 var tween = gsap.to(target, _setDefaults((_setDefaults2 = {}, _setDefaults2[property] = "+=0.1", _setDefaults2.paused = true, _setDefaults2.stagger = 0, _setDefaults2), vars || {})), 6176 func = function func(value, start, startIsRelative) { 6177 return tween.resetTo(property, value, start, startIsRelative); 6178 }; 6179 6180 func.tween = tween; 6181 return func; 6182 }, 6183 isTweening: function isTweening(targets) { 6184 return _globalTimeline.getTweensOf(targets, true).length > 0; 6185 }, 6186 defaults: function defaults(value) { 6187 value && value.ease && (value.ease = _parseEase(value.ease, _defaults.ease)); 6188 return _mergeDeep(_defaults, value || {}); 6189 }, 6190 config: function config(value) { 6191 return _mergeDeep(_config, value || {}); 6192 }, 6193 registerEffect: function registerEffect(_ref3) { 6194 var name = _ref3.name, 6195 effect = _ref3.effect, 6196 plugins = _ref3.plugins, 6197 defaults = _ref3.defaults, 6198 extendTimeline = _ref3.extendTimeline; 6199 (plugins || "").split(",").forEach(function (pluginName) { 6200 return pluginName && !_plugins[pluginName] && !_globals[pluginName] && _warn(name + " effect requires " + pluginName + " plugin."); 6201 }); 6202 6203 _effects[name] = function (targets, vars, tl) { 6204 return effect(toArray(targets), _setDefaults(vars || {}, defaults), tl); 6205 }; 6206 6207 if (extendTimeline) { 6208 Timeline.prototype[name] = function (targets, vars, position) { 6209 return this.add(_effects[name](targets, _isObject(vars) ? vars : (position = vars) && {}, this), position); 6210 }; 6211 } 6212 }, 6213 registerEase: function registerEase(name, ease) { 6214 _easeMap[name] = _parseEase(ease); 6215 }, 6216 parseEase: function parseEase(ease, defaultEase) { 6217 return arguments.length ? _parseEase(ease, defaultEase) : _easeMap; 6218 }, 6219 getById: function getById(id) { 6220 return _globalTimeline.getById(id); 6221 }, 6222 exportRoot: function exportRoot(vars, includeDelayedCalls) { 6223 if (vars === void 0) { 6224 vars = {}; 6225 } 6226 6227 var tl = new Timeline(vars), 6228 child, 6229 next; 6230 tl.smoothChildTiming = _isNotFalse(vars.smoothChildTiming); 6231 6232 _globalTimeline.remove(tl); 6233 6234 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). 6235 6236 tl._time = tl._tTime = _globalTimeline._time; 6237 child = _globalTimeline._first; 6238 6239 while (child) { 6240 next = child._next; 6241 6242 if (includeDelayedCalls || !(!child._dur && child instanceof Tween && child.vars.onComplete === child._targets[0])) { 6243 _addToTimeline(tl, child, child._start - child._delay); 6244 } 6245 6246 child = next; 6247 } 6248 6249 _addToTimeline(_globalTimeline, tl, 0); 6250 6251 return tl; 6252 }, 6253 context: function context(func, scope) { 6254 return func ? new Context(func, scope) : _context; 6255 }, 6256 matchMedia: function matchMedia(scope) { 6257 return new MatchMedia(scope); 6258 }, 6259 matchMediaRefresh: function matchMediaRefresh() { 6260 return _media.forEach(function (c) { 6261 var cond = c.conditions, 6262 found, 6263 p; 6264 6265 for (p in cond) { 6266 if (cond[p]) { 6267 cond[p] = false; 6268 found = 1; 6269 } 6270 } 6271 6272 found && c.revert(); 6273 }) || _onMediaChange(); 6274 }, 6275 addEventListener: function addEventListener(type, callback) { 6276 var a = _listeners[type] || (_listeners[type] = []); 6277 ~a.indexOf(callback) || a.push(callback); 6278 }, 6279 removeEventListener: function removeEventListener(type, callback) { 6280 var a = _listeners[type], 6281 i = a && a.indexOf(callback); 6282 i >= 0 && a.splice(i, 1); 6283 }, 6284 utils: { 6285 wrap: wrap, 6286 wrapYoyo: wrapYoyo, 6287 distribute: distribute, 6288 random: random, 6289 snap: snap, 6290 normalize: normalize, 6291 getUnit: getUnit, 6292 clamp: clamp, 6293 splitColor: splitColor, 6294 toArray: toArray, 6295 selector: selector, 6296 mapRange: mapRange, 6297 pipe: pipe, 6298 unitize: unitize, 6299 interpolate: interpolate, 6300 shuffle: shuffle 6301 }, 6302 install: _install, 6303 effects: _effects, 6304 ticker: _ticker, 6305 updateRoot: Timeline.updateRoot, 6306 plugins: _plugins, 6307 globalTimeline: _globalTimeline, 6308 core: { 6309 PropTween: PropTween, 6310 globals: _addGlobal, 6311 Tween: Tween, 6312 Timeline: Timeline, 6313 Animation: Animation, 6314 getCache: _getCache, 6315 _removeLinkedListItem: _removeLinkedListItem, 6316 reverting: function reverting() { 6317 return _reverting; 6318 }, 6319 context: function context(toAdd) { 6320 if (toAdd && _context) { 6321 _context.data.push(toAdd); 6322 6323 toAdd._ctx = _context; 6324 } 6325 6326 return _context; 6327 }, 6328 suppressOverwrites: function suppressOverwrites(value) { 6329 return _suppressOverwrites = value; 6330 } 6331 } 6332}; 6333 6334_forEachName("to,from,fromTo,delayedCall,set,killTweensOf", function (name) { 6335 return _gsap[name] = Tween[name]; 6336}); 6337 6338_ticker.add(Timeline.updateRoot); 6339 6340_quickTween = _gsap.to({}, { 6341 duration: 0 6342}); // ---- EXTRA PLUGINS -------------------------------------------------------- 6343 6344var _getPluginPropTween = function _getPluginPropTween(plugin, prop) { 6345 var pt = plugin._pt; 6346 6347 while (pt && pt.p !== prop && pt.op !== prop && pt.fp !== prop) { 6348 pt = pt._next; 6349 } 6350 6351 return pt; 6352}, 6353 _addModifiers = function _addModifiers(tween, modifiers) { 6354 var targets = tween._targets, 6355 p, 6356 i, 6357 pt; 6358 6359 for (p in modifiers) { 6360 i = targets.length; 6361 6362 while (i--) { 6363 pt = tween._ptLookup[i][p]; 6364 6365 if (pt && (pt = pt.d)) { 6366 if (pt._pt) { 6367 // is a plugin 6368 pt = _getPluginPropTween(pt, p); 6369 } 6370 6371 pt && pt.modifier && pt.modifier(modifiers[p], tween, targets[i], p); 6372 } 6373 } 6374 } 6375}, 6376 _buildModifierPlugin = function _buildModifierPlugin(name, modifier) { 6377 return { 6378 name: name, 6379 headless: 1, 6380 rawVars: 1, 6381 //don't pre-process function-based values or "random()" strings. 6382 init: function init(target, vars, tween) { 6383 tween._onInit = function (tween) { 6384 var temp, p; 6385 6386 if (_isString(vars)) { 6387 temp = {}; 6388 6389 _forEachName(vars, function (name) { 6390 return temp[name] = 1; 6391 }); //if the user passes in a comma-delimited list of property names to roundProps, like "x,y", we round to whole numbers. 6392 6393 6394 vars = temp; 6395 } 6396 6397 if (modifier) { 6398 temp = {}; 6399 6400 for (p in vars) { 6401 temp[p] = modifier(vars[p]); 6402 } 6403 6404 vars = temp; 6405 } 6406 6407 _addModifiers(tween, vars); 6408 }; 6409 } 6410 }; 6411}; //register core plugins 6412 6413
6414var gsap = _gsap.registerPlugin({ 6415 name: "attr", 6416 init: function init(target, vars, tween, index, targets) { 6417 var p, pt, v; 6418 this.tween = tween; 6419 6420 for (p in vars) { 6421 v = target.getAttribute(p) || ""; 6422 pt = this.add(target, "setAttribute", (v || 0) + "", vars[p], index, targets, 0, 0, p); 6423 pt.op = p; 6424 pt.b = v; // record the beginning value so we can revert() 6425 6426 this._props.push(p); 6427 } 6428 }, 6429 render: function render(ratio, data) { 6430 var pt = data._pt; 6431 6432 while (pt) { 6433 _reverting ? pt.set(pt.t, pt.p, pt.b, pt) : pt.r(ratio, pt.d); // if reverting, go back to the original (pt.b) 6434 6435 pt = pt._next; 6436 } 6437 } 6438}, { 6439 name: "endArray", 6440 headless: 1, 6441 init: function init(target, value) { 6442 var i = value.length; 6443 6444 while (i--) { 6445 this.add(target, i, target[i] || 0, value[i], 0, 0, 0, 0, 0, 1); 6446 } 6447 } 6448}, _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. 6449 6450Tween.version = Timeline.version = gsap.version = "3.15.0"; 6451_coreReady = 1; 6452_windowExists() && _wake(); 6453var Power0 = _easeMap.Power0, 6454 Power1 = _easeMap.Power1, 6455 Power2 = _easeMap.Power2, 6456 Power3 = _easeMap.Power3, 6457 Power4 = _easeMap.Power4, 6458 Linear = _easeMap.Linear, 6459 Quad = _easeMap.Quad, 6460 Cubic = _easeMap.Cubic, 6461 Quart = _easeMap.Quart, 6462 Quint = _easeMap.Quint, 6463 Strong = _easeMap.Strong, 6464 Elastic = _easeMap.Elastic, 6465 Back = _easeMap.Back, 6466 SteppedEase = _easeMap.SteppedEase, 6467 Bounce = _easeMap.Bounce, 6468 Sine = _easeMap.Sine, 6469 Expo = _easeMap.Expo, 6470 Circ = _easeMap.Circ; 6471 6472 //export some internal methods/orojects for use in CSSPlugin so that we can externalize that file and allow custom builds that exclude it. 6473 6474 6475 6476/***/ }, 6477 6478/***/ "./node_modules/gsap/index.js" 6479/*!************************************!*\ 6480 !*** ./node_modules/gsap/index.js ***! 6481 \************************************/ 6482(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 6483 6484__webpack_require__.r(__webpack_exports__); 6485/* empty/unused harmony star reexport */ 6486/* empty/unused harmony star reexport */ 6487/* harmony export */ __webpack_require__.d(__webpack_exports__, { 6488/* harmony export */ TweenMax: () => (/* binding */ TweenMaxWithCSS), 6489/* harmony export */ "default": () => (/* binding */ gsapWithCSS), 6490/* harmony export */ gsap: () => (/* binding */ gsapWithCSS) 6491/* harmony export */ }); 6492/* empty/unused harmony star reexport */ 6493/* empty/unused harmony star reexport */ 6494/* empty/unused harmony star reexport */ 6495/* empty/unused harmony star reexport */ 6496/* empty/unused harmony star reexport */ 6497/* empty/unused harmony star reexport */ 6498/* empty/unused harmony star reexport */ 6499/* empty/unused harmony star reexport */ 6500/* empty/unused harmony star reexport */ 6501/* empty/unused harmony star reexport */ 6502/* empty/unused harmony star reexport */ 6503/* empty/unused harmony star reexport */ 6504/* empty/unused harmony star reexport */ 6505/* empty/unused harmony star reexport */ 6506/* empty/unused harmony star reexport */ 6507/* empty/unused harmony star reexport */ 6508/* empty/unused harmony star reexport */ 6509/* empty/unused harmony star reexport */ 6510/* empty/unused harmony star reexport */ 6511/* empty/unused harmony star reexport */ 6512/* harmony import */ var _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./gsap-core.js */ "./node_modules/gsap/gsap-core.js"); 6513/* harmony import */ var _CSSPlugin_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CSSPlugin.js */ "./node_modules/gsap/CSSPlugin.js"); 6514 6515 6516var gsapWithCSS = _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.gsap.registerPlugin(_CSSPlugin_js__WEBPACK_IMPORTED_MODULE_2__.CSSPlugin) || _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.gsap, 6517 // to protect from tree shaking 6518TweenMaxWithCSS = gsapWithCSS.core.Tween; 6519 6520 6521/***/ }, 6522 6523/***/ "./src/style/main.scss" 6524/*!*****************************!*\ 6525 !*** ./src/style/main.scss ***! 6526 \*****************************/ 6527(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 6528 6529__webpack_require__.r(__webpack_exports__); 6530// extracted by mini-css-extract-plugin 6531 6532 6533/***/ }, 6534 6535/***/ "./src/app/campaign.js" 6536/*!*****************************!*\ 6537 !*** ./src/app/campaign.js ***! 6538 \*****************************/ 6539(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 6540 6541__webpack_require__.r(__webpack_exports__); 6542/* harmony export */ __webpack_require__.d(__webpack_exports__, { 6543/* harmony export */ createCampaignRuntimeConfig: () => (/* binding */ createCampaignRuntimeConfig), 6544/* harmony export */ initCampaign: () => (/* binding */ initCampaign), 6545/* harmony export */ resolveCampaignPhase: () =>
6545 (/* binding */ resolveCampaignPhase) 6546/* harmony export */ }); 6547/* harmony import */ var _media__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./media */ "./src/app/media.js"); 6548/* harmony import */ var _demo_content__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../demo-content */ "./src/demo-content.js"); 6549/* harmony import */ var _safe_url__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./safe-url */ "./src/app/safe-url.js"); 6550 6551 6552 6553 6554const SUPPORTED_PHASES = new Set([1, 2, 3]); 6555 6556function validPhase(value) { 6557 const phase = Number(value); 6558 return SUPPORTED_PHASES.has(phase) ? phase : null; 6559} 6560 6561function resolveCampaignPhase(config, location = window.location) { 6562 const queryPhase = new URLSearchParams(location?.search ?? "").get("phase"); 6563 const requestedPhase = validPhase(queryPhase); 6564 if (requestedPhase) return requestedPhase; 6565 6566 return validPhase(config.activePhase) ?? 1; 6567} 6568 6569function createCampaignRuntimeConfig( 6570 config, 6571 location = window.location, 6572) { 6573 const activePhase = resolveCampaignPhase(config, location); 6574 const queryPhase = validPhase( 6575 new URLSearchParams(location?.search ?? "").get("phase"), 6576 ); 6577 const demoRequested = Boolean(queryPhase && activePhase > 1); 6578 const configuredHeader = (0,_media__WEBPACK_IMPORTED_MODULE_0__.configuredYoutubeVideo)(config.youtube?.header); 6579 const configuredSlider = (0,_media__WEBPACK_IMPORTED_MODULE_0__.configuredYoutubeSlider)(config.youtube?.slider); 6580 const configuredStories = (0,_media__WEBPACK_IMPORTED_MODULE_0__.configuredYoutubeSlider)(config.youtube?.stories); 6581 const configuredWinners = winnersConfigured(config.winners); 6582 const usesDemoYoutube = demoRequested 6583 && activePhase >= 2 6584 && (!configuredHeader || !configuredSlider); 6585 const usesDemoWinners = demoRequested 6586 && activePhase === 3 6587 && !configuredWinners; 6588 6589 return { 6590 ...config, 6591 activePhase, 6592 demoMode: usesDemoYoutube || usesDemoWinners, 6593 youtube: { 6594 header: configuredHeader 6595 ? config.youtube.header 6596 : (usesDemoYoutube ? _demo_content__WEBPACK_IMPORTED_MODULE_1__.demoCampaignContent.youtube.header : null), 6597 slider: configuredSlider 6598 ? config.youtube.slider 6599 : (usesDemoYoutube 6600 ? _demo_content__WEBPACK_IMPORTED_MODULE_1__.demoCampaignContent.youtube.slider 6601 : (config.youtube?.slider ?? { title: null, videos: [] })), 6602 stories: configuredStories 6603 ? config.youtube.stories 6604 : (usesDemoYoutube 6605 ? _demo_content__WEBPACK_IMPORTED_MODULE_1__.demoCampaignContent.youtube.stories 6606 : { title: null, videos: [] }), 6607 }, 6608 winners: configuredWinners 6609 ? config.winners 6610 : (usesDemoWinners ? _demo_content__WEBPACK_IMPORTED_MODULE_1__.demoCampaignContent.winners : null), 6611 }; 6612} 6613 6614function winnersConfigured(winners) { 6615 return Boolean( 6616 winners?.grandPrize 6617 && Array.isArray(winners.secondaryPrizes) 6618 && winners.secondaryPrizes.length > 0, 6619 ); 6620} 6621 6622function configuredModules(config, activePhase) { 6623 const phase = String(activePhase); 6624 const requested = config.phaseModules?.[phase] ?? config.phaseModules?.[1] ?? []; 6625 const modules = new Set(requested); 6626 6627 if (modules.has("hero-video") && !(0,_media__WEBPACK_IMPORTED_MODULE_0__.configuredYoutubeVideo)(config.youtube?.header)) { 6628 modules.delete("hero-video"); 6629 modules.add("hero-default"); 6630 } 6631 6632 if ( 6633 modules.has("villancicos") 6634 && !(0,_media__WEBPACK_IMPORTED_MODULE_0__.configuredYoutubeSlider)(config.youtube?.slider) 6635 && !(0,_media__WEBPACK_IMPORTED_MODULE_0__.configuredYoutubePlaceholderSlider)(config.youtube?.slider) 6636 ) { 6637 modules.delete("villancicos"); 6638 } 6639 6640 if (modules.has("stories") && !(0,_media__WEBPACK_IMPORTED_MODULE_0__.configuredYoutubeSlider)(config.youtube?.stories)) { 6641 modules.delete("stories"); 6642 } 6643 6644 if (modules.has("winners") && !winnersConfigured(config.winners)) { 6645 modules.delete("winners"); 6646 } 6647 6648 return modules; 6649} 6650 6651function configureExternalLinks(config) { 6652 const crmUrl = (0,_safe_url__WEBPACK_IMPORTED_MODULE_2__.safeHttpUrl)(config.crmUrl, { allowAnyHttps: true }); 6653 if (crmUrl) { 6654 document.querySelectorAll("[data-crm-link]").forEach((control)
6654=> { 6655 const link = document.createElement("a"); 6656 link.className = control.className; 6657 link.append(...Array.from(control.childNodes, (node) => node.cloneNode(true))); 6658 link.href = crmUrl; 6659 link.target = "_blank"; 6660 link.rel = "noopener noreferrer"; 6661 link.dataset.crmLink = ""; 6662 control.replaceWith(link); 6663 }); 6664 } 6665 6666 document.querySelectorAll("[data-legal-link]").forEach((label) => { 6667 const key = label.dataset.legalLink; 6668 const url = config.legalUrls?.[key]; 6669 const safeUrl = (0,_safe_url__WEBPACK_IMPORTED_MODULE_2__.safeHttpUrl)(url, { allowAnyHttps: true }); 6670 if (!safeUrl) return; 6671 6672 const link = document.createElement("a"); 6673 link.href = safeUrl; 6674 link.target = "_blank"; 6675 link.rel = "noopener noreferrer"; 6676 link.textContent = label.textContent; 6677 label.replaceWith(link); 6678 }); 6679} 6680 6681function initCampaign(config) { 6682 const activePhase = resolveCampaignPhase(config); 6683 const activeModules = configuredModules(config, activePhase); 6684 document.body.dataset.campaignPhase = String(activePhase); 6685 document.body.dataset.campaignContent = config.demoMode ? "demo" : "configured"; 6686 6687 document.querySelectorAll("[data-campaign-module]").forEach((module) => { 6688 const active = activeModules.has(module.dataset.campaignModule); 6689 module.hidden = !active; 6690 module.dataset.campaignModuleState = active ? "active" : "inactive"; 6691 }); 6692 6693 document.querySelectorAll("[data-campaign-module-link]").forEach((item) => { 6694 const allowedPhases = (item.dataset.campaignPhaseLink || "") 6695 .split(",") 6696 .map(validPhase) 6697 .filter(Boolean); 6698 const phaseAllowed = allowedPhases.length === 0 || allowedPhases.includes(activePhase); 6699 item.hidden = !phaseAllowed 6700 || !activeModules.has(item.dataset.campaignModuleLink); 6701 }); 6702 6703 document.querySelectorAll("[data-phase-sorteo-link]").forEach((item) => { 6704 const link = item.querySelector("a"); 6705 if (!link) return; 6706 6707 link.href = activePhase === 3 ? "#ganadores" : "#sorteo"; 6708 link.textContent = "Sorteo"; 6709 }); 6710 6711 configureExternalLinks(config); 6712 return activeModules; 6713} 6714 6715 6716/***/ }, 6717 6718/***/ "./src/app/media-coordinator.js" 6719/*!**************************************!*\ 6720 !*** ./src/app/media-coordinator.js ***! 6721 \**************************************/ 6722(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 6723 6724__webpack_require__.r(__webpack_exports__); 6725/* harmony export */ __webpack_require__.d(__webpack_exports__, { 6726/* harmony export */ createMediaCoordinator: () => (/* binding */ createMediaCoordinator) 6727/* harmony export */ }); 6728function validController(controller) { 6729 return Boolean(controller && typeof controller.stop === "function"); 6730} 6731 6732function createMediaCoordinator() { 6733 const controllers = new Set(); 6734 let activeController = null; 6735 6736 const register = (controller) => { 6737 if (!validController(controller)) { 6738 throw new TypeError("Cada medio debe exponer un método stop()."); 6739 } 6740 6741 controllers.add(controller); 6742 return () => { 6743 controllers.delete(controller); 6744 if (activeController === controller) activeController = null; 6745 }; 6746 }; 6747 6748 const activate = (controller) => { 6749 if (!controllers.has(controller)) register(controller); 6750 if (activeController === controller) return; 6751 6752 activeController = controller; 6753 controllers.forEach((candidate) => { 6754 if (candidate !== controller) candidate.stop({ reason: "another-media" }); 6755 }); 6756 }; 6757 6758 const release = (controller) => { 6759 if (activeController === controller) activeController = null; 6760 }; 6761 6762 const stopAll = () => { 6763 activeController = null; 6764 controllers.forEach((controller) => controller.stop({ reason: "stop-all" })); 6765 }; 6766 6767 return Object.freeze({ 6768 activate, 6769 register, 6770 release, 6771 stopAll, 6772 get activeController() { 6773 return activeController; 6774 }, 6775 }); 6776} 6777 6778 6779/***/ }, 6780 6781/***/ "./src/app/media.js" 6782/*!**************************!*\ 6783 !*** ./src/app/media.js ***! 6784 \**************************/ 6785(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 6786 6787__webpack_require__.r(__webpack_exports__); 6788/* harmony export */ __webpack_require__.d(__webpack_exports__, { 6789/* harmony export */ configuredJingle: () => (/* binding */ configuredJingle), 6790/* harmony export */ configuredYoutubePlaceholderSlider: () => (/* binding */ configuredYoutubePlaceholderSlider), 6791/* harmony export */ configuredYoutubeSlider: () => (/* binding */ configuredYoutubeSlider), 6792/* harmony export */ configuredYoutubeVideo: () => (/* binding */ configuredYoutubeVideo), 6793/* harmony export */ createYoutubeIframe: () => (/* binding */ createYoutubeIframe), 6794/* harmony export */ displayableYoutubeSlider: () => (/* binding */ displayableYoutubeSlider), 6795/* harmony export */ nonEmptyString: () => (/* binding */ nonEmptyString), 6796/* harmony export */ youtubeEmbedUrl: () => (/* binding */ youtubeEmbedUrl), 6797/* harmony export */ youtubeVideoId: () => (/* binding */ youtubeVideoId) 6798/* harmony export */ }); 6799const YOUTUBE_ID_PATTERN = /^[A-Za-z0-9_-]{11}$/; 6800 6801function nonEmptyString(value) { 6802 return typeof value === "string" && value.trim().length > 0; 6803} 6804 6805function youtubeVideoId(value) { 6806 if (!nonEmptyString(value)) return null; 6807 6808 const candidate = value.trim(); 6809 if (YOUTUBE_ID_PATTERN.test(candidate)) return candidate; 6810 6811 try { 6812 const url = new URL(candidate); 6813 const hostname = url.hostname.replace(/^www\./, ""); 6814 let id = null; 6815 6816 if (hostname === "youtu.be") {
6817 [id] = url.pathname.split("/").filter(Boolean); 6818 } else if ( 6819 hostname === "youtube.com" 6820 || hostname === "m.youtube.com" 6821 || hostname === "youtube-nocookie.com" 6822 ) { 6823 id = url.searchParams.get("v"); 6824 if (!id) { 6825 const parts = url.pathname.split("/").filter(Boolean); 6826 if (["embed", "shorts", "live"].includes(parts[0])) id = parts[1]; 6827 } 6828 } 6829 6830 return YOUTUBE_ID_PATTERN.test(id ?? "") ? id : null; 6831 } catch { 6832 return null; 6833 } 6834} 6835 6836function configuredYoutubeVideo(video) { 6837 return Boolean( 6838 video 6839 && nonEmptyString(video.title) 6840 && youtubeVideoId(video.youtubeId ?? video.url), 6841 ); 6842} 6843 6844function configuredYoutubeSlider(slider) { 6845 return Boolean( 6846 slider 6847 && nonEmptyString(slider.title) 6848 && Array.isArray(slider.videos) 6849 && slider.videos.some(configuredYoutubeVideo), 6850 ); 6851} 6852 6853function configuredYoutubePlaceholderSlider(slider) { 6854 return Boolean( 6855 slider 6856 && nonEmptyString(slider.title) 6857 && Number.isInteger(slider.placeholderSlides) 6858 && slider.placeholderSlides > 0, 6859 ); 6860} 6861 6862function displayableYoutubeSlider(slider) { 6863 return configuredYoutubeSlider(slider) 6864 || configuredYoutubePlaceholderSlider(slider); 6865} 6866 6867function configuredJingle(jingle, activePhase) { 6868 if (!jingle?.enabled || !nonEmptyString(jingle.src)) return false; 6869 if (!Array.isArray(jingle.phases) || !jingle.phases.includes(activePhase)) { 6870 return false; 6871 } 6872 6873 return true; 6874} 6875 6876function youtubeEmbedUrl( 6877 video, 6878 { autoplay = false, loop = false, muted = false } = {}, 6879) { 6880 const id = youtubeVideoId(video?.youtubeId ?? video?.url); 6881 if (!id) return null; 6882 6883 const params = new URLSearchParams({ 6884 autoplay: autoplay ? "1" : "0", 6885 controls: "1", 6886 enablejsapi: "1", 6887 modestbranding: "1", 6888 playsinline: "1", 6889 rel: "0", 6890 }); 6891 6892 if (muted) params.set("mute", "1"); 6893 if (loop) { 6894 params.set("loop", "1"); 6895 params.set("playlist", id); 6896 } 6897 6898 return `https://www.youtube-nocookie.com/embed/${id}?${params.toString()}`; 6899} 6900 6901function createYoutubeIframe(video, options = {}) { 6902 const src = youtubeEmbedUrl(video, options); 6903 if (!src) return null; 6904 6905 const iframe = document.createElement("iframe"); 6906 iframe.src = src; 6907 iframe.title = video.title; 6908 iframe.loading = options.loading ?? "lazy"; 6909 iframe.referrerPolicy = "strict-origin-when-cross-origin"; 6910 iframe.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"; 6911 iframe.allowFullscreen = true; 6912 return iframe; 6913} 6914 6915 6916/***/ }, 6917 6918/***/ "./src/app/safe-url.js" 6919/*!*****************************!*\ 6920 !*** ./src/app/safe-url.js ***! 6921 \*****************************/ 6922(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 6923 6924__webpack_require__.r(__webpack_exports__); 6925/* harmony export */ __webpack_require__.d(__webpack_exports__, { 6926/* harmony export */ SUCHARD_VIDEO_ORIGINS: () => (/* binding */ SUCHARD_VIDEO_ORIGINS), 6927/* harmony export */ YOUTUBE_POSTER_ORIGINS: () => (/* binding */ YOUTUBE_POSTER_ORIGINS), 6928/* harmony export */ safeHttpUrl: () => (/* binding */ safeHttpUrl) 6929/* harmony export */ }); 6930const HTTP_PROTOCOLS = new Set(["http:", "https:"]); 6931const SCHEME_PATTERN = /^[A-Za-z][A-Za-z\d+.-]*:/; 6932 6933function runtimeBaseUrl() { 6934 return globalThis.document?.baseURI 6935 ?? globalThis.location?.href 6936 ?? "http://localhost/"; 6937} 6938 6939function safeHttpUrl( 6940 value, 6941 { 6942 allowedOrigins = [], 6943 allowAnyHttps = false, 6944 allowSameOrigin = true, 6945 baseUrl = runtimeBaseUrl(), 6946 } = {}, 6947) { 6948 if (typeof value !== "string" || value.trim().length === 0) return null; 6949 6950 const candidate = value.trim(); 6951 if (/\p{Cc}/u.test(candidate) || candidate.startsWith("//") || candidate.includes("\\")) { 6952 return null; 6953 } 6954 6955 let base; 6956 let url; 6957 try { 6958 base = new URL(baseUrl); 6959 url = new URL(candidate, base); 6960 } catch { 6961 return null; 6962 } 6963 6964 if (!HTTP_PROTOCOLS.has(url.protocol)) return null; 6965 if (url.username || url.password) return null; 6966 6967 const isRelative = !SCHEME_PATTERN.test(candidate); 6968 if (isRelative && allowSameOrigin && url.origin === base.origin) { 6969 return `${url.pathname}${url.search}${url.hash}`; 6970 } 6971 6972 if (allowSameOrigin && url.origin === base.origin) return url.href; 6973 if (url.protocol !== "https:") return null; 6974 6975 const trustedOrigins = new Set(allowedOrigins); 6976 if (!allowAnyHttps && !trustedOrigins.has(url.origin)) return null; 6977 6978 return url.href; 6979} 6980 6981const YOUTUBE_POSTER_ORIGINS = Object.freeze([ 6982 "https://i.ytimg.com", 6983 "https://img.youtube.com", 6984]); 6985 6986const SUCHARD_VIDEO_ORIGINS = Object.freeze([ 6987 "https://www.suchard.es", 6988]); 6989 6990 6991/***/ }, 6992 6993/***/ "./src/campaign-config.js" 6994/*!********************************!*\ 6995 !*** ./src/campaign-config.js ***! 6996 \********************************/ 6997(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 6998 6999__webpack_require__.r(__webpack_exports__); 7000/* harmony export */ __webpack_require__.d(__webpack_exports__, { 7001/* harmony export */ campaignConfig: () => (/* binding */ campaignConfig) 7002/* harmony export */ }); 7003/* harmony import */ var _assets_audio_mc_suchard_60s_master_v1_14lufs_mp3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./assets/audio/mc-suchard-60s-master-v1-14lufs.mp3 */ "./src/assets/audio/mc-suchard-60s-master-v1-14lufs.mp3"); 7004 7005 7006const exampleExternalUrls = Object.freeze({ 7007 crm: "https://www.suchard.es/", 7008}); 7009 7010const sharedModules = Object.freeze([ 7011 "participation", 7012 "faq", 7013 "stories", 7014 "discover", 7015 "sustainability", 7016 "newsletter", 7017]); 7018 7019const campaignConfig = Object.freeze({ 7020 activePhase: 1, 7021 phaseModules: Object.freeze({ 7022 1: Object.freeze([ 7023 "hero-default", 7024 "prizes", 7025 "villancicos", 7026 ...sharedModules, 7027 ]), 7028 2: Object.freeze([ 7029 "hero-video", 7030 "prizes", 7031 "villancicos", 7032 ...sharedModules, 7033 ]), 7034 3: Object.freeze([ 7035 "hero-video", 7036 "winners", 7037 "villancicos", 7038 "faq", 7039 "stories", 7040 "discover", 7041 "sustainability", 7042 "newsletter", 7043 ]), 7044 }), 7045 crmUrl: exampleExternalUrls.crm, 7046 youtube: Object.freeze({ 7047 header: null, 7048 slider: Object.freeze({ 7049 title: "Escucha nuestro coro", 7050 videos: Object.freeze([ 7051 Object.freeze({ 7052 //https://www.youtube.com/shorts/ivUvRCv-jNI 7053 youtubeId: "ivUvRCv-jNI", 7054 title: "Ejemplo 1 · Suchard 2025 · Son todas Navidades", 7055 posterUrl: "https://i.ytimg.com/vi/QYUZ4cUzEZw/maxresdefault.jpg", 7056 }) 7057 ]), 7058 placeholderSlides: 3, 7059 }), 7060 stories: Object.freeze({ 7061 title: null, 7062 videos: Object.freeze([]), 7063 }), 7064 }), 7065 jingle: Object.freeze({ 7066 enabled: true, 7067 src: _assets_audio_mc_suchard_60s_master_v1_14lufs_mp3__WEBPACK_IMPORTED_MODULE_0__, 7068 loop: true, 7069 phases: Object.freeze([1, 2, 3]), 7070 }), 7071 winners: null, 7072 popup: Object.freeze({ 7073 enabled: false, 7074 trigger: "load", 7075 frequency: "always", 7076 delayMs: 1500, 7077 scrollThreshold: 0.2, 7078 storageKey: "suchard-newsletter-popup-2026", 7079 }), 7080 legalUrls: Object.freeze({ 7081 contact: "https://contactus.mdlzapps.com/mondelezinternationales/contact/es-ES", 7082 legal: "bases-legales.html", 7083 //legal: "SUCHARD_26-BBLL.pdf", 7084 cookies: "politica-cookies.html", 7085 terms: "terminos.html", 7086 privacy: "https://privacy.mondelezinternational.com/eu/es-ES/privacy-notice/", 7087 }), 7088}); 7089 7090 7091/***/ }, 7092 7093/***/ "./src/demo-content.js" 7094/*!*****************************!*\ 7095 !*** ./src/demo-content.js ***! 7096 \*****************************/ 7097(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 7098 7099__webpack_require__.r(__webpack_exports__); 7100/* harmony export */ __webpack_require__.d(__webpack_exports__, { 7101/* harmony export */ demoCampaignContent: () => (/* binding */ demoCampaignContent) 7102/* harmony export */ }); 7103/* harmony import */ var _assets_figma_winners_couple_scene_webp__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./assets/figma/winners/couple-scene.webp */ "./src/assets/figma/winners/couple-scene.webp"); 7104 7105 7106const SUCHARD_HERO_LOOP_URL = "https://www.suchard.es/assets/videos/10s_Suchard.mp4"; 7107 7108const demoSecondaryPrizes = Array.from({ length: 50 }, (_, index) => ( 7109 Object.freeze({ 7110 number: `DEMO-${String(index + 1).padStart(5, "0")}`, 7111 series: `LOREM-${(index % 5) + 1}`, 7112 }) 7113)); 7114 7115const demoCampaignContent = Object.freeze({ 7116 youtube: Object.freeze({ 7117 header: Object.freeze({ 7118 youtubeId: "JNLKEblx2_o", 7119 title: "Sigamos compartiendo el sabor de la Navidad", 7120 autoplay: false, 7121 loop: false, 7122 posterUrl: _assets_figma_winners_couple_scene_webp__WEBPACK_IMPORTED_MODULE_0__, 7123 backgroundVideoUrl: SUCHARD_HERO_LOOP_URL, 7124 }), 7125 slider: Object.freeze({ 7126 title: "Escucha nuestro coro", 7127 videos: Object.freeze([ 7128 Object.freeze({ 7129 //https://www.youtube.com/shorts/ivUvRCv-jNI 7130 youtubeId: "ivUvRCv-jNI", 7131 title: "Ejemplo 1 · Suchard 2025 · Son todas Navidades", 7132 posterUrl: "https://i.ytimg.com/vi/QYUZ4cUzEZw/maxresdefault.jpg", 7133 }) 7134 ]), 7135 /*videos: Object.freeze([ 7136 Object.freeze({ 7137 youtubeId: "QYUZ4cUzEZw", 7138 title: "Ejemplo 1 · Suchard 2025 · Son todas Navidades", 7139 posterUrl: "https://i.ytimg.com/vi/QYUZ4cUzEZw/maxresdefault.jpg", 7140 }), 7141 Object.freeze({ 7142 youtubeId: "JNLKEblx2_o", 7143 title: "Ejemplo 2 · Suchard 2025 · Son todas Navidades", 7144 posterUrl: "https://i.ytimg.com/vi/JNLKEblx2_o/maxresdefault.jpg", 7145 }), 7146 ]),*/ 7147 }), 7148 stories: Object.freeze({ 7149 title: "Por si te has perdido nuestras nuevas historias", 7150 videos: Object.freeze([ 7151 Object.freeze({ 7152 youtubeId: "JNLKEblx2_o", 7153 title: "El sabor de todas las Navidades · Suchard", 7154 posterUrl: "https://i.ytimg.com/vi/JNLKEblx2_o/maxresdefault.jpg", 7155 }), 7156 Object.freeze({ 7157 youtubeId: "QYUZ4cUzEZw", 7158 title: "Una historia de Navidad · Suchard", 7159 posterUrl: "https://i.ytimg.com/vi/QYUZ4cUzEZw/maxresdefault.jpg", 7160 }), 7161 ]), 7162 }), 7163 }), 7164 winners: Object.freeze({ 7165 demoNotice: "Datos de prueba: no son resultados reales.", 7166 referencePlaceholder: true, 7167 introCopy: "Revisa que el número y la serie de tu tableta Suchard Clásico coincidan con el número ganador y descubre si este año el gran premio es para ti.", 7168 grandPrizeTitle: "Primer Premio: 100.000â¬", 7169 grandPrize: Object.freeze({ 7170 number: "DEMO-00000", 7171 series: "LOREM", 7172 }), 7173 secondaryTitle: "50 Segundos Premios de 1.000â¬", 7174 secondaryCopy: "Comprueba si la combinación de número y serie de tu envoltorio aparece entre los siguientes números premiados o descarga el listado oficial (PDF).", 7175 secondaryPrizes: Object.freeze(demoSecondaryPrizes), 7176 officialPdfUrl: null, 7177 }), 7178}); 7179 7180 7181/***/ }, 7182 7183/***/ "./src/features/faq.js" 7184/*!*****************************!*\ 7185 !*** ./src/features/faq.js ***! 7186 \*****************************/ 7187(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 7188 7189__webpack_require__.r(__webpack_exports__); 7190/* harmony export */ __webpack_require__.d(__webpack_exports__, { 7191/* harmony export */ initFaq: () => (/* binding */ initFaq) 7192/* harmony export */ }); 7193function initFaq() { 7194 const toggles = Array.from(document.querySelectorAll("[data-faq-toggle]")); 7195 if (!toggles.length) return; 7196 7197 const setExpanded = (toggle, expanded) => { 7198 const panelId = toggle.getAttribute("aria-controls"); 7199 const panel = panelId ? document.getElementById(panelId) : null; 7200 7201 toggle.setAttribute("aria-expanded", String(expanded)); 7202 if (panel) panel.hidden = !expanded; 7203 }; 7204
7205 toggles.forEach((toggle) => { 7206 setExpanded(toggle, toggle.getAttribute("aria-expanded") === "true"); 7207 toggle.addEventListener("click", () => { 7208 const willExpand = toggle.getAttribute("aria-expanded") !== "true"; 7209 toggles.forEach((item) => setExpanded(item, item === toggle && willExpand)); 7210 }); 7211 }); 7212} 7213 7214 7215/***/ }, 7216 7217/***/ "./src/features/jingle.js" 7218/*!********************************!*\ 7219 !*** ./src/features/jingle.js ***! 7220 \********************************/ 7221(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 7222 7223__webpack_require__.r(__webpack_exports__); 7224/* harmony export */ __webpack_require__.d(__webpack_exports__, { 7225/* harmony export */ initJingle: () => (/* binding */ initJingle) 7226/* harmony export */ }); 7227/* harmony import */ var _app_media__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../app/media */ "./src/app/media.js"); 7228/* harmony import */ var _app_safe_url__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../app/safe-url */ "./src/app/safe-url.js"); 7229 7230 7231 7232function setButtonState(button, playing) { 7233 const label = button.querySelector(".jingle-control__label"); 7234 button.setAttribute("aria-pressed", String(playing)); 7235 button.setAttribute( 7236 "aria-label", 7237 playing ? "Pausar música de Navidad" : "Reproducir música de Navidad", 7238 ); 7239 button.dataset.jingleState = playing ? "playing" : "paused"; 7240 if (label) label.textContent = playing ? "Pausar Jingle" : "Activar Jingle"; 7241} 7242 7243function initJingle(config, activePhase, coordinator) { 7244 const button = document.querySelector("[data-jingle-control]"); 7245 if (!button || !(0,_app_media__WEBPACK_IMPORTED_MODULE_0__.configuredJingle)(config, activePhase)) return null; 7246 7247 const src = (0,_app_safe_url__WEBPACK_IMPORTED_MODULE_1__.safeHttpUrl)(config.src); 7248 if (!src) return null; 7249 7250 const audio = document.createElement("audio"); 7251 audio.src = src; 7252 audio.preload = "none"; 7253 audio.loop = config.loop === true; 7254 7255 let playRequest = 0; 7256 const controller = { 7257 stop() { 7258 playRequest += 1; 7259 audio.pause(); 7260 setButtonState(button, false); 7261 }, 7262 }; 7263 7264 coordinator.register(controller); 7265 setButtonState(button, false); 7266 button.hidden = false; 7267 7268 const pause = () => { 7269 playRequest += 1; 7270 audio.pause(); 7271 coordinator.release(controller); 7272 setButtonState(button, false); 7273 }; 7274 7275 const play = async () => { 7276 const request = ++playRequest; 7277 coordinator.activate(controller); 7278 7279 try { 7280 await audio.play(); 7281 if (request !== playRequest) return; 7282 setButtonState(button, true); 7283 } catch { 7284 if (request !== playRequest) return; 7285 coordinator.release(controller); 7286 setButtonState(button, false); 7287 } 7288 }; 7289 7290 button.addEventListener("click", () => { 7291 if (audio.paused) play(); 7292 else pause(); 7293 }); 7294 audio.addEventListener("play", () => setButtonState(button, true)); 7295 audio.addEventListener("pause", () => setButtonState(button, false)); 7296 audio.addEventListener("ended", () => { 7297 coordinator.release(controller); 7298 setButtonState(button, false); 7299 }); 7300 audio.addEventListener("error", () => { 7301 coordinator.release(controller); 7302 setButtonState(button, false); 7303 }); 7304 7305 return { audio, button, controller }; 7306} 7307 7308 7309/***/ }, 7310 7311/***/ "./src/features/newsletter-dialog.js" 7312/*!*******************************************!*\ 7313 !*** ./src/features/newsletter-dialog.js ***! 7314 \*******************************************/ 7315(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 7316 7317__webpack_require__.r(__webpack_exports__); 7318/* harmony export */ __webpack_require__.d(__webpack_exports__, { 7319/* harmony export */ initNewsletterDialog: () => (/* binding */ initNewsletterDialog) 7320/* harmony export */ }); 7321/* harmony import */ var _app_media__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../app/media */ "./src/app/media.js"); 7322 7323 7324function popupStorage(config) { 7325 try { 7326 if (config.frequency === "session") return window.sessionStorage; 7327 if (config.frequency === "browser") return window.localStorage; 7328 } catch { 7329 return null; 7330 } 7331 7332 return null; 7333} 7334 7335function initNewsletterDialog(campaignConfig) { 7336 const dialog = document.querySelector("[data-newsletter-dialog]"); 7337 const panel = dialog?.querySelector("[data-newsletter-dialog-panel]"); 7338 const closeButton = dialog?.querySelector("[data-newsletter-dialog-close]"); 7339 const config = campaignConfig.popup ?? {}; 7340 7341 if ( 7342 !dialog 7343 || !panel 7344 || !closeButton 7345 || !config.enabled 7346 || typeof dialog.showModal !== "function" 7347 ) return; 7348 7349 let returnFocusTo = null; 7350 const storage = popupStorage(config); 7351 const storageKey = (0,_app_media__WEBPACK_IMPORTED_MODULE_0__.nonEmptyString)(config.storageKey) 7352 ? config.storageKey 7353 : "suchard-newsletter-popup"; 7354 7355 const wasShown = () => { 7356 if (config.frequency === "always" || !storage) return false;
7357 try { 7358 return storage.getItem(storageKey) === "shown"; 7359 } catch { 7360 return false; 7361 } 7362 }; 7363 7364 const rememberShown = () => { 7365 if (config.frequency === "always" || !storage) return; 7366 try { 7367 storage.setItem(storageKey, "shown"); 7368 } catch { 7369 // Storage may be disabled without preventing the dialog from working. 7370 } 7371 }; 7372 7373 const restorePage = () => { 7374 document.body.classList.remove("dialog-is-open"); 7375 returnFocusTo?.focus?.(); 7376 returnFocusTo = null; 7377 }; 7378 7379 const closeDialog = () => { 7380 if (dialog.open) dialog.close(); 7381 }; 7382 7383 const openDialog = ({ source = null, automatic = false } = {}) => { 7384 if (dialog.open || (automatic && wasShown())) return false; 7385 7386 returnFocusTo = source instanceof HTMLElement && source !== document.body 7387 ? source 7388 : null; 7389 dialog.showModal(); 7390 document.body.classList.add("dialog-is-open"); 7391 rememberShown(); 7392 dialog.focus({ preventScroll: true }); 7393 return true; 7394 }; 7395 7396 dialog.addEventListener("close", restorePage); 7397 dialog.addEventListener("cancel", (event) => { 7398 event.preventDefault(); 7399 closeDialog(); 7400 }); 7401 7402 dialog.addEventListener("keydown", (event) => { 7403 if (event.key !== "Tab") return; 7404 7405 const focusableElements = Array.from( 7406 dialog.querySelectorAll("button:not([disabled]), a[href], [tabindex]:not([tabindex='-1'])"), 7407 ).filter((element) => !element.hidden); 7408 const firstElement = focusableElements[0]; 7409 const lastElement = focusableElements.at(-1); 7410 const focusStartsOnDialog = document.activeElement === dialog; 7411 7412 if (event.shiftKey && (focusStartsOnDialog || document.activeElement === firstElement)) { 7413 event.preventDefault(); 7414 lastElement?.focus(); 7415 } else if (!event.shiftKey && (focusStartsOnDialog || document.activeElement === lastElement)) { 7416 event.preventDefault(); 7417 firstElement?.focus(); 7418 } 7419 }); 7420 7421 closeButton.addEventListener("click", closeDialog); 7422 dialog.addEventListener("click", (event) => { 7423 if (!panel.contains(event.target)) closeDialog(); 7424 }); 7425 7426 document.querySelectorAll("[data-newsletter-dialog-open]").forEach((control) => { 7427 control.addEventListener("click", (event) => { 7428 event.preventDefault(); 7429 openDialog({ source: control }); 7430 }); 7431 }); 7432 7433 window.addEventListener("suchard:open-newsletter", () => { 7434 openDialog({ source: document.activeElement }); 7435 }); 7436 7437 if (wasShown()) return; 7438 7439 if (config.trigger === "delay") { 7440 const delay = Number.isFinite(config.delayMs) ? Math.max(0, config.delayMs) : 0; 7441 window.setTimeout(() => openDialog({ automatic: true }), delay); 7442 return; 7443 } 7444 7445 if (config.trigger === "scroll") { 7446 const threshold = Number.isFinite(config.scrollThreshold) 7447 ? Math.min(1, Math.max(0, config.scrollThreshold)) 7448 : 0.2; 7449 const openAtThreshold = () => { 7450 const scrollable = Math.max( 7451 document.documentElement.scrollHeight - window.innerHeight, 7452 1, 7453 ); 7454 if (window.scrollY / scrollable < threshold) return; 7455 7456 window.removeEventListener("scroll", openAtThreshold); 7457 openDialog({ automatic: true }); 7458 }; 7459 7460 window.addEventListener("scroll", openAtThreshold, { passive: true }); 7461 openAtThreshold(); 7462 return; 7463 } 7464 7465 if (config.trigger === "load") openDialog({ automatic: true }); 7466} 7467 7468 7469/***/ }, 7470 7471/***/ "./src/features/reveal-on-view.js" 7472/*!****************************************!*\ 7473 !*** ./src/features/reveal-on-view.js ***! 7474 \****************************************/ 7475(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 7476 7477__webpack_require__.r(__webpack_exports__); 7478/* harmony export */ __webpack_require__.d(__webpack_exports__, { 7479/* harmony export */ initRevealAnimations: () => (/* binding */ initRevealAnimations), 7480/* harmony export */ initVillancicosRevealAnimation: () => (/* binding */ initVillancicosRevealAnimation), 7481/* harmony export */ initWinnerRevealAnimations: () => (/* binding */ initWinnerRevealAnimations) 7482/* harmony export */ }); 7483const REVEAL_THRESHOLD = 0.2; 7484 7485function revealOnce(selector, requiredSelector = null, triggerSelector = null) { 7486 const section = document.querySelector(selector); 7487 if ( 7488 !section 7489 || section.hidden 7490 || section.closest("[hidden]") 7491 || section.classList.contains("is-motion-ready") 7492 || section.classList.contains("is-visible") 7493 || (requiredSelector && !section.querySelector(requiredSelector)) 7494 ) { 7495 return null; 7496 } 7497 7498 if (!("IntersectionObserver" in window)) { 7499 section.classList.add("is-visible"); 7500 return section; 7501 } 7502 7503 const trigger = triggerSelector ? section.querySelector(triggerSelector) : section; 7504 if (!trigger) return null; 7505 7506 section.classList.add("is-motion-ready"); 7507 const observer = new IntersectionObserver( 7508 (entries) => { 7509 if ( 7510 !entries.some( 7511 (entry) => entry.isIntersecting && entry.intersectionRatio >= REVEAL_THRESHOLD, 7512 ) 7513 ) { 7514 return; 7515 } 7516 7517 section.classList.add("is-visible"); 7518 observer.unobserve(trigger); 7519 }, 7520 { threshold: [REVEAL_THRESHOLD] }, 7521 ); 7522 7523 observer.observe(trigger); 7524 return section; 7525} 7526 7527function initPrizeSparkleMotion(section) { 7528 if (!section) return; 7529 7530 const sparkles = Array.from(section.querySelectorAll(".prize-sparkle")); 7531 if (!section.classList.contains("is-motion-ready") || sparkles.length === 0) { 7532 section.classList.add("is-motion-complete"); 7533 return; 7534 } 7535 7536 const trigger = section.querySelector(".prize-stage"); 7537 if (!trigger) { 7538 section.classList.add("is-motion-complete"); 7539 return; 7540 } 7541 7542 const animationDuration = 1000; 7543 const startViewportRatio = 0.82; 7544 const endViewportRatio = 0.16; 7545 let animations = []; 7546 let frameRequest = 0; 7547 7548 const updateProgress = () => { 7549 frameRequest = 0; 7550 const { top } = trigger.getBoundingClientRect();
7551 const travel = window.innerHeight * (startViewportRatio - endViewportRatio); 7552 const progress = Math.min( 7553 1, 7554 Math.max(0, (window.innerHeight * startViewportRatio - top) / travel), 7555 ); 7556 7557 section.classList.toggle("is-motion-complete", progress >= 0.999); 7558 7559 animations.forEach((animation) => { 7560 animation.currentTime = progress * animationDuration; 7561 }); 7562 }; 7563 7564 const scheduleProgressUpdate = () => { 7565 if (frameRequest) return; 7566 frameRequest = window.requestAnimationFrame(updateProgress); 7567 }; 7568 7569 section.classList.remove("is-motion-complete"); 7570 section.classList.add("is-sparkle-active"); 7571 7572 window.requestAnimationFrame(() => { 7573 animations = sparkles.flatMap((sparkle) => sparkle.getAnimations()); 7574 if (animations.length === 0) { 7575 section.classList.remove("is-sparkle-active"); 7576 section.classList.add("is-motion-complete"); 7577 return; 7578 } 7579 7580 animations.forEach((animation) => { 7581 animation.pause(); 7582 animation.currentTime = 0; 7583 }); 7584 updateProgress(); 7585 }); 7586 7587 window.addEventListener("scroll", scheduleProgressUpdate, { passive: true }); 7588 window.addEventListener("resize", scheduleProgressUpdate, { passive: true }); 7589} 7590 7591function initRevealAnimations() { 7592 const prizes = revealOnce(".sorteo-preview", "[data-prize-card]", ".prize-stage"); 7593 initPrizeSparkleMotion(prizes); 7594 revealOnce(".participation", "[data-participation-card]", ".participation__steps"); 7595 revealOnce(".faq", ".faq__sleigh", ".faq__intro"); 7596 revealOnce(".discover", "[data-discover-card]", ".discover__products"); 7597} 7598 7599function initVillancicosRevealAnimation(section = document) { 7600 const wrapper = section.querySelector(".villancicos__wrapper"); 7601 if (!wrapper || wrapper.classList.contains("is-motion-ready")) return null; 7602 7603 if (!("IntersectionObserver" in window)) { 7604 wrapper.classList.add("is-visible"); 7605 return wrapper; 7606 } 7607 7608 wrapper.classList.add("is-motion-ready"); 7609 const observer = new IntersectionObserver( 7610 (entries) => { 7611 if (!entries.some((entry) => entry.isIntersecting)) return; 7612 wrapper.classList.add("is-visible"); 7613 observer.unobserve(wrapper); 7614 }, 7615 { threshold: [REVEAL_THRESHOLD] }, 7616 ); 7617 observer.observe(wrapper); 7618 return wrapper; 7619} 7620 7621function initWinnerRevealAnimations() { 7622 revealOnce(".winner-results__grand-prize"); 7623 revealOnce(".winner-results__list", "li:not([hidden])"); 7624 revealOnce(".winner-claim__steps", "li"); 7625} 7626 7627 7628/***/ }, 7629 7630/***/ "./src/features/site-header.js" 7631/*!*************************************!*\ 7632 !*** ./src/features/site-header.js ***! 7633 \*************************************/ 7634(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 7635 7636__webpack_require__.r(__webpack_exports__); 7637/* harmony export */ __webpack_require__.d(__webpack_exports__, { 7638/* harmony export */ initSiteHeader: () => (/* binding */ initSiteHeader) 7639/* harmony export */ }); 7640/* harmony import */ var gsap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! gsap */ "./node_modules/gsap/index.js"); 7641/* harmony import */ var gsap_ScrollToPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! gsap/ScrollToPlugin */ "./node_modules/gsap/ScrollToPlugin.js"); 7642 7643 7644 7645const DESKTOP_BREAKPOINT = 1024; 7646const HEADER_OFFSET = 120; 7647const HEADER_SCROLL_THRESHOLD = 120; 7648const MENU_FADE_DURATION_MS = 160; 7649const FIXED_CLASS = "site-header--fixed"; 7650const HIDDEN_CLASS = "site-header--hidden"; 7651 7652gsap__WEBPACK_IMPORTED_MODULE_0__.gsap.registerPlugin(gsap_ScrollToPlugin__WEBPACK_IMPORTED_MODULE_1__.ScrollToPlugin); 7653 7654function initSiteHeader() { 7655 const header = document.querySelector("[data-site-header]"); 7656 const toggle = document.querySelector("[data-menu-toggle]"); 7657 const menu = document.querySelector("[data-mobile-menu]"); 7658 if (!header || !toggle || !menu) return; 7659 7660 const overlay = document.querySelector("[data-menu-overlay]"); 7661 const backgroundRegions = Array.from(document.querySelectorAll("main, .site-footer")); 7662 const previousInert = new Map(); 7663 7664 const menuLinks = Array.from(menu.querySelectorAll("a")); 7665 let menuOpen = false; 7666 let menuCloseTimer; 7667 let lastScrollY = window.scrollY; 7668 let anchorFrame; 7669 let anchorTween; 7670 7671 const stopAnchorScroll = () => { 7672 const wasScrollingToAnchor = Boolean(anchorTween); 7673 window.cancelAnimationFrame(anchorFrame); 7674 anchorTween?.kill(); 7675 anchorTween = null; 7676 // Wheel puede llegar después del desplazamiento del compositor y antes 7677 // de scroll. No perder esa distancia cuando no hay un ancla que cancelar. 7678 if (wasScrollingToAnchor) lastScrollY = Math.max(window.scrollY, 0); 7679 }; 7680 7681 // Interrumpir por intención real del usuario. ScrollToPlugin autoKill puede 7682 // confundir las variaciones del viewport de iOS con un desplazamiento manual. 7683 window.addEventListener("touchstart", stopAnchorScroll, { passive: true }); 7684 window.addEventListener("wheel", stopAnchorScroll, { passive: true }); 7685 window.addEventListener("keydown", (event) => { 7686 if (["ArrowUp", "ArrowDown", "PageUp", "PageDown", "Home", "End", " ", "Escape"].includes(event.key)) { 7687 stopAnchorScroll(); 7688 } 7689 }); 7690 7691 if (lastScrollY > HEADER_SCROLL_THRESHOLD) { 7692 header.classList.add(FIXED_CLASS, HIDDEN_CLASS); 7693 } 7694 7695 const hideClosedMenu = () => { 7696 if (!menuOpen) { 7697 menu.hidden = true; 7698 if (overlay) overlay.hidden = true; 7699 } 7700 }; 7701 7702 const closeMenu = ({ restoreFocus = false } = {}) => { 7703 if (!menuOpen) return; 7704 7705 menuOpen = false;
7706 toggle.setAttribute("aria-expanded", "false"); 7707 toggle.setAttribute("aria-label", "Abrir menú"); 7708 menu.classList.remove("mobile-menu--visible"); 7709 document.body.classList.remove("menu-is-open"); 7710 overlay?.classList.remove("mobile-menu-overlay--visible"); 7711 previousInert.forEach((value, region) => { region.inert = value; }); 7712 previousInert.clear(); 7713 7714 window.clearTimeout(menuCloseTimer); 7715 menuCloseTimer = window.setTimeout( 7716 hideClosedMenu, 7717 MENU_FADE_DURATION_MS + 20, 7718 ); 7719 7720 if (restoreFocus) toggle.focus({ preventScroll: true }); 7721 }; 7722 7723 const openMenu = () => { 7724 stopAnchorScroll(); 7725 window.clearTimeout(menuCloseTimer); 7726 menuOpen = true; 7727 if (window.scrollY > 1) header.classList.add(FIXED_CLASS); 7728 header.classList.remove(HIDDEN_CLASS); 7729 toggle.setAttribute("aria-expanded", "true"); 7730 toggle.setAttribute("aria-label", "Cerrar menú"); 7731 menu.hidden = false; 7732 if (overlay) { 7733 overlay.hidden = false; 7734 overlay.getBoundingClientRect(); 7735 overlay.classList.add("mobile-menu-overlay--visible"); 7736 } 7737 backgroundRegions.forEach((region) => { 7738 previousInert.set(region, region.inert); 7739 region.inert = true; 7740 }); 7741 menu.getBoundingClientRect(); 7742 menu.classList.add("mobile-menu--visible"); 7743 document.body.classList.add("menu-is-open"); 7744 }; 7745 7746 toggle.addEventListener("click", () => { 7747 if (menuOpen) closeMenu({ restoreFocus: true }); 7748 else openMenu(); 7749 }); 7750 7751 overlay?.addEventListener("click", () => closeMenu({ restoreFocus: true })); 7752 7753 menuLinks.forEach((link) => { 7754 link.addEventListener("click", () => closeMenu()); 7755 }); 7756 7757 document.addEventListener("keydown", (event) => { 7758 if (event.key === "Escape" && menuOpen) closeMenu({ restoreFocus: true }); 7759 if (event.key === "Tab" && menuOpen) { 7760 const controls = Array.from(header.querySelectorAll("a, button")) 7761 .filter((control) => control.getClientRects().length && !control.closest("[hidden]")); 7762 const first = controls[0]; 7763 const last = controls.at(-1); 7764 if (event.shiftKey && document.activeElement === first) { 7765 event.preventDefault(); 7766 last?.focus(); 7767 } else if (!event.shiftKey && document.activeElement === last) { 7768 event.preventDefault(); 7769 first?.focus(); 7770 } 7771 } 7772 }); 7773 7774 document.addEventListener("click", (event) => { 7775 const link = event.target.closest("a[href^='#']"); 7776 if (!link) return; 7777 7778 const targetId = link.getAttribute("href"); 7779 if (!targetId || targetId === "#") return; 7780 7781 const target = document.querySelector(targetId); 7782 if (!target || target.hidden || target.closest("[hidden]")) return; 7783 7784 event.preventDefault(); 7785 stopAnchorScroll(); 7786 closeMenu(); 7787 gsap__WEBPACK_IMPORTED_MODULE_0__.gsap.killTweensOf(window); 7788 7789 // Medir tras retirar el bloqueo de scroll del menú, con el margen que 7790 // corresponde al header móvil (96px) o al de escritorio (120px). 7791 anchorFrame = window.requestAnimationFrame(() => { 7792 const offset = parseFloat(getComputedStyle(document.documentElement).scrollPaddingTop) 7793 || HEADER_OFFSET; 7794 header.classList.add(FIXED_CLASS); 7795 header.classList.remove(HIDDEN_CLASS); 7796 anchorTween = gsap__WEBPACK_IMPORTED_MODULE_0__.gsap.to(window, { 7797 duration: 0.65, 7798 ease: "power2.out", 7799 scrollTo: { 7800 y: target, 7801 offsetY: offset, 7802 autoKill: false, 7803 }, 7804 onComplete: () => { 7805 anchorTween = null; 7806 lastScrollY = Math.max(window.scrollY, 0); 7807 if (lastScrollY <= 1) header.classList.remove(FIXED_CLASS, HIDDEN_CLASS); 7808 }, 7809 }); 7810 }); 7811 }); 7812 7813 window.addEventListener( 7814 "scroll", 7815 () => { 7816 const currentScrollY = Math.max(window.scrollY, 0); 7817 if (anchorTween) { 7818 lastScrollY = currentScrollY; 7819 return; 7820 } 7821 // Un evento sin desplazamiento no indica que el usuario esté subiendo. 7822 if (currentScrollY === lastScrollY) return; 7823 const scrollingDown = currentScrollY > lastScrollY; 7824 7825 if (currentScrollY <= 1) { 7826 header.classList.remove(FIXED_CLASS, HIDDEN_CLASS); 7827 } else if (!menuOpen && scrollingDown && currentScrollY > HEADER_SCROLL_THRESHOLD) { 7828 header.classList.add(HIDDEN_CLASS); 7829 } else if (!scrollingDown) { 7830 const becomingFixed = !header.classList.contains(FIXED_CLASS); 7831 header.classList.add(FIXED_CLASS); 7832 7833 if (becomingFixed && header.classList.contains(HIDDEN_CLASS)) { 7834 header.getBoundingClientRect(); 7835 window.requestAnimationFrame(() => header.classList.remove(HIDDEN_CLASS)); 7836 } else { 7837 header.classList.remove(HIDDEN_CLASS); 7838 } 7839 } 7840 7841 lastScrollY = currentScrollY; 7842 }, 7843 { passive: true }, 7844 ); 7845 7846 window.addEventListener("resize", () => { 7847 if (window.innerWidth >= DESKTOP_BREAKPOINT) closeMenu(); 7848 }); 7849} 7850 7851 7852/***/ }, 7853 7854/***/ "./src/features/video-hero.js" 7855/*!************************************!*\ 7856 !*** ./src/features/video-hero.js ***! 7857 \************************************/ 7858(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 7859 7860__webpack_require__.r(__webpack_exports__); 7861/* harmony export */ __webpack_require__.d(__webpack_exports__, { 7862/* harmony export */ initVideoHero: () => (/* binding */ initVideoHero) 7863/* harmony export */ }); 7864/* harmony import */ var _app_media__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../app/media */ "./src/app/media.js"); 7865/* harmony import */ var _youtube_player__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./youtube-player */ "./src/features/youtube-player.js"); 7866 7867 7868 7869function initVideoHero(config) {
7870 const section = document.querySelector("[data-video-hero]"); 7871 const title = section?.querySelector("[data-video-hero-title]"); 7872 const backdropContainer = section?.querySelector("[data-video-hero-player]"); 7873 7874 if ( 7875 !section 7876 || section.hidden 7877 || !title 7878 || !backdropContainer 7879 || !(0,_app_media__WEBPACK_IMPORTED_MODULE_0__.configuredYoutubeVideo)(config) 7880 ) return null; 7881 7882 title.textContent = config.title; 7883 const backdrop = (0,_youtube_player__WEBPACK_IMPORTED_MODULE_1__.createYoutubeBackdrop)(config); 7884 backdropContainer.replaceChildren(backdrop); 7885 return { backdrop }; 7886} 7887 7888 7889/***/ }, 7890 7891/***/ "./src/features/villancicos.js" 7892/*!*************************************!*\ 7893 !*** ./src/features/villancicos.js ***! 7894 \*************************************/ 7895(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 7896 7897__webpack_require__.r(__webpack_exports__); 7898/* harmony export */ __webpack_require__.d(__webpack_exports__, { 7899/* harmony export */ initVillancicos: () => (/* binding */ initVillancicos) 7900/* harmony export */ }); 7901/* harmony import */ var _app_media__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../app/media */ "./src/app/media.js"); 7902/* harmony import */ var _youtube_player__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./youtube-player */ "./src/features/youtube-player.js"); 7903/* harmony import */ var _reveal_on_view__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./reveal-on-view */ "./src/features/reveal-on-view.js"); 7904 7905 7906 7907 7908function createSlide(video, coordinator) { 7909 const slide = document.createElement("div"); 7910 slide.className = "swiper-slide villancicos-slide"; 7911 7912 const article = document.createElement("article"); 7913 article.className = "villancicos-mini"; 7914 article.setAttribute("aria-label", video.title); 7915 7916 const playerElement = document.createElement("div"); 7917 playerElement.className = "youtube-player villancicos-player"; 7918 article.append(playerElement); 7919 slide.append(article); 7920 7921 let player; 7922 player = (0,_youtube_player__WEBPACK_IMPORTED_MODULE_1__.createYoutubePlayer)(playerElement, video, { 7923 onPlay: () => coordinator.activate(player), 7924 onStop: () => coordinator.release(player), 7925 }); 7926 coordinator.register(player); 7927 7928 return { slide, player }; 7929} 7930 7931function createPlaceholderSlide(title) { 7932 const slide = document.createElement("div"); 7933 slide.className = "swiper-slide villancicos-slide"; 7934 7935 const article = document.createElement("article"); 7936 article.className = "villancicos-mini villancicos-mini--placeholder"; 7937 article.setAttribute("aria-label", `${title}. Contenido pendiente de aprobación.`); 7938 slide.append(article); 7939 7940 return { 7941 slide, 7942 player: { 7943 reset() {}, 7944 }, 7945 }; 7946} 7947 7948async function initSlider(section, config, coordinator) { 7949 const sliderElement = section?.querySelector("[data-villancicos-slider]"); 7950 const slidesElement = section?.querySelector("[data-villancicos-slides]"); 7951 const title = section?.querySelector("[data-villancicos-title]"); 7952 const previous = section?.querySelector("[data-villancicos-previous]"); 7953 const next = section?.querySelector("[data-villancicos-next]"); 7954 const pagination = section?.querySelector("[data-villancicos-pagination]"); 7955 7956 if ( 7957 !section 7958 || section.hidden 7959 || !sliderElement 7960 || !slidesElement 7961 || !title 7962 || !previous 7963 || !next 7964 || !pagination 7965 || !(0,_app_media__WEBPACK_IMPORTED_MODULE_0__.displayableYoutubeSlider)(config) 7966 ) return null; 7967 7968 section.hidden = true; 7969 const videos = Array.isArray(config.videos) 7970 ? config.videos.filter(_app_media__WEBPACK_IMPORTED_MODULE_0__.configuredYoutubeVideo) 7971 : []; 7972 title.textContent = config.title; 7973 const entries = videos.length > 0 7974 ? videos.map((video) => createSlide(video, coordinator)) 7975 : Array.from( 7976 { length: Math.min(config.placeholderSlides, 5) }, 7977 () => createPlaceholderSlide(config.title), 7978 ); 7979 slidesElement.replaceChildren(...entries.map(({ slide }) => slide)); 7980 7981 try { 7982 const { mountVillancicos } = await Promise.all(/*! import() | villancicos */[__webpack_require__.e("vendors-node_modules_swiper_modules_a11y_css-node_modules_swiper_modules_pagination_css-node_-f6284a"), __webpack_require__.e("villancicos")]).then(__webpack_require__.bind(__webpack_require__, /*! ./villancicos-swiper */ "./src/features/villancicos-swiper.js")); 7983 section.hidden = false;
7984 section.dataset.villancicosState = "ready"; 7985 mountVillancicos({ 7986 sliderElement, 7987 previous, 7988 next, 7989 pagination, 7990 title: config.title, 7991 entries, 7992 }); 7993 (0,_reveal_on_view__WEBPACK_IMPORTED_MODULE_2__.initVillancicosRevealAnimation)(section); 7994 7995 if ("IntersectionObserver" in window) { 7996 const observer = new IntersectionObserver((observations) => { 7997 if (observations.some((observation) => !observation.isIntersecting)) { 7998 entries.forEach(({ player }) => player.reset()); 7999 } 8000 }); 8001 observer.observe(section); 8002 } 8003 return section; 8004 } catch { 8005 section.hidden = true; 8006 section.dataset.villancicosState = "error"; 8007 return null; 8008 } 8009} 8010 8011async function initVillancicos(config, coordinator) { 8012 const sections = Array.from(document.querySelectorAll("[data-villancicos-section]")); 8013 const configByKey = (0,_app_media__WEBPACK_IMPORTED_MODULE_0__.configuredYoutubeSlider)(config) 8014 || (0,_app_media__WEBPACK_IMPORTED_MODULE_0__.configuredYoutubePlaceholderSlider)(config) 8015 ? { villancicos: config } 8016 : config; 8017 8018 return Promise.all(sections.map((section) => { 8019 const key = section.dataset.videoSliderKey || "villancicos"; 8020 return initSlider(section, configByKey?.[key], coordinator); 8021 })); 8022} 8023 8024 8025/***/ }, 8026 8027/***/ "./src/features/youtube-player.js" 8028/*!****************************************!*\ 8029 !*** ./src/features/youtube-player.js ***! 8030 \****************************************/ 8031(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 8032 8033__webpack_require__.r(__webpack_exports__); 8034/* harmony export */ __webpack_require__.d(__webpack_exports__, { 8035/* harmony export */ createYoutubeBackdrop: () => (/* binding */ createYoutubeBackdrop), 8036/* harmony export */ createYoutubePlayer: () => (/* binding */ createYoutubePlayer), 8037/* harmony export */ createYoutubePreview: () => (/* binding */ createYoutubePreview) 8038/* harmony export */ }); 8039/* harmony import */ var _app_media__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../app/media */ "./src/app/media.js"); 8040/* harmony import */ var _app_safe_url__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../app/safe-url */ "./src/app/safe-url.js"); 8041 8042 8043 8044function createYoutubePreview(video, onPlay) { 8045 const button = document.createElement("button"); 8046 button.className = "youtube-player__preview"; 8047 button.type = "button"; 8048 button.setAttribute("aria-label", `Reproducir ${video.title}`); 8049 8050 const posterUrl = (0,_app_media__WEBPACK_IMPORTED_MODULE_0__.nonEmptyString)(video.posterUrl) 8051 ? (0,_app_safe_url__WEBPACK_IMPORTED_MODULE_1__.safeHttpUrl)(video.posterUrl, { allowedOrigins: _app_safe_url__WEBPACK_IMPORTED_MODULE_1__.YOUTUBE_POSTER_ORIGINS }) 8052 : null; 8053 const backgroundVideoUrl = (0,_app_media__WEBPACK_IMPORTED_MODULE_0__.nonEmptyString)(video.backgroundVideoUrl) 8054 ? (0,_app_safe_url__WEBPACK_IMPORTED_MODULE_1__.safeHttpUrl)(video.backgroundVideoUrl, { allowedOrigins: _app_safe_url__WEBPACK_IMPORTED_MODULE_1__.SUCHARD_VIDEO_ORIGINS }) 8055 : null; 8056 8057 if (backgroundVideoUrl) { 8058 const backgroundVideo = document.createElement("video"); 8059 backgroundVideo.className = "youtube-player__background-video"; 8060 backgroundVideo.src = backgroundVideoUrl; 8061 backgroundVideo.autoplay = true; 8062 backgroundVideo.loop = true; 8063 backgroundVideo.muted = true; 8064 backgroundVideo.defaultMuted = true; 8065 backgroundVideo.playsInline = true; 8066 backgroundVideo.preload = "metadata"; 8067 backgroundVideo.controls = false; 8068 backgroundVideo.disablePictureInPicture = true; 8069 backgroundVideo.setAttribute("muted", ""); 8070 backgroundVideo.setAttribute("aria-hidden", "true"); 8071 if (posterUrl) backgroundVideo.poster = posterUrl; 8072 button.append(backgroundVideo); 8073 } else if (posterUrl) { 8074 const image = document.createElement("img"); 8075 image.src = posterUrl; 8076 image.alt = ""; 8077 image.loading = "lazy"; 8078 image.decoding = "async"; 8079 button.append(image); 8080 } 8081 8082 const playIcon = document.createElement("span"); 8083 playIcon.className = "youtube-player__play-icon"; 8084 playIcon.setAttribute("aria-hidden", "true"); 8085 button.append(playIcon); 8086 button.addEventListener("click", () => { 8087 onPlay?.(); 8088 }); 8089 return button; 8090} 8091 8092function createYoutubeBackdrop(video) { 8093 const backdrop = document.createElement("div"); 8094 backdrop.className = "youtube-player__backdrop"; 8095 backdrop.setAttribute("aria-hidden", "true"); 8096 8097 const posterUrl = (0,_app_media__WEBPACK_IMPORTED_MODULE_0__.nonEmptyString)(video.posterUrl) 8098 ? (0,_app_safe_url__WEBPACK_IMPORTED_MODULE_1__.safeHttpUrl)(video.posterUrl, { allowedOrigins: _app_safe_url__WEBPACK_IMPORTED_MODULE_1__.YOUTUBE_POSTER_ORIGINS }) 8099 : null; 8100 const backgroundVideoUrl = (0,_app_media__WEBPACK_IMPORTED_MODULE_0__.nonEmptyString)(video.backgroundVideoUrl) 8101 ? (0,_app_safe_url__WEBPACK_IMPORTED_MODULE_1__.safeHttpUrl)(video.backgroundVideoUrl, { allowedOrigins: _app_safe_url__WEBPACK_IMPORTED_MODULE_1__.SUCHARD_VIDEO_ORIGINS }) 8102 : null; 8103 8104 if (backgroundVideoUrl) { 8105 const backgroundVideo = document.createElement("video"); 8106 backgroundVideo.className = "youtube-player__background-video"; 8107 backgroundVideo.src = backgroundVideoUrl; 8108 backgroundVideo.autoplay = true; 8109 backgroundVideo.loop = true; 8110 backgroundVideo.muted = true; 8111 backgroundVideo.defaultMuted = true;
8112 backgroundVideo.playsInline = true; 8113 backgroundVideo.preload = "metadata"; 8114 backgroundVideo.controls = false; 8115 backgroundVideo.disablePictureInPicture = true; 8116 backgroundVideo.setAttribute("muted", ""); 8117 if (posterUrl) backgroundVideo.poster = posterUrl; 8118 backdrop.append(backgroundVideo); 8119 } else if (posterUrl) { 8120 const image = document.createElement("img"); 8121 image.src = posterUrl; 8122 image.alt = ""; 8123 image.loading = "eager"; 8124 image.decoding = "async"; 8125 backdrop.append(image); 8126 } 8127 8128 return backdrop; 8129} 8130 8131function createYoutubePlayer(container, video, options = {}) { 8132 let playing = false; 8133 8134 const renderPreview = () => { 8135 playing = false; 8136 container.replaceChildren(createYoutubePreview( 8137 video, 8138 () => play({ autoplay: true, muted: false }), 8139 )); 8140 }; 8141 8142 const play = ({ autoplay = false, muted = false } = {}) => { 8143 const iframe = (0,_app_media__WEBPACK_IMPORTED_MODULE_0__.createYoutubeIframe)(video, { 8144 autoplay, 8145 loop: options.loop === true, 8146 loading: options.loading, 8147 muted, 8148 }); 8149 if (!iframe) return false; 8150 8151 options.onPlay?.(); 8152 playing = true; 8153 container.replaceChildren(iframe); 8154 return true; 8155 }; 8156 8157 renderPreview(); 8158 8159 return { 8160 play, 8161 reset() { 8162 if (!playing) return; 8163 renderPreview(); 8164 options.onStop?.(); 8165 }, 8166 stop() { 8167 if (!playing) return; 8168 renderPreview(); 8169 options.onStop?.(); 8170 }, 8171 get playing() { 8172 return playing; 8173 }, 8174 }; 8175} 8176 8177 8178/***/ }, 8179 8180/***/ "./src/landing.js" 8181/*!************************!*\ 8182 !*** ./src/landing.js ***! 8183 \************************/ 8184(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 8185 8186__webpack_require__.r(__webpack_exports__); 8187/* harmony export */ __webpack_require__.d(__webpack_exports__, { 8188/* harmony export */ initLanding: () => (/* binding */ initLanding) 8189/* harmony export */ }); 8190/* harmony import */ var _campaign_config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./campaign-config */ "./src/campaign-config.js"); 8191/* harmony import */ var _app_campaign__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./app/campaign */ "./src/app/campaign.js"); 8192/* harmony import */ var _app_media_coordinator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./app/media-coordinator */ "./src/app/media-coordinator.js"); 8193/* harmony import */ var _features_faq__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./features/faq */ "./src/features/faq.js"); 8194/* harmony import */ var _features_jingle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./features/jingle */ "./src/features/jingle.js"); 8195/* harmony import */ var _features_newsletter_dialog__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./features/newsletter-dialog */ "./src/features/newsletter-dialog.js"); 8196/* harmony import */ var _features_reveal_on_view__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./features/reveal-on-view */ "./src/features/reveal-on-view.js"); 8197/* harmony import */ var _features_site_header__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./features/site-header */ "./src/features/site-header.js"); 8198/* harmony import */ var _features_video_hero__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./features/video-hero */ "./src/features/video-hero.js"); 8199/* harmony import */ var _features_villancicos__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./features/villancicos */ "./src/features/villancicos.js"); 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211function initLanding(config = _campaign_config__WEBPACK_IMPORTED_MODULE_0__.campaignConfig) { 8212 const mediaCoordinator = (0,_app_media_coordinator__WEBPACK_IMPORTED_MODULE_2__.createMediaCoordinator)(); 8213 (0,_app_campaign__WEBPACK_IMPORTED_MODULE_1__.initCampaign)(config); 8214 (0,_features_reveal_on_view__WEBPACK_IMPORTED_MODULE_6__.initRevealAnimations)(); 8215 (0,_features_faq__WEBPACK_IMPORTED_MODULE_3__.initFaq)(); 8216 (0,_features_newsletter_dialog__WEBPACK_IMPORTED_MODULE_5__.initNewsletterDialog)(config); 8217 (0,_features_jingle__WEBPACK_IMPORTED_MODULE_4__.initJingle)(config.jingle, config.activePhase, mediaCoordinator); 8218 (0,_features_video_hero__WEBPACK_IMPORTED_MODULE_8__.initVideoHero)(config.youtube?.header); 8219 (0,_features_villancicos__WEBPACK_IMPORTED_MODULE_9__.initVillancicos)({ 8220 stories: config.youtube?.stories, 8221 villancicos: config.youtube?.slider, 8222 }, mediaCoordinator); 8223 (0,_features_site_header__WEBPACK_IMPORTED_MODULE_7__.initSiteHeader)(); 8224} 8225 8226 8227/***/ }, 8228 8229/***/ "./src/winners.js" 8230/*!************************!*\ 8231 !*** ./src/winners.js ***! 8232 \************************/ 8233(__unused_webpack_module, __webpack_exports__, __webpack_require__) { 8234 8235__webpack_require__.r(__webpack_exports__); 8236/* harmony export */ __webpack_require__.d(__webpack_exports__, { 8237/* harmony export */ initWinners: () => (/* binding */ initWinners) 8238/* harmony export */ }); 8239/* harmony import */ var _campaign_config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./campaign-config */ "./src/campaign-config.js"); 8240/* harmony import */ var _app_media__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./app/media */ "./src/app/media.js"); 8241/* harmony import */ var _app_safe_url__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./app/safe-url */ "./src/app/safe-url.js"); 8242/* harmony import */ var _features_reveal_on_view__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./features/reveal-on-view */ "./src/features/reveal-on-view.js"); 8243 8244 8245 8246 8247 8248const MOBILE_INITIAL_RESULTS = 8; 8249 8250function winnerLabel({ number, series }, referencePlaceholder = false) { 8251 if (referencePlaceholder) return "Núm: XXXXX | Serie: XX"; 8252 return `Núm: ${number} | Serie: ${series}`; 8253} 8254 8255function grandPrizeLabel({ number, series }, referencePlaceholder = false) { 8256 const numberLabel = document.createElement("span"); 8257 numberLabel.textContent = `Núm: ${referencePlaceholder ? "XXXXX" : number}`; 8258 const separator = document.createElement("span"); 8259 separator.className = "winner-results__grand-prize-separator"; 8260 separator.textContent = " | "; 8261 const seriesLabel = document.createElement("span"); 8262 seriesLabel.textContent = `Serie: ${referencePlaceholder ? "XX" : series}`; 8263 return [numberLabel, separator, seriesLabel]; 8264} 8265 8266function initWinners(config = _campaign_config__WEBPACK_IMPORTED_MODULE_0__.campaignConfig) { 8267 const section = document.querySelector("[data-winner-results]"); 8268 const data = config.winners; 8269 8270 if (!section || !data?.grandPrize || !data?.secondaryPrizes?.length) return; 8271 8272 const grandPrize = section.querySelector("[data-grand-prize]"); 8273 const demoNotice = section.querySelector("[data-winner-demo-note]"); 8274 const introCopy = section.querySelector("[data-winner-intro]"); 8275 const secondaryTitle = section.querySelector("[data-secondary-title]"); 8276 const secondaryCopy = section.querySelector("[data-secondary-copy]"); 8277 const list = section.querySelector("[data-secondary-winners]");
8278 const loadMore = section.querySelector("[data-load-more]"); 8279 const status = section.querySelector("[data-winner-status]"); 8280 const referencePlaceholder = data.referencePlaceholder === true; 8281 const initialVisibleResults = window.matchMedia("(width < 1024px)").matches 8282 ? MOBILE_INITIAL_RESULTS 8283 : data.secondaryPrizes.length; 8284 let visibleResults = initialVisibleResults; 8285 8286 const grandPrizeNumber = document.createElement("p"); 8287 grandPrizeNumber.replaceChildren(...grandPrizeLabel(data.grandPrize, referencePlaceholder)); 8288 const grandPrizeTitle = document.createElement("h3"); 8289 grandPrizeTitle.textContent = (0,_app_media__WEBPACK_IMPORTED_MODULE_1__.nonEmptyString)(data.grandPrizeTitle) 8290 ? data.grandPrizeTitle 8291 : "Primer Premio: 100.000â¬"; 8292 grandPrize.replaceChildren(grandPrizeNumber, grandPrizeTitle); 8293 8294 if (demoNotice && (0,_app_media__WEBPACK_IMPORTED_MODULE_1__.nonEmptyString)(data.demoNotice)) { 8295 demoNotice.textContent = data.demoNotice; 8296 demoNotice.hidden = false; 8297 } 8298 8299 if (introCopy && (0,_app_media__WEBPACK_IMPORTED_MODULE_1__.nonEmptyString)(data.introCopy)) { 8300 introCopy.textContent = data.introCopy; 8301 } 8302 8303 if (secondaryTitle && (0,_app_media__WEBPACK_IMPORTED_MODULE_1__.nonEmptyString)(data.secondaryTitle)) { 8304 secondaryTitle.textContent = data.secondaryTitle; 8305 } 8306 8307 secondaryCopy.textContent = (0,_app_media__WEBPACK_IMPORTED_MODULE_1__.nonEmptyString)(data.secondaryCopy) 8308 ? data.secondaryCopy 8309 : "Comprueba si la combinación de tu envoltorio (Número y Serie) se encuentra en la siguiente lista o descárgate el listado oficial (PDF)."; 8310 8311 const officialPdfUrl = (0,_app_safe_url__WEBPACK_IMPORTED_MODULE_2__.safeHttpUrl)(data.officialPdfUrl, { allowAnyHttps: true }); 8312 if (officialPdfUrl) { 8313 secondaryCopy.textContent = "Comprueba si la combinación de tu envoltorio (Número y Serie) se encuentra en la siguiente lista o "; 8314 const officialPdf = document.createElement("a"); 8315 officialPdf.href = officialPdfUrl; 8316 officialPdf.target = "_blank"; 8317 officialPdf.rel = "noopener noreferrer"; 8318 officialPdf.textContent = "descárgate el listado oficial (PDF)."; 8319 secondaryCopy.append(officialPdf); 8320 } else if (!secondaryCopy.textContent.trim().endsWith(".")) { 8321 secondaryCopy.append("."); 8322 } 8323 8324 list.replaceChildren(); 8325 const items = data.secondaryPrizes.map((winner) => { 8326 const item = document.createElement("li"); 8327 item.textContent = winnerLabel(winner, referencePlaceholder); 8328 list.append(item); 8329 return item; 8330 }); 8331 8332 const updateResults = () => { 8333 items.forEach((item) => { 8334 item.hidden = true; 8335 }); 8336 items.forEach((item, index) => { 8337 item.hidden = index >= visibleResults; 8338 }); 8339 8340 const shown = Math.min(visibleResults, items.length);
8341 loadMore.hidden = shown >= items.length; 8342 status.textContent = `${shown} de ${items.length} números mostrados.`; 8343 }; 8344 8345 loadMore.addEventListener("click", () => { 8346 visibleResults += MOBILE_INITIAL_RESULTS; 8347 updateResults(); 8348 }); 8349 8350 section.hidden = false; 8351 updateResults(); 8352 (0,_features_reveal_on_view__WEBPACK_IMPORTED_MODULE_3__.initWinnerRevealAnimations)(); 8353} 8354 8355 8356/***/ }, 8357 8358/***/ "./src/assets/audio/mc-suchard-60s-master-v1-14lufs.mp3" 8359/*!**************************************************************!*\ 8360 !*** ./src/assets/audio/mc-suchard-60s-master-v1-14lufs.mp3 ***! 8361 \**************************************************************/ 8362(module, __unused_webpack_exports, __webpack_require__) { 8363 8364module.exports = __webpack_require__.p + "audio/mc-suchard-60s-master-v1-14lufs.mp3"; 8365 8366/***/ }, 8367 8368/***/ "./src/assets/figma/hero-desktop.avif" 8369/*!********************************************!*\ 8370 !*** ./src/assets/figma/hero-desktop.avif ***! 8371 \********************************************/ 8372(module, __unused_webpack_exports, __webpack_require__) { 8373 8374module.exports = __webpack_require__.p + "img/hero-desktop.avif"; 8375 8376/***/ }, 8377 8378/***/ "./src/assets/figma/hero-desktop.webp" 8379/*!********************************************!*\ 8380 !*** ./src/assets/figma/hero-desktop.webp ***! 8381 \********************************************/ 8382(module, __unused_webpack_exports, __webpack_require__) { 8383 8384module.exports = __webpack_require__.p + "img/hero-desktop.webp"; 8385 8386/***/ }, 8387 8388/***/ "./src/assets/figma/hero-mobile-lcp.avif" 8389/*!***********************************************!*\ 8390 !*** ./src/assets/figma/hero-mobile-lcp.avif ***! 8391 \***********************************************/ 8392(module, __unused_webpack_exports, __webpack_require__) { 8393 8394module.exports = __webpack_require__.p + "img/hero-mobile-lcp.avif"; 8395 8396/***/ }, 8397 8398/***/ "./src/assets/figma/hero-mobile-lcp.webp" 8399/*!***********************************************!*\ 8400 !*** ./src/assets/figma/hero-mobile-lcp.webp ***! 8401 \***********************************************/ 8402(module, __unused_webpack_exports, __webpack_require__) { 8403 8404module.exports = __webpack_require__.p + "img/hero-mobile-lcp.webp"; 8405 8406/***/ }, 8407 8408/***/ "./src/assets/figma/winners/couple-scene.webp" 8409/*!****************************************************!*\ 8410 !*** ./src/assets/figma/winners/couple-scene.webp ***! 8411 \****************************************************/ 8412(module, __unused_webpack_exports, __webpack_require__) { 8413 8414module.exports = __webpack_require__.p + "img/couple-scene.webp"; 8415 8416/***/ }, 8417 8418/***/ "./src/assets/fonts/Geist-LICENSE.txt" 8419/*!********************************************!*\ 8420 !*** ./src/assets/fonts/Geist-LICENSE.txt ***! 8421 \********************************************/ 8422(module, __unused_webpack_exports, __webpack_require__) { 8423 8424module.exports = __webpack_require__.p + "licenses/Geist-LICENSE.txt"; 8425 8426/***/ } 8427 8428/******/ }); 8429/************************************************************************/ 8430/******/ // The module cache 8431/******/ const __webpack_module_cache__ = {}; 8432/******/ 8433/******/ // The require function 8434/******/ function __webpack_require__(moduleId) { 8435/******/ // Check if module is in cache 8436/******/ const cachedModule = __webpack_module_cache__[moduleId]; 8437/******/ if (cachedModule !== undefined) { 8438/******/ return cachedModule.exports; 8439/******/ } 8440/******/ // Create a new module (and put it into the cache) 8441/******/ const module = __webpack_module_cache__[moduleId] = { 8442/******/ // no module.id needed 8443/******/ // no module.loaded needed 8444/******/ exports: {} 8445/******/ }; 8446/******/ 8447/******/ // Execute the module function 8448/******/ if (!(moduleId in __webpack_modules__)) { 8449/******/ delete __webpack_module_cache__[moduleId]; 8450/******/ const e = new Error("Cannot find module '" + moduleId + "'"); 8451/******/ e.code = 'MODULE_NOT_FOUND'; 8452/******/ throw e; 8453/******/ } 8454/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 8455/******/ 8456/******/ // Return the exports of the module 8457/******/ return module.exports; 8458/******/ } 8459/******/ 8460/******/ // expose the modules object (__webpack_modules__) 8461/******/ __webpack_require__.m = __webpack_modules__; 8462/******/ 8463/************************************************************************/ 8464/******/ /* webpack/runtime/define property getters */ 8465/******/ (() => { 8466/******/ // define getter/value functions for harmony exports 8467/******/ __webpack_require__.d = (exports, definition) => { 8468/******/ if(Array.isArray(definition)) { 8469/******/ var i = 0; 8470/******/ while(i < definition.length) { 8471/******/ var key = definition[i++]; 8472/******/ var binding = definition[i++]; 8473/******/ if(!__webpack_require__.o(exports, key)) { 8474/******/ if(binding === 0) { 8475/******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] }); 8476/******/ } else { 8477/******/ Object.defineProperty(exports, key, { enumerable: true, get: binding }); 8478/******/ } 8479/******/ } else if(binding === 0) { i++; } 8480/******/ } 8481/******/ } else { 8482/******/ for(var key in definition) { 8483/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 8484/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 8485/******/ } 8486/******/ } 8487/******/ } 8488/******/ }; 8489/******/ })(); 8490/******/ 8491/******/ /* webpack/runtime/ensure chunk */ 8492/******/ (() => { 8493/******/ __webpack_require__.f = {}; 8494/******/ // This file contains only the entry chunk.
8495/******/ // The chunk loading function for additional chunks 8496/******/ __webpack_require__.e = (chunkId) => { 8497/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => { 8498/******/ __webpack_require__.f[key](chunkId, promises); 8499/******/ return promises; 8500/******/ }, [])); 8501/******/ }; 8502/******/ })(); 8503/******/ 8504/******/ /* webpack/runtime/get javascript chunk filename */ 8505/******/ (() => { 8506/******/ // This function allow to reference async chunks 8507/******/ __webpack_require__.u = (chunkId) => { 8508/******/ // return url for filenames based on template 8509/******/ return "" + chunkId + ".js"; 8510/******/ }; 8511/******/ })(); 8512/******/ 8513/******/ /* webpack/runtime/get mini-css chunk filename */ 8514/******/ (() => { 8515/******/ // This function allow to reference async chunks 8516/******/ __webpack_require__.miniCssF = (chunkId) => { 8517/******/ // return url for filenames based on template 8518/******/ return "" + chunkId + ".css"; 8519/******/ }; 8520/******/ })(); 8521/******/ 8522/******/ /* webpack/runtime/global */ 8523/******/ (() => { 8524/******/ __webpack_require__.g = (function() { 8525/******/ if (typeof globalThis === 'object') return globalThis; 8526/******/ try { 8527/******/ return this || new Function('return this')(); 8528/******/ } catch (e) { 8529/******/ if (typeof window === 'object') return window; 8530/******/ } 8531/******/ })(); 8532/******/ })(); 8533/******/ 8534/******/ /* webpack/runtime/hasOwnProperty shorthand */ 8535/******/ (() => { 8536/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 8537/******/ })(); 8538/******/ 8539/******/ /* webpack/runtime/load script */ 8540/******/ (() => { 8541/******/ const inProgress = {}; 8542/******/ const dataWebpackPrefix = "suchard-navidad-2026:"; 8543/******/ // loadScript function to load a script via script tag 8544/******/ __webpack_require__.l = (url, done, key, chunkId) => { 8545/******/ if(inProgress[url]) { inProgress[url].push(done); return; } 8546/******/ let script, needAttach; 8547/******/ if(key !== undefined) { 8548/******/ const scripts = document.getElementsByTagName("script"); 8549/******/ for(var i = 0; i < scripts.length; i++) { 8550/******/ const s = scripts[i]; 8551/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; } 8552/******/ } 8553/******/ } 8554/******/ if(!script) { 8555/******/ needAttach = true; 8556/******/ script = document.createElement('script'); 8557/******/ 8558/******/ script.charset = 'utf-8'; 8559/******/ if (__webpack_require__.nc) { 8560/******/ script.setAttribute("nonce", __webpack_require__.nc); 8561/******/ } 8562/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key); 8563/******/ 8564/******/ script.src = url; 8565/******/ } 8566/******/ inProgress[url] = [done]; 8567/******/ const onScriptComplete = (prev, event) => { 8568/******/ // avoid mem leaks in IE. 8569/******/ script.onerror = script.onload = null; 8570/******/ clearTimeout(timeout); 8571/******/ const doneFns = inProgress[url]; 8572/******/ delete inProgress[url]; 8573/******/ script.parentNode?.removeChild(script); 8574/******/ doneFns?.forEach((fn) => (fn(event))); 8575/******/ if(prev) return prev(event); 8576/******/ } 8577/******/ const timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000); 8578/******/ script.onerror = onScriptComplete.bind(null, script.onerror); 8579/******/ script.onload = onScriptComplete.bind(null, script.onload); 8580/******/ needAttach && document.head.appendChild(script); 8581/******/ }; 8582/******/ })(); 8583/******/ 8584/******/ /* webpack/runtime/make namespace object */ 8585/******/ (() => { 8586/******/ // define __esModule on exports 8587/******/ __webpack_require__.r = (exports) => { 8588/******/ if(Symbol.toStringTag) { 8589/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 8590/******/ } 8591/******/ Object.defineProperty(exports, '__esModule', { value: true }); 8592/******/ }; 8593/******/ })(); 8594/******/ 8595/******/ /* webpack/runtime/publicPath */ 8596/******/ (() => { 8597/******/ let scriptUrl; 8598/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + ""; 8599/******/ const document = __webpack_require__.g.document; 8600/******/ if (!scriptUrl && document) { 8601/******/ if (document.currentScript?.tagName.toUpperCase() === 'SCRIPT') 8602/******/ scriptUrl = document.currentScript.src; 8603/******/ if (!scriptUrl) { 8604/******/ const scripts = document.getElementsByTagName("script"); 8605/******/ if(scripts.length) { 8606/******/ let i = scripts.length - 1; 8607/******/ while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src; 8608/******/ } 8609/******/ } 8610/******/ } 8611/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration 8612/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your co
8612de to use your own logic. 8613/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser"); 8614/******/ scriptUrl = scriptUrl.replace(/^blob:/, "").replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/"); 8615/******/ __webpack_require__.p = scriptUrl; 8616/******/ })(); 8617/******/ 8618/******/ /* webpack/runtime/css loading */ 8619/******/ (() => { 8620/******/ if (typeof document === "undefined") return; 8621/******/ var createStylesheet = (chunkId, fullhref, oldTag, resolve, reject) => { 8622/******/ var linkTag = document.createElement("link"); 8623/******/ 8624/******/ linkTag.rel = "stylesheet"; 8625/******/ linkTag.type = "text/css"; 8626/******/ if (__webpack_require__.nc) { 8627/******/ linkTag.nonce = __webpack_require__.nc; 8628/******/ } 8629/******/ var onLinkComplete = (event) => { 8630/******/ // avoid mem leaks. 8631/******/ linkTag.onerror = linkTag.onload = null; 8632/******/ if (event.type === 'load') { 8633/******/ resolve(); 8634/******/ } else { 8635/******/ var errorType = event && event.type; 8636/******/ var realHref = event && event.target && event.target.href || fullhref; 8637/******/ var err = new Error("Loading CSS chunk " + chunkId + " failed.\n(" + errorType + ": " + realHref + ")"); 8638/******/ err.name = "ChunkLoadError"; 8639/******/ err.code = "CSS_CHUNK_LOAD_FAILED"; 8640/******/ err.type = errorType; 8641/******/ err.request = realHref; 8642/******/ if (linkTag.parentNode) linkTag.parentNode.removeChild(linkTag) 8643/******/ reject(err); 8644/******/ } 8645/******/ } 8646/******/ linkTag.onerror = linkTag.onload = onLinkComplete; 8647/******/ linkTag.href = fullhref; 8648/******/ 8649/******/ 8650/******/ if (oldTag) { 8651/******/ oldTag.parentNode.insertBefore(linkTag, oldTag.nextSibling); 8652/******/ } else { 8653/******/ document.head.appendChild(linkTag); 8654/******/ } 8655/******/ return linkTag; 8656/******/ }; 8657/******/ var findStylesheet = (href, fullhref) => { 8658/******/ var existingLinkTags = document.getElementsByTagName("link"); 8659/******/ for(var i = 0; i < existingLinkTags.length; i++) { 8660/******/ var tag = existingLinkTags[i]; 8661/******/ var dataHref = tag.getAttribute("data-href") || tag.getAttribute("href"); 8662/******/ if(tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref)) return tag; 8663/******/ } 8664/******/ var existingStyleTags = document.getElementsByTagName("style"); 8665/******/ for(var i = 0; i < existingStyleTags.length; i++) { 8666/******/ var tag = existingStyleTags[i]; 8667/******/ var dataHref = tag.getAttribute("data-href"); 8668/******/ if(dataHref === href || dataHref === fullhref) return tag; 8669/******/ } 8670/******/ }; 8671/******/ var loadStylesheet = (chunkId) => { 8672/******/ return new Promise((resolve, reject) => { 8673/******/ var href = __webpack_require__.miniCssF(chunkId); 8674/******/ var fullhref = __webpack_require__.p + href; 8675/******/ if(findStylesheet(href, fullhref)) return resolve(); 8676/******/ createStylesheet(chunkId, fullhref, null, resolve, reject); 8677/******/ }); 8678/******/ } 8679/******/ // object to store loaded CSS chunks 8680/******/ var installedCssChunks = { 8681/******/ "main": 0 8682/******/ }; 8683/******/ 8684/******/ __webpack_require__.f.miniCss = (chunkId, promises) => { 8685/******/ var cssChunks = {"vendors-node_modules_swiper_modules_a11y_css-node_modules_swiper_modules_pagination_css-node_-f6284a":1}; 8686/******/ if(installedCssChunks[chunkId]) promises.push(installedCssChunks[chunkId]); 8687/******/ else if(installedCssChunks[chunkId] !== 0 && cssChunks[chunkId]) { 8688/******/ promises.push(installedCssChunks[chunkId] = loadStylesheet(chunkId).then(() => { 8689/******/ installedCssChunks[chunkId] = 0; 8690/******/ }, (e) => { 8691/******/ delete installedCssChunks[chunkId]; 8692/******/ throw e; 8693/******/ })); 8694/******/ } 8695/******/ }; 8696/******/ 8697/******/ // no hmr 8698/******/ 8699/******/ // no prefetching 8700/******/ 8701/******/ // no preloaded 8702/******/ })(); 8703/******/ 8704/******/ /* webpack/runtime/jsonp chunk loading */ 8705/******/ (() => { 8706/******/ // no baseURI 8707/******/ 8708/******/ // object to store loaded and loading chunks 8709/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched 8710/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
8711/******/ const installedChunks = { 8712/******/ "main": 0 8713/******/ }; 8714/******/ 8715/******/ __webpack_require__.f.j = (chunkId, promises) => { 8716/******/ // JSONP chunk loading for javascript 8717/******/ let installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined; 8718/******/ if(installedChunkData !== 0) { // 0 means "already installed". 8719/******/ 8720/******/ // a Promise means "currently loading". 8721/******/ if(installedChunkData) { 8722/******/ promises.push(installedChunkData[2]); 8723/******/ } else { 8724/******/ if(true) { // all chunks have JS 8725/******/ // setup Promise in chunk cache 8726/******/ const promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject])); 8727/******/ promises.push(installedChunkData[2] = promise); 8728/******/ 8729/******/ // start chunk loading 8730/******/ const url = __webpack_require__.p + __webpack_require__.u(chunkId); 8731/******/ // create error before stack unwound to get useful stacktrace later 8732/******/ const error = new Error(); 8733/******/ const loadingEnded = (event) => { 8734/******/ if(__webpack_require__.o(installedChunks, chunkId)) { 8735/******/ installedChunkData = installedChunks[chunkId]; 8736/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined; 8737/******/ if(installedChunkData) { 8738/******/ const errorType = event && (event.type === 'load' ? 'missing' : event.type); 8739/******/ const realSrc = event && event.target && event.target.src; 8740/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'; 8741/******/ error.name = 'ChunkLoadError'; 8742/******/ error.type = errorType; 8743/******/ error.request = realSrc; 8744/******/ error.event = event; 8745/******/ installedChunkData[1](error); 8746/******/ } 8747/******/ } 8748/******/ }; 8749/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId); 8750/******/ } 8751/******/ } 8752/******/ } 8753/******/ }; 8754/******/ 8755/******/ // no prefetching 8756/******/ 8757/******/ // no preloaded 8758/******/ 8759/******/ // no HMR 8760/******/ 8761/******/ // no HMR manifest 8762/******/ 8763/******/ // no on chunks loaded 8764/******/ 8765/******/ // install a JSONP callback for chunk loading 8766/******/ const webpackJsonpCallback = (parentChunkLoadingFunction, data) => { 8767/******/ let [chunkIds, moreModules, runtime] = data; 8768/******/ // add "moreModules" to the modules object, 8769/******/ // then flag all "chunkIds" as loaded and fire callback 8770/******/ var moduleId, chunkId, i = 0; 8771/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) { 8772/******/ for(moduleId in moreModules) { 8773/******/ if(__webpack_require__.o(moreModules, moduleId)) { 8774/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; 8775/******/ } 8776/******/ } 8777/******/ if(runtime) var result = runtime(__webpack_require__); 8778/******/ } 8779/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); 8780/******/ for(;i < chunkIds.length; i++) { 8781/******/ chunkId = chunkIds[i]; 8782/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { 8783/******/ installedChunks[chunkId][0](); 8784/******/ } 8785/******/ installedChunks[chunkId] = 0; 8786/******/ } 8787/******/ 8788/******/ } 8789/******/ 8790/******/ const chunkLoadingGlobal = self["webpackChunksuchard_navidad_2026"] = self["webpackChunksuchard_navidad_2026"] || []; 8791/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); 8792/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); 8793/******/ })(); 8794/******/ 8795/************************************************************************/ 8796let __webpack_exports__ = {}; 8797// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk. 8798(() => { 8799/*!**********************!*\ 8800 !*** ./src/index.js ***! 8801 \**********************/ 8802__webpack_require__.r(__webpack_exports__); 8803/* harmony import */ var _style_main_scss__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./style/main.scss */ "./src/style/main.scss"); 8804/* harmony import */ var _assets_fonts_Geist_LICENSE_txt__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assets/fonts/Geist-LICENSE.txt */ "./src/assets/fonts/Geist-LICENSE.txt"); 8805/* harmony import */ var _assets_figma_hero_desktop_avif__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./assets/figma/hero-desktop.avif */ "./src/assets/figma/hero-desktop.avif"); 8806/* harmony import */ var _assets_figma_hero_desktop_webp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assets/figma/hero-desktop.webp */ "./src/assets/figma/hero-desktop.webp"); 8807/* harmony import */ var _assets_figma_hero_mobile_lcp_avif__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./assets/figma/hero-mobile-lcp.avif */ "./src/assets/figma/hero-mobile-lcp.avif"); 8808/* harmony import */ var _assets_figma_hero_mobile_lcp_webp__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./assets/figma/hero-mobile-lcp.webp */ "./src/assets/figma/hero-mobile-lcp.webp"); 8809/* harmony import */ var _landing__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./landing */ "./src/landing.js"); 8810/* harmony import */ var _winners__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./winners */ "./src/winners.js"); 8811/* harmony import */ var _app_campaign__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./app/campaign */ "./src/app/campaign.js"); 8812/* harmony import */ var _campaign_config__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./campaign-config */ "./src/campaign-config.js"); 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824const runtimeConfig = (0,_app_campaign__WEBPACK_IMPORTED_MODULE_8__.createCampaignRuntimeConfig)(_campaign_config__WEBPACK_IMPORTED_MODULE_9__.campaignConfig); 8825 8826function activateDeferredStyles() { 8827 document.querySelectorAll("link[data-deferred-style]").forEach((stylesheet) => { 8828 stylesheet.media = "all"; 8829 stylesheet.removeAttribute("data-deferred-style"); 8830 }); 8831} 8832 8833// La hoja ya se ha solicitado mediante preload. Activarla antes de montar los 8834// módulos evita un layout intermedio incompleto sin volver a bloquear el HTML. 8835activateDeferredStyles(); 8836 8837(0,_landing__WEBPACK_IMPORTED_MODULE_6__.initLanding)(runtimeConfig); 8838(0,_winners__WEBPACK_IMPORTED_MODULE_7__.initWinners)(runtimeConfig); 8839 8840})(); 8841 8842/******/ })() 8843; 8844//# sourceMappingURL=main.js.map
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.