vendor: 4,797 bytes, lines 1-126
1var gsap, _coreInitted, _window, _docEl, _body, _toArray, _config, _windowExists = function _windowExists2() { 2 return typeof window !== "undefined"; 3}, _getGSAP = function _getGSAP2() { 4 return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap; 5}, _isString = function _isString2(value) { 6 return typeof value === "string"; 7}, _max = function _max2(element, axis) { 8 var dim = axis === "x" ? "Width" : "Height", scroll = "scroll" + dim, client = "client" + dim; 9 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]; 10}, _buildGetter = function _buildGetter2(e, axis) { 11 var p = "scroll" + (axis === "x" ? "Left" : "Top"); 12 if (e === _window) { 13 if (e.pageXOffset != null) { 14 p = "page" + axis.toUpperCase() + "Offset"; 15 } else { 16 e = _docEl[p] != null ? _docEl : _body; 17 } 18 } 19 return function() { 20 return e[p]; 21 }; 22}, _getOffset = function _getOffset2(element, container) { 23 var rect = _toArray(element)[0].getBoundingClientRect(), isRoot = !container || container === _window || container === _body, cRect = isRoot ? { 24 top: _docEl.clientTop - (_window.pageYOffset || _docEl.scrollTop || _body.scrollTop || 0), 25 left: _docEl.clientLeft - (_window.pageXOffset || _docEl.scrollLeft || _body.scrollLeft || 0) 26 } : container.getBoundingClientRect(), offsets = { 27 x: rect.left - cRect.left, 28 y: rect.top - cRect.top 29 }; 30 if (!isRoot && container) { 31 offsets.x += _buildGetter(container, "x")(); 32 offsets.y += _buildGetter(container, "y")(); 33 } 34 return offsets; 35}, _parseVal = function _parseVal2(value, target, axis, currentVal) { 36 return !isNaN(value) && typeof value !== "object" ? parseFloat(value) : _isString(value) && value.charAt(1) === "=" ? parseFloat(value.substr(2)) * (value.charAt(0) === "-" ? -1 : 1) + currentVal : value === "max" ? _max(target, axis) : Math.min(_max(target, axis), _getOffset(value, target)[axis]); 37}, _initCore = function _initCore2() { 38 gsap = _getGSAP(); 39 if (_windowExists() && gsap && document.body) { 40 _window = window; 41 _body = document.body; 42 _docEl = document.documentElement; 43 _toArray = gsap.utils.toArray; 44 gsap.config({ 45 autoKillThreshold: 7 46 }); 47 _config = gsap.config(); 48 _coreInitted = 1; 49 } 50}; 51var ScrollToPlugin = { 52 version: "3.4.0", 53 name: "scrollTo", 54 rawVars: 1, 55 register: function register(core) { 56 gsap = core; 57 _initCore(); 58 }, 59 init: function init(target, value, tween, index, targets) { 60 if (!_coreInitted) { 61 _initCore(); 62 } 63 var data = this; 64 data.isWin = target === _window; 65 data.target = target; 66 data.tween = tween; 67 if (typeof value !== "object") { 68 value = { 69 y: value 70 }; 71 if (_isString(value.y) && value.y !== "max" && value.y.charAt(1) !== "=") { 72 value.x = value.y; 73 } 74 } else if (value.nodeType) { 75 value = { 76 y: value, 77 x: value 78 }; 79 } 80 data.vars = value; 81 data.autoKill = !!value.autoKill; 82 data.getX = _buildGetter(target, "x"); 83 data.getY = _buildGetter(target, "y"); 84 data.x = data.xPrev = data.getX(); 85 data.y = data.yPrev = data.getY(); 86 if (value.x != null) { 87 data.add(data, "x", data.x, _parseVal(value.x, target, "x", data.x) - (value.offsetX || 0), index, targets, Math.round); 88 data._props.push("scrollTo_x"); 89 } else { 90 data.skipX = 1; 91 } 92 if (value.y != null) { 93 data.add(data, "y", data.y, _parseVal(value.y, target, "y", data.y) - (value.offsetY || 0), index, targets, Math.round); 94 data._props.push("scrollTo_y"); 95 } else { 96 data.skipY = 1; 97 } 98 }, 99 render: function render(ratio, data) { 100 var pt = data._pt, target = data.target, tween = data.tween, autoKill = data.autoKill, xPrev = data.xPrev, yPrev = data.yPrev, isWin = data.isWin, x, y, yDif, xDif, threshold; 101 while (pt) { 102 pt.r(ratio, pt.d); 103 pt = pt._next; 104 } 105 x = isWin || !data.skipX ? data.getX() : xPrev; 106 y = isWin || !data.skipY ? data.getY() : yPrev; 107 yDif = y - yPrev; 108 xDif = x - xPrev; 109 threshold = _config.autoKillThreshold; 110 if (data.x < 0) { 111 data.x = 0; 112 } 113 if (data.y < 0) { 114 data.y = 0; 115 } 116 if (autoKill) { 117 if (!data.skipX && (xDif > threshold || xDif < -threshold) && x < _max(target, "x")) { 118 data.skipX = 1; 119 } 120 if (!data.skipY && (yDif > threshold || yDif < -threshold) && y < _max(target, "y")) { 121 data.skipY = 1; 122 } 123 if (data.skipX && data.skipY) { 124 tween.kill(); 125 if (data.vars.onAutoKill) { 126 data.vars.onAutoKill.apply(tween, data.vars.onAutoKillParam
126s || []); 127 } 128 } 129 } 130 if (isWin) { 131 _window.scrollTo(!data.skipX ? data.x : x, !data.skipY ? data.y : y); 132 } else { 133 if (!data.skipY) { 134 target.scrollTop = data.y; 135 } 136 if (!data.skipX) { 137 target.scrollLeft = data.x; 138 } 139 } 140 data.xPrev = data.x; 141 data.yPrev = data.y; 142 }, 143 kill: function kill(property) { 144 var both = property === "scrollTo"; 145 if (both || property === "scrollTo_x") { 146 this.skipX = 1; 147 } 148 if (both || property === "scrollTo_y") { 149 this.skipY = 1; 150 } 151 } 152}; 153ScrollToPlugin.max = _max; 154ScrollToPlugin.getOffset = _getOffset; 155ScrollToPlugin.buildGetter = _buildGetter; 156_getGSAP() && gsap.registerPlugin(ScrollToPlugin); 157export { 158 ScrollToPlugin as S 159};
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.