vendor: 4,365 bytes, lines 1-129
1/*! 2 * ScrollToPlugin 3.12.7 3 * https://gsap.com 4 * 5 * @license Copyright 2008-2025, GreenSock. All rights reserved. 6 * Subject to the terms at https://gsap.com/standard-license or for 7 * Club GSAP members, the agreement issued with that membership. 8 * @author: Jack Doyle, [email protected] 9*/ 10 11/* eslint-disable */ 12var gsap, 13 _coreInitted, 14 _window, 15 _docEl, 16 _body, 17 _toArray, 18 _config, 19 ScrollTrigger, 20 _windowExists = function _windowExists() { 21 return typeof window !== "undefined"; 22}, 23 _getGSAP = function _getGSAP() { 24 return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap; 25}, 26 _isString = function _isString(value) { 27 return typeof value === "string"; 28}, 29 _isFunction = function _isFunction(value) { 30 return typeof value === "function"; 31}, 32 _max = function _max(element, axis) { 33 var dim = axis === "x" ? "Width" : "Height", 34 scroll = "scroll" + dim, 35 client = "client" + dim; 36 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]; 37}, 38 _buildGetter = function _buildGetter(e, axis) { 39 //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. 40 var p = "scroll" + (axis === "x" ? "Left" : "Top"); 41 42 if (e === _window) { 43 if (e.pageXOffset != null) { 44 p = "page" + axis.toUpperCase() + "Offset"; 45 } else { 46 e = _docEl[p] != null ? _docEl : _body; 47 } 48 } 49 50 return function () { 51 return e[p]; 52 }; 53}, 54 _clean = function _clean(value, index, target, targets) { 55 _isFunction(value) && (value = value(index, target, targets)); 56 57 if (typeof value !== "object") { 58 return _isString(value) && value !== "max" && value.charAt(1) !== "=" ? { 59 x: value, 60 y: value 61 } : { 62 y: value 63 }; //if we don't receive an object as the parameter, assume the user intends "y". 64 } else if (value.nodeType) { 65 return { 66 y: value, 67 x: value 68 }; 69 } else { 70 var result = {}, 71 p; 72 73 for (p in value) { 74 result[p] = p !== "onAutoKill" && _isFunction(value[p]) ? value[p](index, target, targets) : value[p]; 75 } 76 77 return result; 78 } 79}, 80 _getOffset = function _getOffset(element, container) { 81 element = _toArray(element)[0]; 82 83 if (!element || !element.getBoundingClientRect) { 84 return console.warn("scrollTo target doesn't exist. Using 0") || { 85 x: 0, 86 y: 0 87 }; 88 } 89 90 var rect = element.getBoundingClientRect(), 91 isRoot = !container || container === _window || container === _body, 92 cRect = isRoot ? { 93 top: _docEl.clientTop - (_window.pageYOffset || _docEl.scrollTop || _body.scrollTop || 0), 94 left: _docEl.clientLeft - (_window.pageXOffset || _docEl.scrollLeft || _body.scrollLeft || 0) 95 } : container.getBoundingClientRect(), 96 offsets = { 97 x: rect.left - cRect.left, 98 y: rect.top - cRect.top 99 }; 100 101 if (!isRoot && container) { 102 //only add the current scroll position if it's not the window/body. 103 offsets.x += _buildGetter(container, "x")(); 104 offsets.y += _buildGetter(container, "y")(); 105 } 106 107 return offsets; 108}, 109 _parseVal = function _parseVal(value, target, axis, currentVal, offset) { 110 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); 111}, 112 _initCore = function _initCore() { 113 gsap = _getGSAP(); 114 115 if (_windowExists() && gsap && typeof document !== "undefined" && document.body) { 116 _window = window; 117 _body = document.body; 118 _docEl = document.documentElement; 119 _toArray = gsap.utils.toArray; 120 gsap.config({ 121 autoKillThreshold: 7 122 }); 123 _config = gsap.config(); 124 _coreInitted = 1; 125 } 126}; 127 128export var ScrollToPlugin = { 129 version: "3.12.7
vendor: 4,818 bytes, lines 129-282
129", 130 name: "scrollTo", 131 rawVars: 1, 132 register: function register(core) { 133 gsap = core; 134 135 _initCore(); 136 }, 137 init: function init(target, value, tween, index, targets) { 138 _coreInitted || _initCore(); 139 var data = this, 140 snapType = gsap.getProperty(target, "scrollSnapType"); 141 data.isWin = target === _window; 142 data.target = target; 143 data.tween = tween; 144 value = _clean(value, index, target, targets); 145 data.vars = value; 146 data.autoKill = !!("autoKill" in value ? value : _config).autoKill; 147 data.getX = _buildGetter(target, "x"); 148 data.getY = _buildGetter(target, "y"); 149 data.x = data.xPrev = data.getX(); 150 data.y = data.yPrev = data.getY(); 151 ScrollTrigger || (ScrollTrigger = gsap.core.globals().ScrollTrigger); 152 gsap.getProperty(target, "scrollBehavior") === "smooth" && gsap.set(target, { 153 scrollBehavior: "auto" 154 }); 155 156 if (snapType && snapType !== "none") { 157 // disable scroll snapping to avoid strange behavior 158 data.snap = 1; 159 data.snapInline = target.style.scrollSnapType; 160 target.style.scrollSnapType = "none"; 161 } 162 163 if (value.x != null) { 164 data.add(data, "x", data.x, _parseVal(value.x, target, "x", data.x, value.offsetX || 0), index, targets); 165 166 data._props.push("scrollTo_x"); 167 } else { 168 data.skipX = 1; 169 } 170 171 if (value.y != null) { 172 data.add(data, "y", data.y, _parseVal(value.y, target, "y", data.y, value.offsetY || 0), index, targets); 173 174 data._props.push("scrollTo_y"); 175 } else { 176 data.skipY = 1; 177 } 178 }, 179 render: function render(ratio, data) { 180 var pt = data._pt, 181 target = data.target, 182 tween = data.tween, 183 autoKill = data.autoKill, 184 xPrev = data.xPrev, 185 yPrev = data.yPrev, 186 isWin = data.isWin, 187 snap = data.snap, 188 snapInline = data.snapInline, 189 x, 190 y, 191 yDif, 192 xDif, 193 threshold; 194 195 while (pt) { 196 pt.r(ratio, pt.d); 197 pt = pt._next; 198 } 199 200 x = isWin || !data.skipX ? data.getX() : xPrev; 201 y = isWin || !data.skipY ? data.getY() : yPrev; 202 yDif = y - yPrev; 203 xDif = x - xPrev; 204 threshold = _config.autoKillThreshold; 205 206 if (data.x < 0) { 207 //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) 208 data.x = 0; 209 } 210 211 if (data.y < 0) { 212 data.y = 0; 213 } 214 215 if (autoKill) { 216 //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. 217 if (!data.skipX && (xDif > threshold || xDif < -threshold) && x < _max(target, "x")) { 218 data.skipX = 1; //if the user scrolls separately, we should stop tweening! 219 } 220 221 if (!data.skipY && (yDif > threshold || yDif < -threshold) && y < _max(target, "y")) { 222 data.skipY = 1; //if the user scrolls separately, we should stop tweening! 223 } 224 225 if (data.skipX && data.skipY) { 226 tween.kill(); 227 data.vars.onAutoKill && data.vars.onAutoKill.apply(tween, data.vars.onAutoKillParams || []); 228 } 229 } 230 231 if (isWin) { 232 _window.scrollTo(!data.skipX ? data.x : x, !data.skipY ? data.y : y); 233 } else { 234 data.skipY || (target.scrollTop = data.y); 235 data.skipX || (target.scrollLeft = data.x); 236 } 237 238 if (snap && (ratio === 1 || ratio === 0)) { 239 y = target.scrollTop; 240 x = target.scrollLeft; 241 snapInline ? target.style.scrollSnapType = snapInline : target.style.removeProperty("scroll-snap-type"); 242 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. 243 244 target.scrollLeft = x + 1; 245 target.scrollTop = y; 246 target.scrollLeft = x; 247 } 248 249 data.xPrev = data.x; 250 data.yPrev = data.y; 251 ScrollTrigger && ScrollTrigger.update(); 252 }, 253 kill: function kill(property) { 254 var both = property === "scrollTo", 255 i = this._props.indexOf(property); 256 257 if (both || property === "scrollTo_x") { 258 this.skipX = 1; 259 } 260 261 if (both || property === "scrollTo_y") { 262 this.skipY = 1; 263 } 264 265 i > -1 && this._props.splice(i, 1); 266 return !this._props.length; 267 } 268}; 269ScrollToPlugin.max = _max; 270ScrollToPlugin.getOffset = _getOffset; 271ScrollToPlugin.buildGetter = _buildGetter; 272 273ScrollToPlugin.config = function (vars) { 274 _config || _initCore() || (_config = gsap.config()); // in case the window hasn't been defined yet. 275 276 for (var p in vars) { 277 _config[p] = vars[p]; 278 } 279}; 280 281_getGSAP() && gsap.registerPlugin(ScrollToPlugin); 282export { ScrollToPlugin as default };
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.