1(function (global, factory) { 2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : 3 typeof define === 'function' && define.amd ? define(['exports'], factory) : 4 (global = global || self, factory(global.window = global.window || {})); 5}(this, (function (exports) { 'use strict'; 6 7 /*! 8 * ScrollTrigger 3.5.0 9 * https://greensock.com 10 * 11 * @license Copyright 2008-2020, GreenSock. All rights reserved. 12 * Subject to the terms at https://greensock.com/standard-license or for 13 * Club GreenSock members, the agreement issued with that membership. 14 * @author: Jack Doyle, [email protected] 15 */ 16 var gsap, 17 _coreInitted, 18 _win, 19 _doc, 20 _docEl, 21 _body, 22 _root, 23 _resizeDelay, 24 _raf, 25 _request, 26 _toArray, 27 _clamp, 28 _time2, 29 _syncInterval, 30 _refreshing, 31 _pointerIsDown, 32 _transformProp, 33 _i, 34 _prevWidth, 35 _prevHeight, 36 _autoRefresh, 37 _sort, 38 _limitCallbacks, 39 _startup = 1, 40 _proxies = [], 41 _scrollers = [], 42 _getTime = Date.now, 43 _time1 = _getTime(), 44 _lastScrollTime = 0, 45 _enabled = 1, 46 _passThrough = function _passThrough(v) { 47 return v; 48 }, 49 _windowExists = function _windowExists() { 50 return typeof window !== "undefined"; 51 }, 52 _getGSAP = function _getGSAP() { 53 return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap; 54 }, 55 _isViewport = function _isViewport(e) { 56 return !!~_root.indexOf(e); 57 }, 58 _getProxyProp = function _getProxyProp(element, property) { 59 return ~_proxies.indexOf(element) && _proxies[_proxies.indexOf(element) + 1][property]; 60 }, 61 _getScrollFunc = function _getScrollFunc(element, _ref) { 62 var s = _ref.s, 63 sc = _ref.sc; 64 65 var i = _scrollers.indexOf(element), 66 offset = sc === _vertical.sc ? 1 : 2; 67 68 !~i && (i = _scrollers.push(element) - 1); 69 return _scrollers[i + offset] || (_scrollers[i + offset] = _getProxyProp(element, s) || (_isViewport(element) ? sc : function (value) { 70 return arguments.length ? element[s] = value : element[s]; 71 })); 72 }, 73 _getBoundsFunc = function _getBoundsFunc(element) { 74 return _getProxyProp(element, "getBoundingClientRect") || (_isViewport(element) ? function () { 75 _winOffsets.width = _win.innerWidth; 76 _winOffsets.height = _win.innerHeight; 77 return _winOffsets; 78 } : function () { 79 return _getBounds(element); 80 }); 81 }, 82 _getSizeFunc = function _getSizeFunc(scroller, isViewport, _ref2) { 83 var d = _ref2.d, 84 d2 = _ref2.d2, 85 a = _ref2.a; 86 return (a = _getProxyProp(scroller, "getBoundingClientRect")) ? function () { 87 return a()[d]; 88 } : function () { 89 return (isViewport ? _win["inner" + d2] : scroller["client" + d2]) || 0; 90 }; 91 }, 92 _getOffsetsFunc = function _getOffsetsFunc(element, isViewport) { 93 return !isViewport || ~_proxies.indexOf(element) ? _getBoundsFunc(element) : function () { 94 return _winOffsets; 95 }; 96 }, 97 _maxScroll = function _maxScroll(element, _ref3) { 98 var s = _ref3.s, 99 d2 = _ref3.d2, 100 d = _ref3.d, 101 a = _ref3.a; 102 return (s = "scroll" + d2) && (a = _getProxyProp(element, s)) ? a() - _getBoundsFunc(element)()[d] : _isViewport(element) ? Math.max(_docEl[s], _body[s]) - (_win["inner" + d2] || _docEl["client" + d2] || _body["client" + d2]) : element[s] - element["offset" + d2]; 103 }, 104 _iterateAutoRefresh = function _iterateAutoRefresh(func, events) { 105 for (var i = 0; i < _autoRefresh.length; i += 3) { 106 (!events || ~events.indexOf(_autoRefresh[i + 1])) && func(_autoRefresh[i], _autoRefresh[i + 1], _autoRefresh[i + 2]); 107 } 108 }, 109 _isString = function _isString(value) { 110 return typeof value === "string"; 111 }, 112 _isFunction = function _isFunction(value) { 113 return typeof value === "function"; 114 }, 115 _isNumber = function _isNumber(value) { 116 return typeof value === "number"; 117 }, 118 _isObject = function _isObject(value) { 119 return typeof value === "object"; 120 }, 121 _callIfFunc = function _callIfFunc(value) {
122 return _isFunction(value) && value(); 123 }, 124 _combineFunc = function _combineFunc(f1, f2) { 125 return function () { 126 var result1 = _callIfFunc(f1), 127 result2 = _callIfFunc(f2); 128 129 return function () { 130 _callIfFunc(result1); 131 132 _callIfFunc(result2); 133 }; 134 }; 135 }, 136 _abs = Math.abs, 137 _scrollLeft = "scrollLeft", 138 _scrollTop = "scrollTop", 139 _left = "left", 140 _top = "top", 141 _right = "right", 142 _bottom = "bottom", 143 _width = "width", 144 _height = "height", 145 _Right = "Right", 146 _Left = "Left", 147 _Top = "Top", 148 _Bottom = "Bottom", 149 _padding = "padding", 150 _margin = "margin", 151 _Width = "Width", 152 _Height = "Height", 153 _px = "px", 154 _horizontal = { 155 s: _scrollLeft, 156 p: _left, 157 p2: _Left, 158 os: _right, 159 os2: _Right, 160 d: _width, 161 d2: _Width, 162 a: "x", 163 sc: function sc(value) { 164 return arguments.length ? _win.scrollTo(value, _vertical.sc()) : _win.pageXOffset || _doc[_scrollLeft] || _docEl[_scrollLeft] || _body[_scrollLeft] || 0; 165 } 166 }, 167 _vertical = { 168 s: _scrollTop, 169 p: _top, 170 p2: _Top, 171 os: _bottom, 172 os2: _Bottom, 173 d: _height, 174 d2: _Height, 175 a: "y", 176 op: _horizontal, 177 sc: function sc(value) { 178 return arguments.length ? _win.scrollTo(_horizontal.sc(), value) : _win.pageYOffset || _doc[_scrollTop] || _docEl[_scrollTop] || _body[_scrollTop] || 0; 179 } 180 }, 181 _getComputedStyle = function _getComputedStyle(element) { 182 return _win.getComputedStyle(element); 183 }, 184 _makePositionable = function _makePositionable(element) { 185 return element.style.position = _getComputedStyle(element).position === "absolute" ? "absolute" : "relative"; 186 }, 187 _setDefaults = function _setDefaults(obj, defaults) { 188 for (var p in defaults) { 189 p in obj || (obj[p] = defaults[p]); 190 } 191 192 return obj; 193 }, 194 _getBounds = function _getBounds(element, withoutTransforms) { 195 var tween = withoutTransforms && _getComputedStyle(element)[_transformProp] !== "matrix(1, 0, 0, 1, 0, 0)" && gsap.to(element, { 196 x: 0, 197 y: 0, 198 xPercent: 0, 199 yPercent: 0, 200 rotation: 0, 201 rotationX: 0, 202 rotationY: 0, 203 scale: 1, 204 skewX: 0, 205 skewY: 0 206 }).progress(1), 207 bounds = element.getBoundingClientRect(); 208 tween && tween.progress(0).kill(); 209 return bounds; 210 }, 211 _getSize = function _getSize(element, _ref4) { 212 var d2 = _ref4.d2; 213 return element["offset" + d2] || element["client" + d2] || 0; 214 }, 215 _getLabels = function _getLabels(animation) { 216 return function (value) { 217 var a = [], 218 labels = animation.labels, 219 duration = animation.duration(), 220 p; 221 222 for (p in labels) { 223 a.push(labels[p] / duration); 224 } 225 226 return gsap.utils.snap(a, value); 227 }; 228 }, 229 _multiListener = function _multiListener(func, element, types, callback) { 230 return types.split(",").forEach(function (type) { 231 return func(element, type, callback); 232 }); 233 }, 234 _addListener = function _addListener(element, type, func) { 235 return element.addEventListener(type, func, { 236 passive: true 237 }); 238 }, 239 _removeListener = function _removeListener(element, type, func) { 240 return element.removeEventListener(type, func); 241 }, 242 _markerDefaults = { 243 startColor: "green", 244 endColor: "red", 245 indent: 0, 246 fontSize: "16px", 247 fontWeight: "normal" 248 }, 249 _defaults = { 250 toggleActions: "play", 251 anticipatePin: 0 252 }, 253 _keywords = { 254 top: 0, 255 left: 0, 256 center: 0.5, 257 bottom: 1, 258 right: 1 259 }, 260 _offsetToPx = function _offsetToPx(value, size) { 261 if (_isString(value)) { 262 var eqIndex = value.indexOf("="), 263 relative = ~eqIndex ? +(value.charAt(eqIndex - 1) + 1) * parseFloat(value.substr(eqIndex + 1)) : 0; 264 265 if (relative) { 266 value.indexOf("%") > eqIndex && (relative *= size / 100); 267 value = value.substr(0, eqIndex - 1); 268 } 269 270 value = relative + (value in _keywords ? _keywords[value] * size : ~value.indexOf("%") ? parseFloat(value) * size / 100 : parseFloat(value) || 0); 271 } 272 273 return value; 274 }, 275 _createMarker = function _createMarker(type, name, container, direction, _ref5, offset, matchWidthEl) { 276 var startColor = _ref5.startColor, 277 endColor = _ref5.endColor, 278 fontSize = _ref5.fontSize, 279 indent = _ref5.indent, 280 fontWeight = _ref5.fontWeight; 281 282 var e = _doc.createElement("div"), 283 useFixedPosition = _isViewport(container) || _getProxyProp(container, "pinType") === "fixed", 284 isScroller = type.indexOf("scroller") !== -1, 285 parent = useFixedPosition ? _body : container, 286 isStart = type.indexOf("start") !== -1, 287 color = isStart ? startColor : endColor, 288 css = "border-color:" + color + ";font-size:" + fontSize + ";color:" + color + ";font-weight:" + fontWeight + ";pointer-events:none;white-space:nowrap;font-family:sans-serif,Arial;z-index:1000;padding:4px 8px;border-width:0;border-style:solid;"; 289 290 css += "position:" + (isScroller && useFixedPosition ? "fixed;" : "absolute;"); 291 (isScroller || !useFixedPosition) && (css += (direction === _vertical ? _right : _bottom) + ":" + (offset + parseFloat(indent)) + "px;"); 292 matchWidthEl && (css += "box-sizing:border-box;text-align:left;
292width:" + matchWidthEl.offsetWidth + "px;"); 293 e._isStart = isStart; 294 e.setAttribute("class", "gsap-marker-" + type); 295 e.style.cssText = css; 296 e.innerText = name || name === 0 ? type + "-" + name : type; 297 parent.insertBefore(e, parent.children[0]); 298 e._offset = e["offset" + direction.op.d2]; 299 300 _positionMarker(e, 0, direction, isStart); 301 302 return e; 303 }, 304 _positionMarker = function _positionMarker(marker, start, direction, flipped) { 305 var vars = { 306 display: "block" 307 }, 308 side = direction[flipped ? "os2" : "p2"], 309 oppositeSide = direction[flipped ? "p2" : "os2"]; 310 marker._isFlipped = flipped; 311 vars[direction.a + "Percent"] = flipped ? -100 : 0; 312 vars[direction.a] = flipped ? 1 : 0; 313 vars["border" + side + _Width] = 1; 314 vars["border" + oppositeSide + _Width] = 0; 315 vars[direction.p] = start; 316 gsap.set(marker, vars); 317 }, 318 _triggers = [], 319 _ids = {}, 320 _sync = function _sync() { 321 return _request || (_request = _raf(_updateAll)); 322 }, 323 _onScroll = function _onScroll() { 324 if (!_request) { 325 _request = _raf(_updateAll); 326 _lastScrollTime || _dispatch("scrollStart"); 327 _lastScrollTime = _getTime(); 328 } 329 }, 330 _onResize = function _onResize() { 331 return !_refreshing && _resizeDelay.restart(true); 332 }, 333 _listeners = {}, 334 _emptyArray = [], 335 _media = [], 336 _creatingMedia, 337 _lastMediaTick, 338 _onMediaChange = function _onMediaChange(e) { 339 var tick = gsap.ticker.frame, 340 matches = [], 341 i = 0; 342 343 if (_lastMediaTick !== tick || _startup) { 344 _revertAll(); 345 346 for (; i < _media.length; i += 3) { 347 _win.matchMedia(_media[i]).matches ? matches.push(i) : _revertAll(1, _media[i]) || _isFunction(_media[i + 2]) && _media[i + 2](); 348 } 349 350 _revertRecorded(); 351 352 for (i = 0; i < matches.length; i++) { 353 _creatingMedia = _media[matches[i]]; 354 _media[matches[i] + 2] = _media[matches[i] + 1](e); 355 } 356 357 _creatingMedia = 0; 358 359 _refreshAll(0, 1); 360 361 _lastMediaTick = tick; 362 363 _dispatch("matchMedia"); 364 } 365 }, 366 _softRefresh = function _softRefresh() { 367 return _removeListener(ScrollTrigger, "scrollEnd", _softRefresh) || _refreshAll(true); 368 }, 369 _dispatch = function _dispatch(type) { 370 return _listeners[type] && _listeners[type].map(function (f) { 371 return f(); 372 }) || _emptyArray; 373 }, 374 _savedStyles = [], 375 _revertRecorded = function _revertRecorded(media) { 376 for (var i = 0; i < _savedStyles.length; i += 4) { 377 if (!media || _savedStyles[i + 3] === media) { 378 _savedStyles[i].style.cssText = _savedStyles[i + 1]; 379 _savedStyles[i + 2].uncache = 1; 380 } 381 } 382 }, 383 _revertAll = function _revertAll(kill, media) { 384 var trigger; 385 386 for (_i = 0; _i < _triggers.length; _i++) { 387 trigger = _triggers[_i]; 388 389 if (!media || trigger.media === media) { 390 if (kill) { 391 trigger.kill(1); 392 } else { 393 trigger.scroll.rec || (trigger.scroll.rec = trigger.scroll()); 394 trigger.revert(); 395 } 396 } 397 } 398 399 _revertRecorded(media); 400 401 media || _dispatch("revert"); 402 }, 403 _refreshAll = function _refreshAll(force, skipRevert) { 404 if (_lastScrollTime && !force) { 405 _addListener(ScrollTrigger, "scrollEnd", _softRefresh); 406 407 return; 408 } 409 410 var refreshInits = _dispatch("refreshInit"); 411 412 _sort && ScrollTrigger.sort(); 413 skipRevert || _revertAll(); 414 415 for (_i = 0; _i < _triggers.length; _i++) { 416 _triggers[_i].refresh(); 417 } 418 419 refreshInits.forEach(function (result) { 420 return result && result.render && result.render(-1); 421 }); 422 _i = _triggers.length; 423 424 while (_i--) { 425 _triggers[_i].scroll.rec = 0; 426 } 427 428 _dispatch("refresh"); 429 }, 430 _lastScroll = 0, 431 _direction = 1, 432 _updateAll = function _updateAll() { 433 var l = _triggers.length, 434 time = _getTime(), 435 recordVelocity = time - _time1 >= 50, 436 scroll = l && _triggers[0].scroll(); 437 438 _direction = _lastScroll > scroll ? -1 : 1; 439 _lastScroll = scroll; 440 441 if (recordVelocity) { 442 if (_lastScrollTime && !_pointerIsDown && time - _lastScrollTime > 200) { 443 _lastScrollTime = 0; 444 445 _dispatch("scrollEnd"); 446 } 447 448 _time2 = _time1; 449 _time1 = time; 450 } 451 452 if (_direction < 0) { 453 _i = l; 454 455 while (_i--) { 456 _triggers[_i] && _triggers[_i].update(0, recordVelocity); 457 } 458 459 _direction = 1; 460 } else { 461 for (_i = 0; _i < l; _i++) { 462 _triggers[_i] && _triggers[_i].update(0, recordVelocity); 463 } 464 } 465 466 _request = 0; 467 }, 468 _propNamesToCopy = [_left, _top, _bottom, _right, _margin + _Bottom, _margin + _Right, _margin + _Top, _margin + _Left, "display", "flexShrink", "float"], 469 _stateProps = _propNamesToCopy.concat([_width, _height, "boxSizing", "max" + _Width, "max" + _Height, "position", _margin, _padding, _padding + _Top, _padding + _Right, _padding + _Bottom, _padding + _Left]), 470 _swapPinOut = function _swapPinOut(pin, spacer, state) { 471 _setState(state); 472 473 if (pin.parentNode === spacer) { 474 var parent = spacer.parentNode; 475 476 if (parent) { 477 parent.insertBefore(pin, spacer); 478 parent.removeChild(spacer); 479 } 480 } 481 }, 482 _swapPinIn = function _swapPinIn(pin, spacer, cs, spacerState) { 483 if (pin.parentNode !== spacer) { 484 var i = _propNamesToCopy.length, 485 spacerStyle = spacer.style, 486 pinStyle = pin.style, 487 p; 488 489 while (i--) { 490 p = _propNamesToCopy[i]; 491 spacerStyle[p] = cs[p]; 492 } 493 494 spacerStyle.position = cs.position === "absolute" ? "absolute" : "relative"; 495 cs.display === "inline" && (spacerStyle.display = "inline-block"); 496 pinStyle[_bottom] = pinStyle[_right] = "auto"; 497 spacerStyle.overflow = "visible"; 498 spacerStyle.boxSizing = "border-box"; 499 spacerStyle[_width] = _getSize(pin, _horizontal) + _px; 500 spacerStyle[_height] = _getSize(pin, _vertical) + _px; 501 spacerStyle[_padding] = pinStyle[_margin] = pinStyle[_top] = pinStyle[_left] = "0"; 502 503 _setState(spacerState); 504 505 pinStyle[_width] = cs[_width]; 506 pinStyle[_height] = cs[_height]; 507 pinStyle[_padding] = cs[_padding]; 508 pin.parentNode.insertBefore(spacer, pin); 509 spacer.appendChild(pin); 510 } 511 }, 512 _capsExp = /([A-Z])/g, 513 _setState = function _setState(state) { 514 if (state) { 515 var style = state.t.style, 516 l = state.length, 517 i = 0, 518 p, 519 value; 520 521 for (; i < l; i += 2) { 522 value = state[i + 1];
523 p = state[i]; 524 525 if (value) { 526 style[p] = value; 527 } else if (style[p]) { 528 style.removeProperty(p.replace(_capsExp, "-$1").toLowerCase()); 529 } 530 } 531 } 532 }, 533 _getState = function _getState(element) { 534 var l = _stateProps.length, 535 style = element.style, 536 state = [], 537 i = 0; 538 539 for (; i < l; i++) { 540 state.push(_stateProps[i], style[_stateProps[i]]); 541 } 542 543 state.t = element; 544 return state; 545 }, 546 _copyState = function _copyState(state, override, omitOffsets) { 547 var result = [], 548 l = state.length, 549 i = omitOffsets ? 8 : 0, 550 p; 551 552 for (; i < l; i += 2) { 553 p = state[i]; 554 result.push(p, p in override ? override[p] : state[i + 1]); 555 } 556 557 result.t = state.t; 558 return result; 559 }, 560 _winOffsets = { 561 left: 0, 562 top: 0 563 }, 564 _parsePosition = function _parsePosition(value, trigger, scrollerSize, direction, scroll, marker, markerScroller, self, scrollerBounds, borderWidth, useFixedPosition, scrollerMax) { 565 _isFunction(value) && (value = value(self)); 566 567 if (_isString(value) && value.substr(0, 3) === "max") { 568 value = scrollerMax + (value.charAt(4) === "=" ? _offsetToPx("0" + value.substr(3), scrollerSize) : 0); 569 } 570 571 if (!_isNumber(value)) { 572 _isFunction(trigger) && (trigger = trigger(self)); 573 574 var element = _toArray(trigger)[0] || _body, 575 bounds = _getBounds(element) || {}, 576 offsets = value.split(" "), 577 localOffset, 578 globalOffset, 579 display; 580 581 if ((!bounds || !bounds.left && !bounds.top) && _getComputedStyle(element).display === "none") { 582 display = element.style.display; 583 element.style.display = "block"; 584 bounds = _getBounds(element); 585 display ? element.style.display = display : element.style.removeProperty("display"); 586 } 587 588 localOffset = _offsetToPx(offsets[0], bounds[direction.d]); 589 globalOffset = _offsetToPx(offsets[1] || "0", scrollerSize); 590 value = bounds[direction.p] - scrollerBounds[direction.p] - borderWidth + localOffset + scroll - globalOffset; 591 markerScroller && _positionMarker(markerScroller, globalOffset, direction, scrollerSize - globalOffset < 20 || markerScroller._isStart && globalOffset > 20); 592 scrollerSize -= scrollerSize - globalOffset; 593 } else if (markerScroller) { 594 _positionMarker(markerScroller, scrollerSize, direction, true); 595 } 596 597 if (marker) { 598 var position = value + scrollerSize, 599 isStart = marker._isStart; 600 scrollerMax = "scroll" + direction.d2; 601 602 _positionMarker(marker, position, direction, isStart && position > 20 || !isStart && (useFixedPosition ? Math.max(_body[scrollerMax], _docEl[scrollerMax]) : marker.parentNode[scrollerMax]) <= position + 1); 603 604 if (useFixedPosition) { 605 scrollerBounds = _getBounds(markerScroller); 606 useFixedPosition && (marker.style[direction.op.p] = scrollerBounds[direction.op.p] - direction.op.m - marker._offset + _px); 607 } 608 } 609 610 return Math.round(value); 611 }, 612 _prefixExp = /(?:webkit|moz|length|cssText)/i, 613 _reparent = function _reparent(element, parent) { 614 if (element.parentNode !== parent) { 615 var style = element.style, 616 p, 617 cs; 618 619 if (parent === _body) { 620 element._stOrig = style.cssText; 621 cs = _getComputedStyle(element); 622 623 for (p in cs) { 624 if (!+p && !_prefixExp.test(p) && cs[p] && typeof style[p] === "string" && p !== "0") { 625 style[p] = cs[p]; 626 } 627 } 628 } else { 629 style.cssText = element._stOrig; 630 } 631 632 parent.appendChild(element); 633 } 634 }, 635 _getTweenCreator = function _getTweenCreator(scroller, direction) { 636 var getScroll = _getScrollFunc(scroller, direction), 637 prop = "_scroll" + direction.p2, 638 lastScroll1, 639 lastScroll2, 640 getTween = function getTween(scrollTo, vars, initialValue, change1, change2) { 641 var tween = getTween.tween, 642 onComplete = vars.onComplete, 643 modifiers = {}; 644 tween && tween.kill(); 645 lastScroll1 = initialValue; 646 vars[prop] = scrollTo; 647 vars.modifiers = modifiers; 648 649 modifiers[prop] = function (value) { 650 value = getScroll(); 651 652 if (value !== lastScroll1 && value !== lastScroll2) { 653 tween.kill(); 654 getTween.tween = 0; 655 } else { 656 value = initialValue + change1 * tween.ratio + change2 * tween.ratio * tween.ratio; 657 } 658 659 lastScroll2 = lastScroll1; 660 return lastScroll1 = Math.round(value); 661 }; 662 663 vars.onComplete = function () { 664 getTween.tween = 0; 665 onComplete && onComplete.call(tween); 666 }; 667 668 tween = getTween.tween = gsap.to(scroller, vars); 669 return tween; 670 }; 671 672 scroller[prop] = getScroll; 673 return getTween; 674 }; 675 676 _horizontal.op = _vertical; 677 var ScrollTrigger = function () { 678 function ScrollTrigger(vars, animation) { 679 _coreInitted || ScrollTrigger.register(gsap) || console.warn("Please gsap.registerPlugin(ScrollTrigger)"); 680 this.init(vars, animation); 681 } 682 683 var _proto = ScrollTrigger.prototype; 684 685 _proto.init = function init(vars, animation) { 686 this.progress = 0; 687 this.vars && this.kill(1); 688 689 if (!_enabled) { 690 this.update = this.refresh = this.kill = _passThrough; 691 return; 692 } 693 694 vars = _setDefaults(_isString(vars) || _isNumber(vars) || vars.nodeType ? { 695 trigger: vars 696 } : vars, _defaults); 697 698 var direction = vars.horizontal ? _horizontal : _vertical, 699 _vars = vars,
700 onUpdate = _vars.onUpdate, 701 toggleClass = _vars.toggleClass, 702 id = _vars.id, 703 onToggle = _vars.onToggle, 704 onRefresh = _vars.onRefresh, 705 scrub = _vars.scrub, 706 trigger = _vars.trigger, 707 pin = _vars.pin, 708 pinSpacing = _vars.pinSpacing, 709 invalidateOnRefresh = _vars.invalidateOnRefresh, 710 anticipatePin = _vars.anticipatePin, 711 onScrubComplete = _vars.onScrubComplete, 712 onSnapComplete = _vars.onSnapComplete, 713 once = _vars.once, 714 snap = _vars.snap, 715 pinReparent = _vars.pinReparent, 716 isToggle = !scrub && scrub !== 0, 717 scroller = _toArray(vars.scroller || _win)[0], 718 scrollerCache = gsap.core.getCache(scroller), 719 isViewport = _isViewport(scroller), 720 useFixedPosition = "pinType" in vars ? vars.pinType === "fixed" : isViewport || _getProxyProp(scroller, "pinType") === "fixed", 721 callbacks = [vars.onEnter, vars.onLeave, vars.onEnterBack, vars.onLeaveBack], 722 toggleActions = isToggle && vars.toggleActions.split(" "), 723 markers = "markers" in vars ? vars.markers : _defaults.markers, 724 borderWidth = isViewport ? 0 : parseFloat(_getComputedStyle(scroller)["border" + direction.p2 + _Width]) || 0, 725 self = this, 726 onRefreshInit = vars.onRefreshInit && function () { 727 return vars.onRefreshInit(self); 728 }, 729 getScrollerSize = _getSizeFunc(scroller, isViewport, direction), 730 getScrollerOffsets = _getOffsetsFunc(scroller, isViewport), 731 tweenTo, 732 pinCache, 733 snapFunc, 734 isReverted, 735 scroll1, 736 scroll2, 737 start, 738 end, 739 markerStart, 740 markerEnd, 741 markerStartTrigger, 742 markerEndTrigger, 743 markerVars, 744 change, 745 pinOriginalState, 746 pinActiveState, 747 pinState, 748 spacer, 749 offset, 750 pinGetter, 751 pinSetter, 752 pinStart, 753 pinChange, 754 spacingStart, 755 spacerState, 756 markerStartSetter, 757 markerEndSetter, 758 cs, 759 snap1, 760 snap2, 761 scrubTween, 762 scrubSmooth, 763 snapDurClamp, 764 snapDelayedCall, 765 prevProgress, 766 prevScroll, 767 prevAnimProgress; 768 769 self.media = _creatingMedia; 770 anticipatePin *= 45; 771 772 _triggers.push(self); 773 774 self.scroller = scroller; 775 self.scroll = _getScrollFunc(scroller, direction); 776 scroll1 = self.scroll(); 777 self.vars = vars; 778 animation = animation || vars.animation; 779 "refreshPriority" in vars && (_sort = 1); 780 scrollerCache.tweenScroll = scrollerCache.tweenScroll || { 781 top: _getTweenCreator(scroller, _vertical), 782 left: _getTweenCreator(scroller, _horizontal) 783 }; 784 self.tweenTo = tweenTo = scrollerCache.tweenScroll[direction.p]; 785 786 if (animation) { 787 animation.vars.lazy = false; 788 animation._initted || animation.vars.immediateRender !== false && vars.immediateRender !== false && animation.render(0, true, true); 789 self.animation = animation.pause(); 790 animation.scrollTrigger = self; 791 scrubSmooth = _isNumber(scrub) && scrub; 792 scrubSmooth && (scrubTween = gsap.to(animation, { 793 ease: "power3", 794 duration: scrubSmooth, 795 onComplete: function onComplete() { 796 return onScrubComplete && onScrubComplete(self); 797 } 798 })); 799 snap1 = 0; 800 id || (id = animation.vars.id); 801 } 802 803 if (snap) { 804 _isObject(snap) || (snap = { 805 snapTo: snap 806 }); 807 gsap.set(isViewport ? [_body, _docEl] : scroller, { 808 scrollBehavior: "auto" 809 }); 810 snapFunc = _isFunction(snap.snapTo) ? snap.snapTo : snap.snapTo === "labels" ? _getLabels(animation) : gsap.utils.snap(snap.snapTo); 811 snapDurClamp = snap.duration || { 812 min: 0.1, 813 max: 2 814 }; 815 snapDurClamp = _isObject(snapDurClamp) ? _clamp(snapDurClamp.min, snapDurClamp.max) : _clamp(snapDurClamp, snapDurClamp); 816 snapDelayedCall = gsap.delayedCall(snap.delay || scrubSmooth / 2 || 0.1, function () { 817 if (Math.abs(self.getVelocity()) < 10 && !_pointerIsDown) { 818 var totalProgress = animation && !isToggle ? animation.totalProgress() : self.progress, 819 velocity = (totalProgress - snap2) / (_getTime() - _time2) * 1000 || 0, 820 change1 = _abs(velocity / 2) * velocity / 0.185, 821 naturalEnd = totalProgress + change1, 822 endValue = _clamp(0, 1, snapFunc(naturalEnd, self)), 823 scroll = self.scroll(), 824 endScroll = Math.round(start + endValue * change), 825 tween = tweenTo.tween; 826 827 if (scroll <= end && scroll >= start && endScroll !== scroll) { 828 if (tween && !tween._initted && tween.data <= Math.abs(endScroll - scroll)) { 829 return; 830 } 831 832 tweenTo(endScroll, { 833 duration: snapDurClamp(_abs(Math.max(_abs(naturalEnd - totalProgress), _abs(endValue - totalProgress)) * 0.185 / velocity / 0.05 || 0)), 834 ease: snap.ease || "power3", 835 data: Math.abs(endScroll - scroll), 836 onComplete: function onComplete() { 837 snap1 = snap2 = animation && !isToggle ? animation.totalProgress() : self.progress; 838 onSnapComplete && onSnapComplete(self); 839 } 840 }, scroll, change1 * change, endScroll - scroll - change1 * change); 841 } 842 } else if (self.isActive) { 843 snapDelayedCall.restart(true); 844 } 845 }).pause(); 846 } 847 848 id && (_ids[id] = self); 849 trigger = self.trigger = _toArray(trigger || pin)[0]; 850 pin = pin === true ? trigger : _toArray(pin)[0]; 851 _isString(toggleClass) && (toggleClass = { 852 targets: trigger, 853 className: toggleClass 854 }); 855 856 if (pin) { 857 pinSpacing === false || pinSpacing === _margin || (pinSpacing = !pinSpacing && _getComputedStyle(pin.parentNode).display === "flex" ? false : _padding); 858 self.pin = pin; 859 vars.force3D !== false && gsap.set(pin, { 860 force3D: true 861 }); 862 pinCache = gsap.core.getCache(pin);
863 864 if (!pinCache.spacer) { 865 pinCache.spacer = spacer = _doc.createElement("div"); 866 spacer.setAttribute("class", "pin-spacer" + (id ? " pin-spacer-" + id : "")); 867 pinCache.pinState = pinOriginalState = _getState(pin); 868 } else { 869 pinOriginalState = pinCache.pinState; 870 } 871 872 self.spacer = spacer = pinCache.spacer; 873 cs = _getComputedStyle(pin); 874 spacingStart = cs[pinSpacing + direction.os2]; 875 pinGetter = gsap.getProperty(pin); 876 pinSetter = gsap.quickSetter(pin, direction.a, _px); 877 878 _swapPinIn(pin, spacer, cs); 879 880 pinState = _getState(pin); 881 } 882 883 if (markers) { 884 markerVars = _isObject(markers) ? _setDefaults(markers, _markerDefaults) : _markerDefaults; 885 markerStartTrigger = _createMarker("scroller-start", id, scroller, direction, markerVars, 0); 886 markerEndTrigger = _createMarker("scroller-end", id, scroller, direction, markerVars, 0, markerStartTrigger); 887 offset = markerStartTrigger["offset" + direction.op.d2]; 888 markerStart = _createMarker("start", id, scroller, direction, markerVars, offset); 889 markerEnd = _createMarker("end", id, scroller, direction, markerVars, offset); 890 891 if (!useFixedPosition) { 892 _makePositionable(scroller); 893 894 gsap.set([markerStartTrigger, markerEndTrigger], { 895 force3D: true 896 }); 897 markerStartSetter = gsap.quickSetter(markerStartTrigger, direction.a, _px); 898 markerEndSetter = gsap.quickSetter(markerEndTrigger, direction.a, _px); 899 } 900 } 901 902 self.revert = function (revert) { 903 var r = revert !== false || !self.enabled, 904 prevRefreshing = _refreshing; 905 906 if (r !== isReverted) { 907 if (r) { 908 prevScroll = Math.max(self.scroll(), self.scroll.rec || 0); 909 prevProgress = self.progress; 910 prevAnimProgress = animation && animation.progress(); 911 } 912 913 markerStart && [markerStart, markerEnd, markerStartTrigger, markerEndTrigger].forEach(function (m) { 914 return m.style.display = r ? "none" : "block"; 915 }); 916 r && (_refreshing = 1); 917 self.update(r); 918 _refreshing = prevRefreshing; 919 pin && (r ? _swapPinOut(pin, spacer, pinOriginalState) : (!pinReparent || !self.isActive) && _swapPinIn(pin, spacer, _getComputedStyle(pin), spacerState)); 920 isReverted = r; 921 } 922 }; 923 924 self.refresh = function (soft) { 925 if (_refreshing || !self.enabled) { 926 return; 927 } 928 929 if (pin && soft && _lastScrollTime) { 930 _addListener(ScrollTrigger, "scrollEnd", _softRefresh); 931 932 return; 933 } 934 935 _refreshing = 1; 936 scrubTween && scrubTween.kill(); 937 invalidateOnRefresh && animation && animation.progress(0).invalidate(); 938 isReverted || self.revert(); 939 940 var size = getScrollerSize(), 941 scrollerBounds = getScrollerOffsets(), 942 max = _maxScroll(scroller, direction), 943 offset = 0, 944 otherPinOffset = 0, 945 parsedEnd = vars.end, 946 parsedEndTrigger = vars.endTrigger || trigger, 947 parsedStart = vars.start || (pin || !trigger ? "0 0" : "0 100%"), 948 triggerIndex = trigger && Math.max(0, _triggers.indexOf(self)) || 0, 949 i = triggerIndex, 950 cs, 951 bounds, 952 scroll, 953 isVertical, 954 override, 955 curTrigger, 956 curPin, 957 oppositeScroll; 958 959 while (i--) { 960 curPin = _triggers[i].pin; 961 curPin && (curPin === trigger || curPin === pin) && _triggers[i].revert(); 962 } 963 964 start = _parsePosition(parsedStart, trigger, size, direction, self.scroll(), markerStart, markerStartTrigger, self, scrollerBounds, borderWidth, useFixedPosition, max) || (pin ? -0.001 : 0); 965 _isFunction(parsedEnd) && (parsedEnd = parsedEnd(self)); 966 967 if (_isString(parsedEnd) && !parsedEnd.indexOf("+=")) { 968 if (~parsedEnd.indexOf(" ")) { 969 parsedEnd = (_isString(parsedStart) ? parsedStart.split(" ")[0] : "") + parsedEnd;
970 } else { 971 offset = _offsetToPx(parsedEnd.substr(2), size); 972 parsedEnd = _isString(parsedStart) ? parsedStart : start + offset; 973 parsedEndTrigger = trigger; 974 } 975 } 976 977 end = Math.max(start, _parsePosition(parsedEnd || (parsedEndTrigger ? "100% 0" : max), parsedEndTrigger, size, direction, self.scroll() + offset, markerEnd, markerEndTrigger, self, scrollerBounds, borderWidth, useFixedPosition, max)) || -0.001; 978 change = end - start || (start -= 0.01) && 0.001; 979 offset = 0; 980 i = triggerIndex; 981 982 while (i--) { 983 curTrigger = _triggers[i]; 984 curPin = curTrigger.pin; 985 986 if (curPin && curTrigger.start - curTrigger._pinPush < start) { 987 cs = curTrigger.end - curTrigger.start; 988 curPin === trigger && (offset += cs); 989 curPin === pin && (otherPinOffset += cs); 990 } 991 } 992 993 start += offset; 994 end += offset; 995 self._pinPush = otherPinOffset; 996 997 if (markerStart && offset) { 998 cs = {}; 999 cs[direction.a] = "+=" + offset; 1000 gsap.set([markerStart, markerEnd], cs); 1001 } 1002 1003 if (pin) { 1004 cs = _getComputedStyle(pin); 1005 isVertical = direction === _vertical; 1006 scroll = self.scroll(); 1007 pinStart = parseFloat(pinGetter(direction.a)) + otherPinOffset; 1008 1009 _swapPinIn(pin, spacer, cs); 1010 1011 pinState = _getState(pin); 1012 bounds = _getBounds(pin, true); 1013 oppositeScroll = useFixedPosition && _getScrollFunc(scroller, isVertical ? _horizontal : _vertical)(); 1014 1015 if (pinSpacing) { 1016 spacerState = [pinSpacing + direction.os2, change + otherPinOffset + _px]; 1017 spacerState.t = spacer; 1018 i = pinSpacing === _padding ? _getSize(pin, direction) + change + otherPinOffset : 0; 1019 i && spacerState.push(direction.d, i + _px); 1020 1021 _setState(spacerState); 1022 1023 useFixedPosition && self.scroll(prevScroll); 1024 } 1025 1026 if (useFixedPosition) { 1027 override = { 1028 top: bounds.top + (isVertical ? scroll - start : oppositeScroll) + _px, 1029 left: bounds.left + (isVertical ? oppositeScroll : scroll - start) + _px, 1030 boxSizing: "border-box", 1031 position: "fixed" 1032 }; 1033 override[_width] = override["max" + _Width] = Math.ceil(bounds.width) + _px; 1034 override[_height] = override["max" + _Height] = Math.ceil(bounds.height) + _px; 1035 override[_margin] = override[_margin + _Top] = override[_margin + _Right] = override[_margin + _Bottom] = override[_margin + _Left] = "0"; 1036 override[_padding] = cs[_padding]; 1037 override[_padding + _Top] = cs[_padding + _Top]; 1038 override[_padding + _Right] = cs[_padding + _Right]; 1039 override[_padding + _Bottom] = cs[_padding + _Bottom]; 1040 override[_padding + _Left] = cs[_padding + _Left]; 1041 pinActiveState = _copyState(pinOriginalState, override, pinReparent); 1042 } 1043 1044 if (animation) { 1045 animation.progress(1, true); 1046 pinChange = pinGetter(direction.a) - pinStart + change + otherPinOffset; 1047 change !== pinChange && pinActiveState.splice(pinActiveState.length - 2, 2); 1048 animation.progress(0, true); 1049 } else { 1050 pinChange = change; 1051 } 1052 } else if (trigger && self.scroll()) { 1053 bounds = trigger.parentNode; 1054 1055 while (bounds && bounds !== _body) { 1056 if (bounds._pinOffset) { 1057 start -= bounds._pinOffset; 1058 end -= bounds._pinOffset; 1059 } 1060 1061 bounds = bounds.parentNode; 1062 } 1063 } 1064 1065 for (i = 0; i < triggerIndex; i++) { 1066 curTrigger = _triggers[i].pin; 1067 curTrigger && (curTrigger === trigger || curTrigger === pin) && _triggers[i].revert(false); 1068 } 1069 1070 self.start = start; 1071 self.end = end; 1072 scroll1 = scroll2 = self.scroll(); 1073 scroll1 < prevScroll && self.scroll(prevScroll); 1074 self.revert(false); 1075 _refreshing = 0; 1076 prevAnimProgress && isToggle && animation.progress(prevAnimProgress, true); 1077 1078 if (prevProgress !== self.progress) { 1079 scrubTween && animation.totalProgress(prevProgress, true); 1080 self.progress = prevProgress;
1081 self.update(); 1082 } 1083 1084 pin && pinSpacing && (spacer._pinOffset = Math.round(self.progress * pinChange)); 1085 onRefresh && onRefresh(self); 1086 }; 1087 1088 self.getVelocity = function () { 1089 return (self.scroll() - scroll2) / (_getTime() - _time2) * 1000 || 0; 1090 }; 1091 1092 self.update = function (reset, recordVelocity) { 1093 var scroll = self.scroll(), 1094 p = reset ? 0 : (scroll - start) / change, 1095 clipped = p < 0 ? 0 : p > 1 ? 1 : p || 0, 1096 prevProgress = self.progress, 1097 isActive, 1098 wasActive, 1099 toggleState, 1100 action, 1101 stateChanged, 1102 toggled; 1103 1104 if (recordVelocity) { 1105 scroll2 = scroll1; 1106 scroll1 = scroll; 1107 1108 if (snap) { 1109 snap2 = snap1; 1110 snap1 = animation && !isToggle ? animation.totalProgress() : clipped; 1111 } 1112 } 1113 1114 anticipatePin && !clipped && pin && !_refreshing && !_startup && _lastScrollTime && start < scroll + (scroll - scroll2) / (_getTime() - _time2) * anticipatePin && (clipped = 0.0001); 1115 1116 if (clipped !== prevProgress && self.enabled) { 1117 isActive = self.isActive = !!clipped && clipped < 1; 1118 wasActive = !!prevProgress && prevProgress < 1; 1119 toggled = isActive !== wasActive; 1120 stateChanged = toggled || !!clipped !== !!prevProgress; 1121 self.direction = clipped > prevProgress ? 1 : -1; 1122 self.progress = clipped; 1123 1124 if (!isToggle) { 1125 if (scrubTween && !_refreshing && !_startup) { 1126 scrubTween.vars.totalProgress = clipped; 1127 scrubTween.invalidate().restart(); 1128 } else if (animation) { 1129 animation.totalProgress(clipped, !!_refreshing); 1130 } 1131 } 1132 1133 if (pin) { 1134 reset && pinSpacing && (spacer.style[pinSpacing + direction.os2] = spacingStart); 1135 1136 if (!useFixedPosition) { 1137 pinSetter(pinStart + pinChange * clipped); 1138 } else if (stateChanged) { 1139 action = !reset && clipped > prevProgress && end + 1 > scroll && scroll + 1 >= _maxScroll(scroller, direction); 1140 1141 if (pinReparent) { 1142 if (!reset && (isActive || action)) { 1143 var bounds = _getBounds(pin, true), 1144 _offset = scroll - start; 1145 1146 pin.style.top = bounds.top + (direction === _vertical ? _offset : 0) + _px; 1147 pin.style.left = bounds.left + (direction === _vertical ? 0 : _offset) + _px; 1148 } 1149 1150 _reparent(pin, !reset && (isActive || action) ? _body : spacer); 1151 } 1152 1153 _setState(isActive || action ? pinActiveState : pinState); 1154 1155 pinChange !== change && clipped < 1 && isActive || pinSetter(pinStart + (clipped === 1 && !action ? pinChange : 0)); 1156 } 1157 } 1158 1159 snap && !tweenTo.tween && !_refreshing && !_startup && snapDelayedCall.restart(true); 1160 toggleClass && (toggled || once && clipped && (clipped < 1 || !_limitCallbacks)) && _toArray(toggleClass.targets).forEach(function (el) { 1161 return el.classList[isActive || once ? "add" : "remove"](toggleClass.className); 1162 }); 1163 onUpdate && !isToggle && !reset && onUpdate(self); 1164 1165 if (stateChanged && !_refreshing) { 1166 toggleState = clipped && !prevProgress ? 0 : clipped === 1 ? 1 : prevProgress === 1 ? 2 : 3; 1167 1168 if (isToggle) { 1169 action = !toggled && toggleActions[toggleState + 1] !== "none" && toggleActions[toggleState + 1] || toggleActions[toggleState]; 1170 1171 if (animation && (action === "complete" || action === "reset" || action in animation)) { 1172 if (action === "complete") { 1173 animation.pause().totalProgress(1); 1174 } else if (action === "reset") { 1175 animation.restart(true).pause(); 1176 } else { 1177 animation[action](); 1178 } 1179 } 1180 1181 onUpdate && onUpdate(self); 1182 } 1183 1184 if (toggled || !_limitCallbacks) { 1185 onToggle && toggled && onToggle(self); 1186 callbacks[toggleState] && callbacks[toggleState](self); 1187 once && (clipped === 1 ? self.kill(false, 1) : callbacks[toggleState] = 0); 1188 1189 if (!toggled) { 1190 toggleState = clipped === 1 ? 1 : 3; 1191 callbacks[toggleState] && callbacks[toggleState](self); 1192 } 1193 } 1194 } else if (isToggle && onUpdate && !_refreshing) { 1195 onUpdate(self); 1196 } 1197 } 1198 1199 if (markerEndSetter) { 1200 markerStartSetter(scroll + (markerStartTrigger._isFlipped ? 1 : 0)); 1201 markerEndSetter(scroll); 1202 } 1203 }; 1204 1205 self.enable = function () { 1206 if (!self.enabled) { 1207 self.enabled = true; 1208 1209 _addListener(scroller, "resize", _onResize); 1210 1211 _addListener(scroller, "scroll", _onScroll); 1212 1213 onRefreshInit && _addListener(ScrollTrigger, "refreshInit", onRefreshInit); 1214 !animation || !animation.add ? self.refresh() : gsap.delayedCall(0.01, function () { 1215 return start || end || self.refresh();
1216 }) && (change = 0.01) && (start = end = 0); 1217 } 1218 }; 1219 1220 self.disable = function (reset, allowAnimation) { 1221 if (self.enabled) { 1222 reset !== false && self.revert(); 1223 self.enabled = self.isActive = false; 1224 allowAnimation || scrubTween && scrubTween.pause(); 1225 prevScroll = 0; 1226 pinCache && (pinCache.uncache = 1); 1227 onRefreshInit && _removeListener(ScrollTrigger, "refreshInit", onRefreshInit); 1228 1229 if (snapDelayedCall) { 1230 snapDelayedCall.pause(); 1231 tweenTo.tween && tweenTo.tween.kill(); 1232 } 1233 1234 if (!isViewport) { 1235 var i = _triggers.length; 1236 1237 while (i--) { 1238 if (_triggers[i].scroller === scroller && _triggers[i] !== self) { 1239 return; 1240 } 1241 } 1242 1243 _removeListener(scroller, "resize", _onResize); 1244 1245 _removeListener(scroller, "scroll", _onScroll); 1246 } 1247 } 1248 }; 1249 1250 self.kill = function (revert, allowAnimation) { 1251 self.disable(revert, allowAnimation); 1252 id && delete _ids[id]; 1253 1254 var i = _triggers.indexOf(self); 1255 1256 _triggers.splice(i, 1); 1257 1258 i === _i && _direction > 0 && _i--; 1259 1260 if (animation) { 1261 animation.scrollTrigger = null; 1262 revert && animation.render(-1); 1263 allowAnimation || animation.kill(); 1264 } 1265 1266 markerStart && [markerStart, markerEnd, markerStartTrigger, markerEndTrigger].forEach(function (m) { 1267 return m.parentNode.removeChild(m); 1268 }); 1269 pinCache && (pinCache.uncache = 1); 1270 }; 1271 1272 self.enable(); 1273 }; 1274 1275 ScrollTrigger.register = function register(core) { 1276 if (!_coreInitted) { 1277 gsap = core || _getGSAP(); 1278 1279 if (_windowExists() && window.document) { 1280 _win = window; 1281 _doc = document; 1282 _docEl = _doc.documentElement; 1283 _body = _doc.body; 1284 } 1285 1286 if (gsap) { 1287 _toArray = gsap.utils.toArray; 1288 _clamp = gsap.utils.clamp; 1289 gsap.core.globals("ScrollTrigger", ScrollTrigger); 1290 1291 if (_body) { 1292 _raf = _win.requestAnimationFrame || function (f) { 1293 return setTimeout(f, 16); 1294 }; 1295 1296 _addListener(_win, "mousewheel", _onScroll); 1297 1298 _root = [_win, _doc, _docEl, _body]; 1299 1300 _addListener(_doc, "scroll", _onScroll); 1301 1302 var bodyStyle = _body.style, 1303 border = bodyStyle.borderTop, 1304 bounds; 1305 bodyStyle.borderTop = "1px solid #000"; 1306 bounds = _getBounds(_body); 1307 _vertical.m = Math.round(bounds.top + _vertical.sc()) || 0; 1308 _horizontal.m = Math.round(bounds.left + _horizontal.sc()) || 0; 1309 border ? bodyStyle.borderTop = border : bodyStyle.removeProperty("border-top"); 1310 _syncInterval = setInterval(_sync, 200); 1311 gsap.delayedCall(0.5, function () { 1312 return _startup = 0; 1313 }); 1314 1315 _addListener(_doc, "touchcancel", _passThrough); 1316 1317 _addListener(_body, "touchstart", _passThrough); 1318 1319 _multiListener(_addListener, _doc, "pointerdown,touchstart,mousedown", function () { 1320 return _pointerIsDown = 1; 1321 }); 1322 1323 _multiListener(_addListener, _doc, "pointerup,touchend,mouseup", function () { 1324 return _pointerIsDown = 0; 1325 }); 1326 1327 _transformProp = gsap.utils.checkPrefix("transform"); 1328 1329 _stateProps.push(_transformProp); 1330 1331 _coreInitted = _getTime(); 1332 _resizeDelay = gsap.delayedCall(0.2, _refreshAll).pause(); 1333 _autoRefresh = [_doc, "visibilitychange", function () { 1334 var w = _win.innerWidth, 1335 h = _win.innerHeight; 1336 1337 if (_doc.hidden) { 1338 _prevWidth = w; 1339 _prevHeight = h; 1340 } else if (_prevWidth !== w || _prevHeight !== h) { 1341 _onResize(); 1342 } 1343 }, _doc, "DOMContentLoaded", _refreshAll, _win, "load", function () { 1344 return _lastScrollTime || _refreshAll(); 1345 }, _win, "resize", _onResize]; 1346 1347 _iterateAutoRefresh(_addListener); 1348 } 1349 } 1350 } 1351 1352 return _coreInitted; 1353 }; 1354 1355 ScrollTrigger.defaults = function defaults(config) { 1356 for (var p in config) { 1357 _defaults[p] = config[p]; 1358 } 1359 }; 1360 1361 ScrollTrigger.kill = function kill() { 1362 _enabled = 0; 1363
1364 _triggers.slice(0).forEach(function (trigger) { 1365 return trigger.kill(1); 1366 }); 1367 }; 1368 1369 ScrollTrigger.config = function config(vars) { 1370 "limitCallbacks" in vars && (_limitCallbacks = !!vars.limitCallbacks); 1371 var ms = vars.syncInterval; 1372 ms && clearInterval(_syncInterval) || (_syncInterval = ms) && setInterval(_sync, ms); 1373 "autoRefreshEvents" in vars && (_iterateAutoRefresh(_removeListener) || _iterateAutoRefresh(_addListener, vars.autoRefreshEvents || "none")); 1374 }; 1375 1376 ScrollTrigger.scrollerProxy = function scrollerProxy(target, vars) { 1377 var t = _toArray(target)[0]; 1378 1379 _isViewport(t) ? _proxies.unshift(_win, vars, _body, vars, _docEl, vars) : _proxies.unshift(t, vars); 1380 }; 1381 1382 ScrollTrigger.matchMedia = function matchMedia(vars) { 1383 var mq, p, i, func, result; 1384 1385 for (p in vars) { 1386 i = _media.indexOf(p); 1387 func = vars[p]; 1388 _creatingMedia = p; 1389 1390 if (p === "all") { 1391 func(); 1392 } else { 1393 mq = _win.matchMedia(p); 1394 1395 if (mq) { 1396 mq.matches && (result = func()); 1397 1398 if (~i) { 1399 _media[i + 1] = _combineFunc(_media[i + 1], func); 1400 _media[i + 2] = _combineFunc(_media[i + 2], result); 1401 } else { 1402 i = _media.length; 1403 1404 _media.push(p, func, result); 1405 1406 mq.addListener ? mq.addListener(_onMediaChange) : mq.addEventListener("change", _onMediaChange); 1407 } 1408 } 1409 } 1410 1411 _creatingMedia = 0; 1412 } 1413 1414 return _media; 1415 }; 1416 1417 ScrollTrigger.clearMatchMedia = function clearMatchMedia(query) { 1418 query || (_media.length = 0); 1419 query = _media.indexOf(query); 1420 query >= 0 && _media.splice(query, 3); 1421 }; 1422 1423 return ScrollTrigger; 1424 }(); 1425 ScrollTrigger.version = "3.5.0"; 1426 1427 ScrollTrigger.saveStyles = function (targets) { 1428 return targets ? _toArray(targets).forEach(function (target) { 1429 var i = _savedStyles.indexOf(target); 1430 1431 i >= 0 && _savedStyles.splice(i, 4); 1432 1433 _savedStyles.push(target, target.style.cssText, gsap.core.getCache(target), _creatingMedia); 1434 }) : _savedStyles; 1435 }; 1436 1437 ScrollTrigger.revert = function (soft, media) { 1438 return _revertAll(!soft, media); 1439 }; 1440 1441 ScrollTrigger.create = function (vars, animation) { 1442 return new ScrollTrigger(vars, animation); 1443 }; 1444 1445 ScrollTrigger.refresh = function (safe) { 1446 return safe ? _onResize() : _refreshAll(true); 1447 }; 1448 1449 ScrollTrigger.update = _updateAll; 1450 1451 ScrollTrigger.maxScroll = function (element, horizontal) { 1452 return _maxScroll(element, horizontal ? _horizontal : _vertical); 1453 }; 1454 1455 ScrollTrigger.getScrollFunc = function (element, horizontal) { 1456 return _getScrollFunc(_toArray(element)[0], horizontal ? _horizontal : _vertical); 1457 }; 1458 1459 ScrollTrigger.getById = function (id) { 1460 return _ids[id]; 1461 }; 1462 1463 ScrollTrigger.getAll = function () { 1464 return _triggers.slice(0); 1465 }; 1466 1467 ScrollTrigger.isScrolling = function () { 1468 return !!_lastScrollTime; 1469 }; 1470 1471 ScrollTrigger.addEventListener = function (type, callback) { 1472 var a = _listeners[type] || (_listeners[type] = []); 1473 ~a.indexOf(callback) || a.push(callback); 1474 }; 1475 1476 ScrollTrigger.removeEventListener = function (type, callback) { 1477 var a = _listeners[type], 1478 i = a && a.indexOf(callback); 1479 i >= 0 && a.splice(i, 1); 1480 }; 1481 1482 ScrollTrigger.batch = function (targets, vars) { 1483 var result = [], 1484 varsCopy = {}, 1485 interval = vars.interval || 0.016, 1486 batchMax = vars.batchMax || 1e9, 1487 proxyCallback = function proxyCallback(type, callback) { 1488 var elements = [], 1489 triggers = [], 1490 delay = gsap.delayedCall(interval, function () { 1491 callback(elements, triggers); 1492 elements = []; 1493 triggers = []; 1494 }).pause(); 1495 return function (self) { 1496 elements.length || delay.restart(true); 1497 elements.push(self.trigger); 1498 triggers.push(self); 1499 batchMax <= elements.length && delay.progress(1); 1500 }; 1501 }, 1502 p; 1503 1504 for (p in vars) { 1505 varsCopy[p] = p.substr(0, 2) === "on" && _isFunction(vars[p]) && p !== "onRefreshInit" ? proxyCallback(p, vars[p]) : vars[p]; 1506 } 1507 1508 if (_isFunction(batchMax)) { 1509 batchMax = batchMax(); 1510 1511 _addListener(ScrollTrigger, "refresh", function () { 1512 return batchMax = vars.batchMax(); 1513 }); 1514 } 1515
1516 _toArray(targets).forEach(function (target) { 1517 var config = {}; 1518 1519 for (p in varsCopy) { 1520 config[p] = varsCopy[p]; 1521 } 1522 1523 config.trigger = target; 1524 result.push(ScrollTrigger.create(config)); 1525 }); 1526 1527 return result; 1528 }; 1529 1530 ScrollTrigger.sort = function (func) { 1531 return _triggers.sort(func || function (a, b) { 1532 return (a.vars.refreshPriority || 0) * -1e6 + a.start - (b.start + (b.vars.refreshPriority || 0) * -1e6); 1533 }); 1534 }; 1535 1536 _getGSAP() && gsap.registerPlugin(ScrollTrigger); 1537 1538 exports.ScrollTrigger = ScrollTrigger; 1539 exports.default = ScrollTrigger; 1540 1541 Object.defineProperty(exports, '__esModule', { value: true }); 1542 1543})));
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.