/******/ (function() { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ "../../node_modules/@grubersjoe/slide-menu/dist/slide-menu.js": /*!********************************************************************!*\ !*** ../../node_modules/@grubersjoe/slide-menu/dist/slide-menu.js ***! \********************************************************************/ /***/ (function() { !function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=59)}([function(t,e,n){(function(e){var n=function(t){return t&&t.Math==Math&&t};t.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof e&&e)||Function("return this")()}).call(this,n(32))},function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},function(t,e,n){var r=n(1);t.exports=!r((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,e,n){var r=n(3),o=n(18),i=n(13);t.exports=r?function(t,e,n){return o.f(t,e,i(1,n))}:function(t,e,n){return t[e]=n,t}},function(t,e,n){var r=n(4);t.exports=function(t){if(!r(t))throw TypeError(String(t)+" is not an object");return t}},function(t,e,n){var r=n(14),o=n(8);t.exports=function(t){return r(o(t))}},function(t,e){t.exports=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}},function(t,e,n){var r=n(0),o=n(5);t.exports=function(t,e){try{o(r,t,e)}catch(n){r[t]=e}return e}},function(t,e,n){var r=n(0),o=n(11).f,i=n(5),c=n(19),s=n(9),a=n(38),u=n(46);t.exports=function(t,e){var n,l,f,p,h,m=t.target,d=t.global,v=t.stat;if(n=d?r:v?r[m]||s(m,{}):(r[m]||{}).prototype)for(l in e){if(p=e[l],f=t.noTargetGet?(h=o(n,l))&&h.value:n[l],!u(d?l:m+(v?".":"#")+l,t.forced)&&void 0!==f){if(typeof p==typeof f)continue;a(p,f)}(t.sham||f&&f.sham)&&i(p,"sham",!0),c(n,l,p,t)}}},function(t,e,n){var r=n(3),o=n(12),i=n(13),c=n(7),s=n(16),a=n(2),u=n(17),l=Object.getOwnPropertyDescriptor;e.f=r?l:function(t,e){if(t=c(t),e=s(e,!0),u)try{return l(t,e)}catch(t){}if(a(t,e))return i(!o.f.call(t,e),t[e])}},function(t,e,n){"use strict";var r={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,i=o&&!r.call({1:2},1);e.f=i?function(t){var e=o(this,t);return!!e&&e.enumerable}:r},function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},function(t,e,n){var r=n(1),o=n(15),i="".split;t.exports=r((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==o(t)?i.call(t,""):Object(t)}:Object},function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(t,e,n){var r=n(4);t.exports=function(t,e){if(!r(t))return t;var n,o;if(e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;if("function"==typeof(n=t.valueOf)&&!r(o=n.call(t)))return o;if(!e&&"function"==typeof(n=t.toString)&&!r(o=n.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,e,n){var r=n(3),o=n(1),i=n(33);t.exports=!r&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},function(t,e,n){var r=n(3),o=n(17),i=n(6),c=n(16),s=Object.defineProperty;e.f=r?s:function(t,e,n){if(i(t),e=c(e,!0),i(n),o)try{return s(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},function(t,e,n){var r=n(0),o=n(5),i=n(2),c=n(9),s=n(20),a=n(34),u=a.get,l=a.enforce,f=String(String).split("String");(t.exports=function(t,e,n,s){var a=!!s&&!!s.unsafe,u=!!s&&!!s.enumerable,p=!!s&&!!s.noTargetGet;"function"==typeof n&&("string"!=typeof e||i(n,"name")||o(n,"name",e),l(n).source=f.join("string"==typeof e?e:"")),t!==r?(a?!p&&t[e]&&(u=!0):delete t[e],u?t[e]=n:o(t,e,n)):u?t[e]=n:c(e,n)})(Function.prototype,"toString",(function(){return"function"==typeof this&&u(this).source||s(this)}))},function(t,e,n){var r=n(21),o=Function.toString;"function"!=typeof r.inspectSource&&(r.inspectSource=function(t){return o.call(t)}),t.exports=r.inspectSource},function(t,e,n){var r=n(0),o=n(9),i=r["__core-js_shared__"]||o("__core-js_shared__",{});t.exports=i},function(t,e,n){var r=n(37),o=n(21);(t.exports=function(t,e){return o[t]||(o[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.1",mode:r?"pure":"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})},function(t,e){var n=0,r=Math.random();t.exports=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++n+r).toString(36)}},function(t,e){t.exports={}},function(t,e,n){var r=n(2),o=n(7),i=n(43).indexOf,c=n(24);t.exports=function(t,e){var n,s=o(t),a=0,u=[];for(n in s)!r(c,n)&&r(s,n)&&u.push(n);for(;e.length>a;)r(s,n=e[a++])&&(~i(u,n)||u.push(n));return u}},function(t,e){var n=Math.ceil,r=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?r:n)(t)}},function(t,e){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},function(t,e){e.f=Object.getOwnPropertySymbols},function(t,e,n){var r=n(0),o=n(22),i=n(2),c=n(23),s=n(30),a=n(55),u=o("wks"),l=r.Symbol,f=a?l:l&&l.withoutSetter||c;t.exports=function(t){return i(u,t)||(s&&i(l,t)?u[t]=l[t]:u[t]=f("Symbol."+t)),u[t]}},function(t,e,n){var r=n(1);t.exports=!!Object.getOwnPropertySymbols&&!r((function(){return!String(Symbol())}))},function(t,e,n){var r=n(10),o=n(47);r({target:"Object",stat:!0,forced:Object.assign!==o},{assign:o})},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){var r=n(0),o=n(4),i=r.document,c=o(i)&&o(i.createElement);t.exports=function(t){return c?i.createElement(t):{}}},function(t,e,n){var r,o,i,c=n(35),s=n(0),a=n(4),u=n(5),l=n(2),f=n(36),p=n(24),h=s.WeakMap;if(c){var m=new h,d=m.get,v=m.has,g=m.set;r=function(t,e){return g.call(m,t,e),e},o=function(t){return d.call(m,t)||{}},i=function(t){return v.call(m,t)}}else{var E=f("state");p[E]=!0,r=function(t,e){return u(t,E,e),e},o=function(t){return l(t,E)?t[E]:{}},i=function(t){return l(t,E)}}t.exports={set:r,get:o,has:i,enforce:function(t){return i(t)?o(t):r(t,{})},getterFor:function(t){return function(e){var n;if(!a(e)||(n=o(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}}},function(t,e,n){var r=n(0),o=n(20),i=r.WeakMap;t.exports="function"==typeof i&&/native code/.test(o(i))},function(t,e,n){var r=n(22),o=n(23),i=r("keys");t.exports=function(t){return i[t]||(i[t]=o(t))}},function(t,e){t.exports=!1},function(t,e,n){var r=n(2),o=n(39),i=n(11),c=n(18);t.exports=function(t,e){for(var n=o(e),s=c.f,a=i.f,u=0;ul;)if((s=a[l++])!=s)return!0}else for(;u>l;l++)if((t||l in a)&&a[l]===n)return t||l||0;return!t&&-1}};t.exports={includes:c(!0),indexOf:c(!1)}},function(t,e,n){var r=n(26),o=Math.min;t.exports=function(t){return t>0?o(r(t),9007199254740991):0}},function(t,e,n){var r=n(26),o=Math.max,i=Math.min;t.exports=function(t,e){var n=r(t);return n<0?o(n+e,0):i(n,e)}},function(t,e,n){var r=n(1),o=/#|\.prototype\./,i=function(t,e){var n=s[c(t)];return n==u||n!=a&&("function"==typeof e?r(e):!!e)},c=i.normalize=function(t){return String(t).replace(o,".").toLowerCase()},s=i.data={},a=i.NATIVE="N",u=i.POLYFILL="P";t.exports=i},function(t,e,n){"use strict";var r=n(3),o=n(1),i=n(48),c=n(28),s=n(12),a=n(49),u=n(14),l=Object.assign,f=Object.defineProperty;t.exports=!l||o((function(){if(r&&1!==l({b:1},l(f({},"a",{enumerable:!0,get:function(){f(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},e={},n=Symbol();return t[n]=7,"abcdefghijklmnopqrst".split("").forEach((function(t){e[t]=t})),7!=l({},t)[n]||"abcdefghijklmnopqrst"!=i(l({},e)).join("")}))?function(t,e){for(var n=a(t),o=arguments.length,l=1,f=c.f,p=s.f;o>l;)for(var h,m=u(arguments[l++]),d=f?i(m).concat(f(m)):i(m),v=d.length,g=0;v>g;)h=d[g++],r&&!p.call(m,h)||(n[h]=m[h]);return n}:l},function(t,e,n){var r=n(25),o=n(27);t.exports=Object.keys||function(t){return r(t,o)}},function(t,e,n){var r=n(8);t.exports=function(t){return Object(r(t))}},function(t,e,n){"use strict";var r=n(19),o=n(6),i=n(1),c=n(51),s=RegExp.prototype,a=s.toString,u=i((function(){return"/a/b"!=a.call({source:"a",flags:"b"})})),l="toString"!=a.name;(u||l)&&r(RegExp.prototype,"toString",(function(){var t=o(this),e=String(t.source),n=t.flags;return"/"+e+"/"+String(void 0===n&&t instanceof RegExp&&!("flags"in s)?c.call(t):n)}),{unsafe:!0})},function(t,e,n){"use strict";var r=n(6);t.exports=function(){var t=r(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e}},function(t,e,n){"use strict";var r=n(10),o=n(53),i=n(8);r({target:"String",proto:!0,forced:!n(56)("includes")},{includes:function(t){return!!~String(i(this)).indexOf(o(t),arguments.length>1?arguments[1]:void 0)}})},function(t,e,n){var r=n(54);t.exports=function(t){if(r(t))throw TypeError("The method doesn't accept regular expressions");return t}},function(t,e,n){var r=n(4),o=n(15),i=n(29)("match");t.exports=function(t){var e;return r(t)&&(void 0!==(e=t[i])?!!e:"RegExp"==o(t))}},function(t,e,n){var r=n(30);t.exports=r&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},function(t,e,n){var r=n(29)("match");t.exports=function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[r]=!1,"/./"[t](e)}catch(t){}}return!1}},function(t,e,n){},,function(t,e,n){"use strict";n.r(e);var r,o,i;n(31),n(50),n(52),n(57);function c(t,e,n){const r=[];for(;t&&null!==t.parentElement&&(void 0===n||r.length{t.parentElement&&t.parentElement.removeChild(t)})}if(n){Array.from(this.wrapperElem.querySelectorAll(".".concat(u.CLASS_NAMES.control))).forEach(t=>{const e=s(t,"li");e&&e.parentElement&&e.parentElement.removeChild(e)})}!function(t){const e=t.parentElement;if(null===e)throw Error("`elem` has no parentElement");for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}(this.wrapperElem),this.menuElem.style.cssText="",this.menuElem.querySelectorAll("ul").forEach(t=>t.style.cssText=""),delete this.menuElem._slideMenu}navigateTo(t){if(this.triggerEvent(i.Navigate),"string"==typeof t){const e=document.querySelector(t);if(!(e instanceof HTMLElement))throw new Error("Invalid parameter `target`. A valid query selector is required.");t=e}Array.from(this.wrapperElem.querySelectorAll(".".concat(u.CLASS_NAMES.active))).forEach(t=>{t.style.display="none",t.classList.remove(u.CLASS_NAMES.active)});const e=c(t,"ul"),n=e.length-1;n>=0&&n!==this.level&&(this.level=n,this.moveSlider(this.wrapperElem,100*-this.level)),e.forEach(t=>{t.style.display="block",t.classList.add(u.CLASS_NAMES.active)})}initEventHandlers(){Array.from(this.menuElem.querySelectorAll("a")).forEach(t=>t.addEventListener("click",t=>{const e=t.target,n=e.matches("a")?e:s(e,"a");n&&this.navigate(r.Forward,n)})),this.menuElem.addEventListener("transitionend",this.onTransitionEnd.bind(this)),this.wrapperElem.addEventListener("transitionend",this.onTransitionEnd.bind(this)),this.initKeybindings(),this.initSubmenuVisibility()}onTransitionEnd(t){t.target!==this.menuElem&&t.target!==this.wrapperElem||(this.isAnimating=!1,this.lastAction&&(this.triggerEvent(this.lastAction,!0),this.lastAction=null))}initKeybindings(){document.addEventListener("keydown",t=>{switch(t.key){case this.options.keyClose:this.close();break;case this.options.keyOpen:this.open();break;default:return}t.preventDefault()})}initSubmenuVisibility(){this.menuElem.addEventListener("sm.back-after",()=>{const t=".".concat(u.CLASS_NAMES.active," ").repeat(this.level+1),e=this.menuElem.querySelector("ul ".concat(t));e&&(e.style.display="none",e.classList.remove(u.CLASS_NAMES.active))})}triggerEvent(t,e=!1){this.lastAction=t;const n="sm.".concat(t).concat(e?"-after":""),r=new CustomEvent(n);this.menuElem.dispatchEvent(r)}navigate(t=r.Forward,e){if(this.isAnimating||t===r.Backward&&0===this.level)return;const n=-100*(this.level+t);if(e&&null!==e.parentElement&&t===r.Forward){const t=e.parentElement.querySelector("ul");if(!t)return;t.classList.add(u.CLASS_NAMES.active),t.style.display="block"}const o=t===r.Forward?i.Forward:i.Back;this.triggerEvent(o),this.level=this.level+t,this.moveSlider(this.wrapperElem,n)}moveSlider(t,e){e.toString().includes("%")||(e+="%"),t.style.transform="translateX(".concat(e,")"),this.isAnimating=!0}initMenu(){this.runWithoutAnimation(()=>{switch(this.options.position){case o.Left:Object.assign(this.menuElem.style,{left:0,right:"auto",transform:"translateX(-100%)"});break;default:Object.assign(this.menuElem.style,{left:"auto",right:0})}this.menuElem.style.display="block"})}runWithoutAnimation(t){const e=[this.menuElem,this.wrapperElem];e.forEach(t=>t.style.transition="none"),t(),this.menuElem.offsetHeight,e.forEach(t=>t.style.removeProperty("transition")),this.isAnimating=!1}initSubmenus(){this.menuElem.querySelectorAll("a").forEach(t=>{if(null===t.parentElement)return;const e=t.parentElement.querySelector("ul");if(!e)return;t.addEventListener("click",t=>{t.preventDefault()});const n=t.textContent;if(this.addLinkDecorators(t),this.options.showBackLink){const{backLinkBefore:t,backLinkAfter:r}=this.options,o=document.createElement("a");o.innerHTML=t+n+r,o.classList.add(u.CLASS_NAMES.backlink,u.CLASS_NAMES.control),o.setAttribute("data-action",i.Back);const c=document.createElement("li");c.appendChild(o),e.insertBefore(c,e.firstChild)}})}addLinkDecorators(t){const{submenuLinkBefore:e,submenuLinkAfter:n}=this.options;if(e){const n=document.createElement("span");n.classList.add(u.CLASS_NAMES.decorator),n.innerHTML=e,t.insertBefore(n,t.firstChild)}if(n){const e=document.createElement("span");e.classList.add(u.CLASS_NAMES.decorator),e.innerHTML=n,t.appendChild(e)}return t}}u.NAMESPACE="slide-menu",u.CLASS_NAMES={active:"".concat(u.NAMESPACE,"__submenu--active"),backlink:"".concat(u.NAMESPACE,"__backlink"),control:"".concat(u.NAMESPACE,"__control"),decorator:"".concat(u.NAMESPACE,"__decorator"),wrapper:"".concat(u.NAMESPACE,"__slider")},document.addEventListener("click",t=>{if(!(t.target instanceof HTMLElement))return;const e=t.target.className.includes(u.CLASS_NAMES.control)?t.target:s(t.target,".".concat(u.CLASS_NAMES.control));if(!e||!e.className.includes(u.CLASS_NAMES.control))return;const n=e.getAttribute("data-target"),r=n&&"this"!==n?document.getElementById(n):s(e,".".concat(u.NAMESPACE));if(!r)throw new Error("Unable to find menu ".concat(n));const o=r._slideMenu,i=e.getAttribute("data-action"),c=e.getAttribute("data-arg");o&&i&&"function"==typeof o[i]&&(c?o[i](c):o[i]())}),window.SlideMenu=u}]); /***/ }), /***/ "../../node_modules/aos/dist/aos.js": /*!******************************************!*\ !*** ../../node_modules/aos/dist/aos.js ***! \******************************************/ /***/ (function(module, __unused_webpack_exports, __webpack_require__) { !function(e,t){ true?module.exports=t():0}(this,function(){"use strict";var e="undefined"!=typeof window?window:"undefined"!=typeof __webpack_require__.g?__webpack_require__.g:"undefined"!=typeof self?self:{},t="Expected a function",n=NaN,o="[object Symbol]",i=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,c=/^0o[0-7]+$/i,s=parseInt,u="object"==typeof e&&e&&e.Object===Object&&e,d="object"==typeof self&&self&&self.Object===Object&&self,l=u||d||Function("return this")(),f=Object.prototype.toString,m=Math.max,p=Math.min,b=function(){return l.Date.now()};function v(e,n,o){var i,a,r,c,s,u,d=0,l=!1,f=!1,v=!0;if("function"!=typeof e)throw new TypeError(t);function y(t){var n=i,o=a;return i=a=void 0,d=t,c=e.apply(o,n)}function h(e){var t=e-u;return void 0===u||t>=n||t<0||f&&e-d>=r}function k(){var e=b();if(h(e))return x(e);s=setTimeout(k,function(e){var t=n-(e-u);return f?p(t,r-(e-d)):t}(e))}function x(e){return s=void 0,v&&i?y(e):(i=a=void 0,c)}function O(){var e=b(),t=h(e);if(i=arguments,a=this,u=e,t){if(void 0===s)return function(e){return d=e,s=setTimeout(k,n),l?y(e):c}(u);if(f)return s=setTimeout(k,n),y(u)}return void 0===s&&(s=setTimeout(k,n)),c}return n=w(n)||0,g(o)&&(l=!!o.leading,r=(f="maxWait"in o)?m(w(o.maxWait)||0,n):r,v="trailing"in o?!!o.trailing:v),O.cancel=function(){void 0!==s&&clearTimeout(s),d=0,i=u=a=s=void 0},O.flush=function(){return void 0===s?c:x(b())},O}function g(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function w(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&f.call(e)==o}(e))return n;if(g(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=g(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(i,"");var u=r.test(e);return u||c.test(e)?s(e.slice(2),u?2:8):a.test(e)?n:+e}var y=function(e,n,o){var i=!0,a=!0;if("function"!=typeof e)throw new TypeError(t);return g(o)&&(i="leading"in o?!!o.leading:i,a="trailing"in o?!!o.trailing:a),v(e,n,{leading:i,maxWait:n,trailing:a})},h="Expected a function",k=NaN,x="[object Symbol]",O=/^\s+|\s+$/g,j=/^[-+]0x[0-9a-f]+$/i,E=/^0b[01]+$/i,N=/^0o[0-7]+$/i,z=parseInt,C="object"==typeof e&&e&&e.Object===Object&&e,A="object"==typeof self&&self&&self.Object===Object&&self,q=C||A||Function("return this")(),L=Object.prototype.toString,T=Math.max,M=Math.min,S=function(){return q.Date.now()};function D(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function H(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&L.call(e)==x}(e))return k;if(D(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=D(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(O,"");var n=E.test(e);return n||N.test(e)?z(e.slice(2),n?2:8):j.test(e)?k:+e}var $=function(e,t,n){var o,i,a,r,c,s,u=0,d=!1,l=!1,f=!0;if("function"!=typeof e)throw new TypeError(h);function m(t){var n=o,a=i;return o=i=void 0,u=t,r=e.apply(a,n)}function p(e){var n=e-s;return void 0===s||n>=t||n<0||l&&e-u>=a}function b(){var e=S();if(p(e))return v(e);c=setTimeout(b,function(e){var n=t-(e-s);return l?M(n,a-(e-u)):n}(e))}function v(e){return c=void 0,f&&o?m(e):(o=i=void 0,r)}function g(){var e=S(),n=p(e);if(o=arguments,i=this,s=e,n){if(void 0===c)return function(e){return u=e,c=setTimeout(b,t),d?m(e):r}(s);if(l)return c=setTimeout(b,t),m(s)}return void 0===c&&(c=setTimeout(b,t)),r}return t=H(t)||0,D(n)&&(d=!!n.leading,a=(l="maxWait"in n)?T(H(n.maxWait)||0,t):a,f="trailing"in n?!!n.trailing:f),g.cancel=function(){void 0!==c&&clearTimeout(c),u=0,o=s=i=c=void 0},g.flush=function(){return void 0===c?r:v(S())},g},W=function(){};function P(e){e&&e.forEach(function(e){var t=Array.prototype.slice.call(e.addedNodes),n=Array.prototype.slice.call(e.removedNodes);if(function e(t){var n=void 0,o=void 0;for(n=0;n=o.out&&!n.once?a():t>=o.in?e.animated||(function(e,t){t&&t.forEach(function(t){return e.classList.add(t)})}(i,n.animatedClassNames),V("aos:in",i),e.options.id&&V("aos:in:"+e.options.id,i),e.animated=!0):e.animated&&!n.once&&a()}(e,window.pageYOffset)})},Z=function(e){for(var t=0,n=0;e&&!isNaN(e.offsetLeft)&&!isNaN(e.offsetTop);)t+=e.offsetLeft-("BODY"!=e.tagName?e.scrollLeft:0),n+=e.offsetTop-("BODY"!=e.tagName?e.scrollTop:0),e=e.offsetParent;return{top:n,left:t}},ee=function(e,t,n){var o=e.getAttribute("data-aos-"+t);if(void 0!==o){if("true"===o)return!0;if("false"===o)return!1}return o||n},te=function(e,t){return e.forEach(function(e,n){var o=ee(e.node,"mirror",t.mirror),i=ee(e.node,"once",t.once),a=ee(e.node,"id"),r=t.useClassNames&&e.node.getAttribute("data-aos"),c=[t.animatedClassName].concat(r?r.split(" "):[]).filter(function(e){return"string"==typeof e});t.initClassName&&e.node.classList.add(t.initClassName),e.position={in:function(e,t,n){var o=window.innerHeight,i=ee(e,"anchor"),a=ee(e,"anchor-placement"),r=Number(ee(e,"offset",a?0:t)),c=a||n,s=e;i&&document.querySelectorAll(i)&&(s=document.querySelectorAll(i)[0]);var u=Z(s).top-o;switch(c){case"top-bottom":break;case"center-bottom":u+=s.offsetHeight/2;break;case"bottom-bottom":u+=s.offsetHeight;break;case"top-center":u+=o/2;break;case"center-center":u+=o/2+s.offsetHeight/2;break;case"bottom-center":u+=o/2+s.offsetHeight;break;case"top-top":u+=o;break;case"bottom-top":u+=o+s.offsetHeight;break;case"center-top":u+=o+s.offsetHeight/2}return u+r}(e.node,t.offset,t.anchorPlacement),out:o&&function(e,t){window.innerHeight;var n=ee(e,"anchor"),o=ee(e,"offset",t),i=e;return n&&document.querySelectorAll(n)&&(i=document.querySelectorAll(n)[0]),Z(i).top+i.offsetHeight-o}(e.node,t.offset)},e.options={once:i,mirror:o,animatedClassNames:c,id:a}}),e},ne=function(){var e=document.querySelectorAll("[data-aos]");return Array.prototype.map.call(e,function(e){return{node:e}})},oe=[],ie=!1,ae={offset:120,delay:0,easing:"ease",duration:400,disable:!1,once:!1,mirror:!1,anchorPlacement:"top-bottom",startEvent:"DOMContentLoaded",animatedClassName:"aos-animate",initClassName:"aos-init",useClassNames:!1,disableMutationObserver:!1,throttleDelay:99,debounceDelay:50},re=function(){return document.all&&!window.atob},ce=function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&(ie=!0),ie&&(oe=te(oe,ae),X(oe),window.addEventListener("scroll",y(function(){X(oe,ae.once)},ae.throttleDelay)))},se=function(){if(oe=ne(),de(ae.disable)||re())return ue();ce()},ue=function(){oe.forEach(function(e,t){e.node.removeAttribute("data-aos"),e.node.removeAttribute("data-aos-easing"),e.node.removeAttribute("data-aos-duration"),e.node.removeAttribute("data-aos-delay"),ae.initClassName&&e.node.classList.remove(ae.initClassName),ae.animatedClassName&&e.node.classList.remove(ae.animatedClassName)})},de=function(e){return!0===e||"mobile"===e&&U.mobile()||"phone"===e&&U.phone()||"tablet"===e&&U.tablet()||"function"==typeof e&&!0===e()};return{init:function(e){return ae=I(ae,e),oe=ne(),ae.disableMutationObserver||_.isSupported()||(console.info('\n aos: MutationObserver is not supported on this browser,\n code mutations observing has been disabled.\n You may have to call "refreshHard()" by yourself.\n '),ae.disableMutationObserver=!0),ae.disableMutationObserver||_.ready("[data-aos]",se),de(ae.disable)||re()?ue():(document.querySelector("body").setAttribute("data-aos-easing",ae.easing),document.querySelector("body").setAttribute("data-aos-duration",ae.duration),document.querySelector("body").setAttribute("data-aos-delay",ae.delay),-1===["DOMContentLoaded","load"].indexOf(ae.startEvent)?document.addEventListener(ae.startEvent,function(){ce(!0)}):window.addEventListener("load",function(){ce(!0)}),"DOMContentLoaded"===ae.startEvent&&["complete","interactive"].indexOf(document.readyState)>-1&&ce(!0),window.addEventListener("resize",$(ce,ae.debounceDelay,!0)),window.addEventListener("orientationchange",$(ce,ae.debounceDelay,!0)),oe)},refresh:ce,refreshHard:se}}); /***/ }), /***/ "./scripts/modules/anchor.js": /*!***********************************!*\ !*** ./scripts/modules/anchor.js ***! \***********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ init; } /* harmony export */ }); /* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery"); /* provided dependency */ var $ = __webpack_require__(/*! jquery */ "jquery"); function init() { jQuery('a[href^="#"]').on('click',function(e) { e.preventDefault(); var target = $(this).attr("href"); if($(target).length > 0){ $('html,body').animate({scrollTop: $(target).offset().top},'slow'); } }); } /***/ }), /***/ "./scripts/modules/banner.js": /*!***********************************!*\ !*** ./scripts/modules/banner.js ***! \***********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ init; } /* harmony export */ }); /* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery"); /* eslint-disable */ function init() { jQuery('.banner-close').on('click',function () { jQuery('.banner_header').hide(); }) } /***/ }), /***/ "./scripts/modules/cobertura.js": /*!**************************************!*\ !*** ./scripts/modules/cobertura.js ***! \**************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ init; } /* harmony export */ }); /* harmony import */ var leaflet__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! leaflet */ "../../node_modules/leaflet/dist/leaflet-src.js"); /* harmony import */ var leaflet__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(leaflet__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var leaflet_search__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! leaflet-search */ "../../node_modules/leaflet-search/dist/leaflet-search.src.js"); /* harmony import */ var leaflet_search__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(leaflet_search__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var leaflet_markercluster__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! leaflet.markercluster */ "../../node_modules/leaflet.markercluster/dist/leaflet.markercluster-src.js"); /* harmony import */ var leaflet_markercluster__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(leaflet_markercluster__WEBPACK_IMPORTED_MODULE_2__); /* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery"); /* provided dependency */ var $ = __webpack_require__(/*! jquery */ "jquery"); /* eslint-disable */ function init() { if(jQuery('#map').length == 0) { return; } var dirPath = window.location.origin; var limitesEuropa = leaflet__WEBPACK_IMPORTED_MODULE_0___default().latLngBounds( leaflet__WEBPACK_IMPORTED_MODULE_0___default().latLng(35, -24), // Latitud, Longitud del suroeste de Europa leaflet__WEBPACK_IMPORTED_MODULE_0___default().latLng(53, 21) // Latitud, Longitud del noreste de Europa ); // config map var config = { minZoom: 5.2, maxZoom: 9, preferCanvas: true, zoomControl: false, }; var zoom = 5.2; var lat = 44.43513228190882; var lng = -0.9057117782019052; var map = leaflet__WEBPACK_IMPORTED_MODULE_0___default().map("map", config).setView([lat, lng], zoom); map.fitBounds(limitesEuropa); map.setMaxBounds(limitesEuropa); map.on("drag", function () { map.panInsideBounds(limitesEuropa, { animate: false }); }); // primer array abajo izquierda. // segundo array arriba derecha. // 1º cuanto mas alto más arriba. 2º cuanto mas bajo más izquierda var latLngBounds = leaflet__WEBPACK_IMPORTED_MODULE_0___default().latLngBounds([ [34.15, -31.35], // abajo izquierda [53.88, 28.93] ]); leaflet__WEBPACK_IMPORTED_MODULE_0___default().imageOverlay( dirPath + "/wp-content/themes/paack/resources/assets/images/map/map2.svg", latLngBounds, { opacity: 1, interactive: false, } ).addTo(map); var allPoints = []; function fetchLocations() { $.ajax({ type : "GET", dataType : "json", url : "/wp-admin/admin-ajax.php", data : {action: "get_locations"}, success: function(data) { if (data.length > 0) { data.forEach(function (val) { if(val.latitud != null && val.longitud != null){ allPoints.push({ name: val.title, ciudad: val.ciudad, pais: val.pais, lat: val.latitud, desc: val.desc, lng: val.longitud, latlng: [ parseFloat(val.latitud), parseFloat(val.longitud) ], category: "coming", temperatura: val.temperatura, sostenible: val.sostenible, distribucion: val.distribucion, coming: val.coming, }); } }); } setMap(allPoints); // Manejar los checkboxes para filtrar los marcadores var allFilterCheckboxes = { distribution: document.getElementById("distributionCheckbox"), coming: document.getElementById("comingCheckbox"), temperature: document.getElementById("temperatureCheckbox"), sustainability: document.getElementById("sustainabilityCheckbox"), espana: document.getElementById("spainCheckbox"), francia: document.getElementById("franceCheckbox"), portugal: document.getElementById("portugalCheckbox"), italia: document.getElementById("italyCheckbox"), }; var filterCheckboxesCenters = { distribution: allFilterCheckboxes.distribution, coming: allFilterCheckboxes.coming, temperature: allFilterCheckboxes.temperature, sustainability: allFilterCheckboxes.sustainability, }; var filterCheckboxesCountry = { espana: allFilterCheckboxes.espana, francia: allFilterCheckboxes.francia, portugal: allFilterCheckboxes.portugal, italia: allFilterCheckboxes.italia, }; // Agregar eventos de cambio a los checkboxes for (var checkboxId in allFilterCheckboxes) { if (allFilterCheckboxes.hasOwnProperty(checkboxId)) { allFilterCheckboxes[checkboxId].addEventListener("change", function() { resetIcons(markers); var selectedCenters = Object.keys(filterCheckboxesCenters).filter( function (id) { return filterCheckboxesCenters[id].checked; } ); var selectedCountries = Object.keys(filterCheckboxesCountry).filter( function (id) { return filterCheckboxesCountry[id].checked; } ); var layers_by_country = []; markers.forEach(function (marker) { var isVisible = false; if (selectedCenters.length === 0 && selectedCountries.length === 0) { isVisible = true; } else { var contain_center = selectedCenters.length === 0; selectedCenters.forEach(function (center) { if (center === "temperature" && marker.temperatura) { contain_center = true; } if (center === "sustainability" && marker.sostenible) { contain_center = true; } if (center === "distribution" && marker.distribucion) { contain_center = true; } if (center === "coming" && marker.coming) { contain_center = true; } }); var in_country = selectedCountries.length === 0; selectedCountries.forEach(function (country) { if (country === marker.country) { in_country = true; } }); isVisible = contain_center && in_country; } if (isVisible) { if (!layers_by_country[marker.country]) { layers_by_country[marker.country] = []; } layers_by_country[marker.country].push(marker); } }); allMarkerClusterGroups.clearLayers(); Object.keys(layers_by_country).forEach(function (key) { var markerClusterGroup = leaflet__WEBPACK_IMPORTED_MODULE_0___default().markerClusterGroup({ zoomToBoundsOnClick: true, showCoverageOnHover: false, disableClusteringAtZoom: 7, maxClusterRadius: 120 }); var country = layers_by_country[key]; country.forEach(function (marker) { markerClusterGroup.addLayer(marker) }) markerClusterGroup.addTo(map); allMarkerClusterGroups.addLayer(markerClusterGroup); }); }); } } setSearch(); jQuery('#map-show-filters').addClass('show'); jQuery('#searcherMap').addClass('show'); jQuery('.legend').addClass('show'); }, error: function (error) { console.error("Error en la solicitud AJAX: ", error); }, }) } var allMarkerClusterGroups = leaflet__WEBPACK_IMPORTED_MODULE_0___default().layerGroup(); var markers = []; function setMap(allPoints) { var LeafIcon = leaflet__WEBPACK_IMPORTED_MODULE_0___default().Icon.extend({ options: { iconSize: [12, 12], }, }); var darkIcon = new LeafIcon({ iconUrl: dirPath + "/wp-content/themes/paack/resources/assets/images/map/dark_circle.svg", }), blueIcon = new LeafIcon({ iconUrl: dirPath + "/wp-content/themes/paack/resources/assets/images/map/blue_circle.svg", }), yellowIcon = new LeafIcon({ iconUrl: dirPath + "/wp-content/themes/paack/resources/assets/images/map/yellow_circle.svg", }), greenIcon = new LeafIcon({ iconUrl: dirPath + "/wp-content/themes/paack/resources/assets/images/map/green_circle.svg", }); leaflet__WEBPACK_IMPORTED_MODULE_0___default().control .zoom({ position: "bottomright", }) .addTo(map); leaflet__WEBPACK_IMPORTED_MODULE_0___default().tileLayer( "https://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}{r}.png", { attribution: "© Paack", } ).addTo(map); // Create a LayerGroup var valoresLeyenda = JSON.parse(document.getElementById('info-div').dataset.valores_leyenda); var layers_by_country = []; allPoints.forEach(function (item) { var divCirles = ""; var icon = darkIcon; if (item.temperatura === true) { divCirles += '

' + valoresLeyenda.azul + '

'; } if (item.sostenible === true) { divCirles += '

' + valoresLeyenda.verde + '

'; } if (item.distribucion === true) { divCirles += '

' + valoresLeyenda.negro + '

'; } if (item.coming === true) { divCirles += '

' + valoresLeyenda.amarillo + '

'; } if (item.temperatura === true) { icon = blueIcon } else if (item.sostenible === true) { icon = greenIcon } else if (item.coming === true) { icon = yellowIcon } item.name = item.name.replace("–", "|"); var marker = leaflet__WEBPACK_IMPORTED_MODULE_0___default().marker([item.lat, item.lng], { title: item.name.replace("–", "-"), type: item.category, icon: icon, properties: { name: item.name }, }).bindPopup( '

' + item.name + '

' + divCirles + '
', { closeButton: false } ); marker.coming = item.coming; marker.distribucion = item.distribucion; marker.sostenible = item.sostenible; marker.temperatura = item.temperatura; marker.country = item.pais; marker.properties = { name: item.name.replace("–", "-"), }; if (!layers_by_country[item.pais]) { layers_by_country[item.pais] = []; // Inicializar como un array vacío si no existe } layers_by_country[item.pais].push(marker); marker.category = item.category; markers.push(marker); }); allMarkerClusterGroups.clearLayers(); Object.keys(layers_by_country).forEach(function (key) { var markerClusterGroup = leaflet__WEBPACK_IMPORTED_MODULE_0___default().markerClusterGroup({ zoomToBoundsOnClick: true, showCoverageOnHover: false, disableClusteringAtZoom: 7, maxClusterRadius: 120, }); var country = layers_by_country[key]; country.forEach(function (marker) { markerClusterGroup.addLayer(marker) }) markerClusterGroup.addTo(map); allMarkerClusterGroups.addLayer(markerClusterGroup); }); markers.forEach(function (marker) { marker.on("click", function () { openMarkerModal(marker) }); }); $("#map-show-filters").on("click", function () { $("#map-filters").removeClass("hidden"); if(!$('.legend').hasClass('closed') || !$('.legend').hasClass('closed_mobile')){ $('.legend').addClass('closed_mobile'); } }); $("#map-hide-filters").on("click", function () { $("#map-filters").addClass("hidden"); $('.legend').removeClass('closed_mobile'); }); $('body').on('click','.leaflet-popup-close-button',function(e){ e.preventDefault(); document.getElementById("info-div").classList.add("opacity-0"); document.getElementById("info-div").classList.remove("opacity-1"); jQuery('#info-div').removeClass('marker_show'); resetIcons(markers); }) } function resetIcons(markers){ markers.forEach(function (marker) { var icon = ""; if (marker.temperatura === true) { icon = dirPath + "/wp-content/themes/paack/resources/assets/images/map/blue_circle.svg"; } else if (marker.sostenible === true) { icon = dirPath + "/wp-content/themes/paack/resources/assets/images/map/green_circle.svg"; } else if (marker.coming === true) { icon = dirPath + "/wp-content/themes/paack/resources/assets/images/map/yellow_circle.svg"; } else { icon = dirPath + "/wp-content/themes/paack/resources/assets/images/map/dark_circle.svg"; } marker.setIcon( leaflet__WEBPACK_IMPORTED_MODULE_0___default().icon({ iconUrl: icon, iconSize: 12, }) ); }); } function setLegend() { /* legend */ var legend = leaflet__WEBPACK_IMPORTED_MODULE_0___default().control({ position: "bottomleft", }); var valoresLeyenda2 = JSON.parse(document.getElementById('info-div').dataset.valores_leyenda); var div = leaflet__WEBPACK_IMPORTED_MODULE_0___default().DomUtil.create("div", "legend"); var color = ["#46A2DB", "#009844", "#0A253C", "#FBD259"]; var label = [ valoresLeyenda2.azul, valoresLeyenda2.verde, valoresLeyenda2.negro, valoresLeyenda2.amarillo ]; var rows = []; legend.onAdd = function () { color.map(function (item, index) { rows.push(("\n
\n " + (label[index]) + "\n
") ); }); var stringleyenda = document.getElementById('ms-leyenda').innerHTML; div.innerHTML = '

'+stringleyenda+'

' + rows.join("") + '
'; div.innerHTML += '
'+stringleyenda+'
'; return div; }; jQuery('body').on('click','.close-legend',function(e){ jQuery('.legend').addClass('closed'); }) jQuery('body').on('click','.legend-collapse',function(){ jQuery('.legend').removeClass('closed'); jQuery('.legend').removeClass('closed_mobile'); }) legend.addTo(map); /* legend */ } var searchControl = null; function setSearch() { if(searchControl != null){ map.removeControl(searchControl); } var stringbuscar = document.getElementById('ms-buscar').innerHTML; var stringubicacion = document.getElementById('ms-ubicacion').innerHTML; searchControl = new (leaflet__WEBPACK_IMPORTED_MODULE_0___default().Control).Search({ position: "topleft", layer: allMarkerClusterGroups, container: "searcherMap", initial: false, collapsed: false, textPlaceholder: stringbuscar, marker: false, textErr: stringubicacion, moveToLocation: function(latlng, title, map) { searchControl._input.blur(); document.getElementById('map').focus(); var marker = markers.find(function(marker) { return marker.getLatLng().equals(latlng); }); if (marker) { // Abre el modal openMarkerModal(marker) } map.setView(latlng, 7); } }) map.addControl(searchControl); } function openMarkerModal(marker){ resetIcons(markers); if (map.getZoom() == config.minZoom) { map.zoomIn(); } var info = marker.getPopup().getContent(); // Obtiene la información del marcador document.getElementById("info-div").classList.remove("opacity-0"); document.getElementById("info-div").classList.add("opacity-1"); document.getElementById("info-div").innerHTML = info; // Muestra la información en el div var icon = ""; if (marker.temperatura === true) { icon = dirPath + "/wp-content/themes/paack/resources/assets/images/map/Mark-blue.svg"; } else if (marker.sostenible === true) { icon = dirPath + "/wp-content/themes/paack/resources/assets/images/map/Mark-green.svg"; } else if (marker.coming === true) { icon = dirPath + "/wp-content/themes/paack/resources/assets/images/map/Mark-yellow.svg"; } else { icon = dirPath + "/wp-content/themes/paack/resources/assets/images/map/Mark-dark.svg"; } marker.setIcon( leaflet__WEBPACK_IMPORTED_MODULE_0___default().icon({ iconUrl: icon, iconSize: 30, className: 'selectedMarker', }) ); jQuery('.legend').addClass('closed_mobile'); jQuery('#info-div').addClass('marker_show'); } setLegend(); fetchLocations(); jQuery('.clear-filters').on('click',function(){ var inputs = jQuery('#map-filters').find('input[type="checkbox"]'); inputs.each(function(){ if(jQuery(this).is(':checked')){ jQuery(this).trigger('click'); } }) }) } /***/ }), /***/ "./scripts/modules/custom_selects_location_form.js": /*!*********************************************************!*\ !*** ./scripts/modules/custom_selects_location_form.js ***! \*********************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ init; } /* harmony export */ }); /* provided dependency */ var $ = __webpack_require__(/*! jquery */ "jquery"); /* eslint-disable */ function init() { var form = $('.wpcf7-form'); if(form.length == 0) { return; } var country = form.find('select#pais'); var states = form.find('.state_select'); var states_select = form.find('.wpcf7-state_select'); var cities = form.find('.city_select'); var cities_select = cities.find('.wpcf7-city_select'); var select_cities_es = form.find('.city_select_es select'); var options_cities_es = select_cities_es.html(); var select_cities_fr = form.find('.city_select_fr select'); var options_cities_fr = select_cities_fr.html(); var select_cities_pt = form.find('.city_select_pt select'); var options_cities_pt = select_cities_pt.html(); var select_cities_it = form.find('.city_select_it select'); var options_cities_it = select_cities_it.html(); country.on('change',function(){ var country_code = $(this).val(); if(country_code == 'Spain' || country_code == 'España'){ country_code = 'es'; } else if(country_code == 'Italy' || country_code == 'Italia'){ country_code = 'it'; } else if(country_code == 'French' || country_code == 'Francia'){ country_code = 'fr'; } else if(country_code == 'Portugal'){ country_code = 'pt'; } states.removeClass('show'); states_select.val(''); cities.removeClass('show'); cities_select.val(''); if(country_code != ""){ var states$1 = form.find('.state_select_' + country_code); states$1.addClass('show'); } }) states_select.on('change', function(){ var selectedValue = $(this).val(); cities.removeClass('show'); cities_select.val(''); var country_code = country.val(); if(country_code == 'Spain' || country_code == 'España'){ country_code = 'es'; select_cities_es.html(options_cities_es); } else if(country_code == 'Italy' || country_code == 'Italia'){ country_code = 'it'; select_cities_it.html(options_cities_it); } else if(country_code == 'France' || country_code == 'Francia'){ country_code = 'fr'; select_cities_fr.html(options_cities_fr); } else if(country_code == 'Portugal'){ country_code = 'pt'; select_cities_pt.html(options_cities_pt); } if(country_code != "" && selectedValue != ""){ var cities_selected = form.find('.city_select_' + country_code); cities_selected.addClass('show'); var first_option = cities_selected.find('option:first') var first_option_text = first_option.text(); first_option.text('Loading...'); setTimeout(function(){ get_city_select(cities_selected, selectedValue); first_option.text(first_option_text); }, 0); } }) } function get_city_select(cities, state){ var select_cities = cities.find('.wpcf7-city_select'); select_cities.find('option:not([data-state="'+ state +'"]):not(:first)').remove(); } /***/ }), /***/ "./scripts/modules/footer.js": /*!***********************************!*\ !*** ./scripts/modules/footer.js ***! \***********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ init; } /* harmony export */ }); /* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery"); /* provided dependency */ var $ = __webpack_require__(/*! jquery */ "jquery"); /* eslint-disable */ function init() { // Dropdown jQuery(".accordion-link").on("click", function () { var id = jQuery(this).data("reference"); var iconPlus = jQuery(this).find("svg path.svg-plus"); var iconMinus = jQuery(this).find("svg path.svg-minus"); var contents = jQuery('.accordion-content:not('+ id +')'); contents.each(function(){ jQuery(this).slideToggle(200).addClass("hidden").hide(); var parent = jQuery(this).parent() var iconPlusItem = parent.find("svg path.svg-plus"); var iconMinusItem = parent.find("svg path.svg-minus") jQuery(iconMinusItem).removeClass("opacity-1"); jQuery(iconMinusItem).addClass("opacity-0"); jQuery(iconPlusItem).removeClass("opacity-0"); jQuery(iconPlusItem).addClass("opacity-1"); }) if (jQuery(id).hasClass("hidden")) { jQuery(id).slideToggle(200).removeClass("hidden"); jQuery(iconPlus).removeClass("opacity-1"); jQuery(iconPlus).addClass("opacity-0"); jQuery(iconMinus).removeClass("opacity-0"); jQuery(iconMinus).addClass("opacity-1"); } else { jQuery(id).slideToggle(200).addClass("hidden"); jQuery(iconMinus).removeClass("opacity-1"); jQuery(iconMinus).addClass("opacity-0"); jQuery(iconPlus).removeClass("opacity-0"); jQuery(iconPlus).addClass("opacity-1"); } }); // Read more normal jQuery(".toggle-button").on("click", function (e) { e.preventDefault(); var buttonText = jQuery(this).text().trim(); var textOpen = jQuery(this).data("open"); var textClose = jQuery(this).data("close"); jQuery(this).prev(".hidden-content").slideToggle(200); jQuery(this).next().toggleClass("rotate-180"); jQuery(this).html(buttonText === textOpen ? textClose : textOpen); }); // Read more normal jQuery(".toggle-button-reverse").on("click", function (e) { e.preventDefault(); var buttonText = jQuery(this).text().trim(); var textOpen = jQuery(this).data("open"); var textClose = jQuery(this).data("close"); jQuery(this).next().next(".hidden-content").slideToggle(200); jQuery(this).next().toggleClass("rotate-180"); jQuery(this).html(buttonText === textOpen ? textClose : textOpen); }); jQuery(".toggle-button, .toggle-button-reverse").hover(function () { jQuery(this).next().toggleClass("text-neutrals-700"); }); // Accordion jQuery(function () { // Cache selectors var $accordion = $(".js-accordion"); var $allPanels = $(".accordion-panel").hide(); var $allItems = $(".accordion-item"); // Event listeners $accordion.on("click", ".accordion-toggle", function () { // Toggle the current accordion panel and close others $allPanels.slideUp(); $allItems.removeClass("faq-is-open"); if (jQuery(this).next().is(":visible")) { jQuery(".accordion-panel").slideUp(); jQuery(".accordion-icon").removeClass("rotate-180"); } else { jQuery(this) .next() .slideDown() .closest(".accordion-item") .addClass("faq-is-open"); jQuery(this).children("svg.accordion-icon").addClass("rotate-180"); } return false; }); }); // Forms jQuery("#flexCheckIndeterminate").prop("indeterminate", true); jQuery("#flexCheckIndeterminateDisabled").prop("indeterminate", true); // Tabs document .querySelectorAll("[data-tabs-toggle]") .forEach(function (tabsToggleEl) { var tabsToggleElementsId = tabsToggleEl.getAttribute("id"); var tabsToggleElements = document.querySelectorAll( "#" + tabsToggleElementsId + ' [role="tab"]' ); var activeTabToggleEl = null; var activeTabContentEl = null; tabsToggleElements.forEach(function (tabToggleEl) { tabToggleEl.addEventListener("click", function (event) { var tabToggleEl = event.target; var tabTargetSelector = tabToggleEl.getAttribute("data-tabs-target"); var tabContentEl = document.querySelector(tabTargetSelector); // don't do anything if it's already active if (tabToggleEl !== activeTabToggleEl) { // find currently active tab toggle and content if not set if (!activeTabToggleEl && !activeTabContentEl) { activeTabToggleEl = document.querySelector( "#" + tabsToggleElementsId + ' [aria-selected="true"]' ); activeTabContentEl = document.querySelector( activeTabToggleEl.getAttribute("data-tabs-target") ); } // show and activate tab tabToggleEl.classList.add("active"); tabToggleEl.setAttribute("aria-selected", true); tabContentEl.classList.remove("hidden"); // hide and deactive currently active tab toggle and content activeTabToggleEl.setAttribute("aria-selected", false); activeTabToggleEl.classList.remove("active"); activeTabContentEl.classList.add("hidden"); // set currently active toggle and content tabs activeTabToggleEl = tabToggleEl; activeTabContentEl = tabContentEl; } }); }); }); jQuery(window).on("load", function () { function goToByScroll(id) { jQuery("html, body").animate( { scrollTop: jQuery("#" + id).offset().top - 10, }, 1000 ); } if (window.location.hash != "") { goToByScroll(window.location.hash.substr(1)); } }); } /***/ }), /***/ "./scripts/modules/forms.js": /*!**********************************!*\ !*** ./scripts/modules/forms.js ***! \**********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ init; } /* harmony export */ }); /* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery"); /* provided dependency */ var $ = __webpack_require__(/*! jquery */ "jquery"); /* eslint-disable */ function init() { var contacto = jQuery('*[data-id="contacto"]'); var empresa = jQuery('*[data-id="empresa"]'); var actividad = jQuery('*[data-id="actividad"]'); var fieldName = jQuery("#username"); var fieldEmail = jQuery("#email"); var fieldPhone = jQuery("#phone"); var fieldCompany = jQuery("#company"); var fieldIndustria = jQuery("#industria"); var fieldPuntorecogida = jQuery("#puntorecogida"); var fieldUbicacion = jQuery("#ubicacion"); var fieldPais = jQuery("#pais"); var fieldCity = jQuery("#city"); jQuery(".js-form-step1").on("click", function () { if (validateFormStep1()) { jQuery("#formstep").val("empresa"); contacto.addClass("wpcf7cf-hidden").hide(); empresa.removeClass("wpcf7cf-hidden").show(); jQuery(".form-items-steps p").removeClass("active"); jQuery(".form-items-steps p:nth-child(2)").addClass("active"); var form = jQuery(this).closest('.block-form'); $([document.documentElement, document.body]).animate({ scrollTop: jQuery(form).offset().top - 74 }, 1000); } }); jQuery(".js-form-step2").on("click", function () { if (validateFormStep2()) { jQuery("#formstep").val("actividad"); empresa.addClass("wpcf7cf-hidden").hide(); actividad.removeClass("wpcf7cf-hidden").show(); jQuery(".form-items-steps p").removeClass("active"); jQuery(".form-items-steps p:nth-child(3)").addClass("active"); var form = jQuery(this).closest('.block-form'); $([document.documentElement, document.body]).animate({ scrollTop: jQuery(form).offset().top -74 }, 1000); } }); jQuery(".js-back-form-step1").on("click", function () { jQuery("#formstep").val("contacto"); contacto.addClass("wpcf7cf-hidden").show(); empresa.removeClass("wpcf7cf-hidden").hide(); jQuery(".form-items-steps p").removeClass("active"); jQuery(".form-items-steps p:nth-child(1)").addClass("active"); var form = jQuery(this).closest('.block-form'); $([document.documentElement, document.body]).animate({ scrollTop: jQuery(form).offset().top - 74 }, 1000); }); jQuery(".js-back-form-step2").on("click", function () { jQuery("#formstep").val("empresa"); empresa.addClass("wpcf7cf-hidden").show(); actividad.removeClass("wpcf7cf-hidden").hide(); jQuery(".form-items-steps p").removeClass("active"); jQuery(".form-items-steps p:nth-child(2)").addClass("active"); var form = jQuery(this).closest('.block-form'); $([document.documentElement, document.body]).animate({ scrollTop: jQuery(form).offset().top -74 }, 1000); }); jQuery('.block-form select').on('change', function() { if (jQuery(this).val() != '') { jQuery(this).addClass('selected'); } else { jQuery(this).removeClass('selected'); } }); function validateFormStep1() { if (fieldName.val() === "") { showError(fieldName); } else{ removeError(fieldName); } if (fieldPhone.val() === "") { showError(fieldPhone); } else{ removeError(fieldPhone); } if (IsEmail(fieldEmail.val()) === false) { showError(fieldEmail); } else{ removeError(fieldEmail); } if (fieldName.val() !== "" && fieldPhone.val() !== "" && IsEmail(fieldEmail.val()) !== false) { return true; } return false; } function validateFormStep2() { if (fieldCompany.val() === "") { showError(fieldCompany); } else{ removeError(fieldCompany); } if (fieldIndustria.val() === "") { showError(fieldIndustria); } else{ removeError(fieldIndustria); } if (fieldPuntorecogida.val() === "") { showError(fieldPuntorecogida); } else{ removeError(fieldPuntorecogida); } if (fieldUbicacion.val() === "") { showError(fieldUbicacion); } else{ removeError(fieldUbicacion); } if (fieldPais.val() === "") { showError(fieldPais); } else{ removeError(fieldPais); } var fieldProvince = jQuery('.state_select.show .wpcf7-state_select'); if (fieldProvince.val() === "") { showError(fieldProvince); } else{ removeError(fieldProvince); } var fieldCity = jQuery('.city_select.show .wpcf7-city_select'); if (fieldCity.val() === "") { showError(fieldCity); } else{ removeError(fieldCity); } if ( fieldCompany.val() !== "" && fieldIndustria.val() !== "" && fieldPuntorecogida.val() !== "" && fieldUbicacion.val() !== "" && fieldPais.val() !== "" && fieldProvince.val() !== "" && fieldCity.val() !== "" ) { return true; } return false; } function showError(field) { if(!field.hasClass("wpcf7-not-valid")){ field.addClass("wpcf7-not-valid"); var lang = $('html').attr('lang'); if(lang == 'en-US') { field.after( '' ); } else { field.after( '' ); } } } function removeError(field) { if(field.hasClass("wpcf7-not-valid")){ field.removeClass("wpcf7-not-valid"); field.next('.wpcf7-not-valid-tip').remove(); } } function IsEmail(email) { var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if (!regex.test(email)) { return false; } else { return true; } } } /***/ }), /***/ "./scripts/modules/menu.js": /*!*********************************!*\ !*** ./scripts/modules/menu.js ***! \*********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ init; } /* harmony export */ }); /* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery"); /* eslint-disable */ function init() { if (jQuery(".c-header").attr("data-mode") !== "dark") { var deltaInit = 300; jQuery(window).on("scroll", function () { var scroll = jQuery(window).scrollTop(); if (scroll > deltaInit) { jQuery(".c-header").addClass("scrolled").attr("data-mode", "dark"); } else { jQuery(".c-header").removeClass("scrolled").attr("data-mode", "light"); } }); } jQuery("#menu-header-principal-nav > li.menu-item").hover( function () { if (jQuery(this).hasClass("menu-item-has-children")) { jQuery(".c-header").addClass("scrolled"); jQuery(".sub-menu-wrapper").removeClass("open"); jQuery(this).children(".sub-menu-wrapper").addClass("open"); } else { jQuery(".c-header").removeClass("scrolled"); jQuery(".sub-menu-wrapper").removeClass("open"); } }, function () { } ); jQuery("#menu-header-principal-nav .sub-menu-wrapper").on( "mouseleave", function () { jQuery(".c-header").removeClass("scrolled"); jQuery(".sub-menu-wrapper").removeClass("open"); } ); } /***/ }), /***/ "./scripts/modules/modal.js": /*!**********************************!*\ !*** ./scripts/modules/modal.js ***! \**********************************/ /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { /* provided dependency */ var $ = __webpack_require__(/*! jquery */ "jquery"); $(function() { $('.lity-custom-close').on('click',function(){ $('.lity-close').trigger('click'); }); $(document).on('lity:open',function() { if ($('.custom-close')) { $('.lity-close').hide(); } }); }); /***/ }), /***/ "./scripts/modules/nav_blog.js": /*!*************************************!*\ !*** ./scripts/modules/nav_blog.js ***! \*************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ init; } /* harmony export */ }); /* provided dependency */ var $ = __webpack_require__(/*! jquery */ "jquery"); /* eslint-disable */ function init() { if($('.nav-categories').length == 0) { return; } var scrollDuration = 300; var leftPaddle = document.getElementsByClassName('left-paddle'); var rightPaddle = document.getElementsByClassName('right-paddle'); var contenedor = $('.menu_container'); var contenedorOffset = contenedor.offset().left; var elementos = contenedor.find('.link'); var posElementos = []; // Calcular las posiciones relativas de los elementos en relación con el contenedor elementos.each(function() { var data = []; data['left'] = $(this).offset().left - contenedorOffset; data['width'] = $(this).width(); posElementos.push(data); }); $('window').on('resize',function(){ elementos = $('.menu_container').find('.link'); posElementos = []; // Calcular las posiciones relativas de los elementos en relación con el contenedor elementos.each(function() { var data = []; data['left'] = $(this).offset().left; data['width'] = $(this).width(); posElementos.push(data); }); }) // scroll to right $(rightPaddle).on('click', function () { var scrollDerecha = contenedor.scrollLeft(); for (var i = 0; i < posElementos.length; i++) { var pos_element = posElementos[i]['left'] + posElementos[i]['width']; if (pos_element > contenedor.width() + scrollDerecha) { contenedor.animate({ scrollLeft: posElementos[i]['left'] }, scrollDuration); break; } } }); // scroll to left $(leftPaddle).on('click', function () { var scrollIzquierda = contenedor.scrollLeft(); for (var i = posElementos.length - 1; i >= 0; i--) { if (posElementos[i]['left'] < scrollIzquierda) { var scroll_right = posElementos[i]['left'] - contenedor.width() + posElementos[i]['width']; contenedor.animate({ scrollLeft: scroll_right}, scrollDuration); break; } } }); var nav_active = contenedor.find('.link.active'); if(nav_active.length > 0){ var posicion = nav_active.position().left - contenedorOffset; contenedor.scrollLeft(posicion); } } /***/ }), /***/ "./scripts/modules/slider.js": /*!***********************************!*\ !*** ./scripts/modules/slider.js ***! \***********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ init; } /* harmony export */ }); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! jquery */ "jquery"); /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var swiper_element_bundle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! swiper/element/bundle */ "../../node_modules/swiper/swiper-element-bundle.mjs"); /* eslint-disable */ // import function to register Swiper custom elements function init() { (0,swiper_element_bundle__WEBPACK_IMPORTED_MODULE_1__.register)(); if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".testimonialsSwiper").length) { // swiper element var swiperElTestimonials = document.querySelectorAll(".testimonialsSwiper"); swiperElTestimonials.forEach(function (swiperElTestimonial) { var parent = swiperElTestimonial.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); // swiper parameters var swiperParamsTestimonials = { slidesPerView: 1, watchOverflow: true, navigation: { nextEl: next_element, prevEl: prev_element, }, autoHeight: true, }; // now we need to assign all parameters to Swiper element Object.assign(swiperElTestimonial, swiperParamsTestimonials); // and now initialize it swiperElTestimonial.initialize(); }); } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".logosTestimonialSwiper").length) { // swiper element var swiperElLogosTestimonials = document.querySelectorAll(".logosTestimonialSwiper"); swiperElLogosTestimonials.forEach(function (swiperElLogoTestimonial) { var num_items = swiperElLogoTestimonial.getAttribute('data-items'); var slidesPerViewDesktop = (num_items < 7) ? num_items : 7; var slidesPerViewTablet = (num_items < 5) ? num_items : 5; var slidesPerViewMobile = (num_items < 3) ? num_items : 3; // swiper parameters var swiperParamsLogoTestimonials = { slidesPerView: slidesPerViewMobile, watchOverflow: true, loop: true, spaceBetween: 16, centerInsufficientSlides: true, autoplay: { delay: 2000, disableOnInteraction: false, }, breakpoints: { 640: { slidesPerView: slidesPerViewTablet, }, 767: { slidesPerView: slidesPerViewDesktop, spaceBetween: 32, } } }; // now we need to assign all parameters to Swiper element Object.assign(swiperElLogoTestimonial, swiperParamsLogoTestimonials); // and now initialize it swiperElLogoTestimonial.initialize(); }); } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".swiper-equal-features").length) { var featuresSwiperSlider = document.querySelectorAll(".swiper-equal-features"); featuresSwiperSlider.forEach(function (swiperElfeatures) { var parent = swiperElfeatures.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); var container = parent.parentElement; var pagination_feature = container.querySelector(".equal-swiper-pagination"); var swiperParamsfeatures = { spaceBetween: 24, slidesPerView: 1, watchOverflow: true, observer: true, observeParents: true, breakpoints: { 500: { slidesPerView: 2, }, 768: { slidesPerView: 3, pagination: { enabled: true, } }, 1200: { slidesPerView: 4, pagination: { enabled: true, } }, }, pagination: { enabled: false, el: pagination_feature, clickable: true, }, navigation: { nextEl: next_element, prevEl: prev_element, }, on: { lock: function () { swiperElfeatures.classList.add('nav-lock'); }, unlock: function () { swiperElfeatures.classList.remove('nav-lock'); } } }; // now we need to assign all parameters to Swiper element Object.assign(swiperElfeatures, swiperParamsfeatures); // and now initialize it swiperElfeatures.initialize(); }) } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".blog_cards_repeater_slider").length) { // swiper element var swiperBlogCards = document.querySelectorAll(".blog_cards_repeater_slider"); swiperBlogCards.forEach(function (swiperBlogCard) { var parent = swiperBlogCard.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); var container = parent.parentElement; var blogCards_pagination = container.querySelector(".blog-cards-repeater-pagination"); // swiper parameters var swiperParamsBlogCards = { spaceBetween: 24, breakpoints: { 0: { slidesPerView: 1, spaceBetween: 0 }, 580: { slidesPerView: 2, }, 768: { slidesPerView: 2, }, 889: { slidesPerView: 3, pagination: { enabled: true, } }, 1040: { slidesPerView: 4, pagination: { enabled: true, } }, }, pagination: { enabled: false, el: blogCards_pagination, clickable: true, }, navigation: { nextEl: next_element, prevEl: prev_element, }, on: { lock: function () { swiperBlogCard.classList.add('nav-lock'); }, unlock: function () { swiperBlogCard.classList.remove('nav-lock'); } } }; Object.assign(swiperBlogCard, swiperParamsBlogCards); swiperBlogCard.initialize(); }) } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".heroSwiper").length) { // swiper element var swiperHero = document.querySelector(".heroSwiper"); // swiper parameters var swiperParamsHero = { watchOverflow: true, autoplay: { delay: 5000, }, pagination: { el: ".hero-swiper-pagination", clickable: true, }, on: { slideChange: function () { //console.log(this.realIndex, this.activeIndex); }, }, }; // now we need to assign all parameters to Swiper element Object.assign(swiperHero, swiperParamsHero); // and now initialize it swiperHero.initialize(); } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".hero-thumbs").length) { var heroThumbsSwiperSlider = document.querySelectorAll(".hero-thumbs"); heroThumbsSwiperSlider.forEach(function (swiperElHeroThumbs) { var parent = swiperElHeroThumbs.parentElement; var pagination_hero_thumbs = parent.querySelector(".hero-thumbs-swiper-pagination"); var swiperParamsHeroThumbs = { spaceBetween: 24, slidesPerView: 1, watchOverflow: true, breakpoints: { 577: { slidesPerView: 2, pagination: { enabled: true, } }, 981: { slidesPerView: 3, pagination: { enabled: false, } }, }, pagination: { enabled: true, el: pagination_hero_thumbs, clickable: true, }, }; // now we need to assign all parameters to Swiper element Object.assign(swiperElHeroThumbs, swiperParamsHeroThumbs); // and now initialize it swiperElHeroThumbs.initialize(); }) } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".alcanceSwiper").length) { var alcanceSwiperSlider = document.querySelectorAll(".alcanceSwiper"); alcanceSwiperSlider.forEach(function (swiperElAlcance) { var parent = swiperElAlcance.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); var container = parent.parentElement; var pagination_alcance = container.querySelector(".alcance-swiper-pagination"); var n_items = jquery__WEBPACK_IMPORTED_MODULE_0___default()(swiperElAlcance).find('swiper-slide').length; var slides_per_view = 3; var slides_per_view_tablet = 2; if(n_items < 3){ slides_per_view = n_items; } if(n_items < 2){ slides_per_view_tablet = n_items; } var swiperParamsAlcance = { spaceBetween: 24, slidesPerView: 1, watchOverflow: true, breakpoints: { 768: { slidesPerView: slides_per_view_tablet, pagination: { enabled: true, } }, 1200: { slidesPerView: slides_per_view, pagination: { enabled: true, } }, }, pagination: { enabled: false, el: pagination_alcance, clickable: true, }, navigation: { nextEl: next_element, prevEl: prev_element, }, on: { lock: function () { swiperElAlcance.classList.add('nav-lock'); }, unlock: function () { swiperElAlcance.classList.remove('nav-lock'); } } }; // now we need to assign all parameters to Swiper element Object.assign(swiperElAlcance, swiperParamsAlcance); // and now initialize it swiperElAlcance.initialize(); }) } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".swiper-delivery-features").length) { var deliverySwiperSlider = document.querySelectorAll(".swiper-delivery-features"); deliverySwiperSlider.forEach(function (swiperEldelivery) { var parent = swiperEldelivery.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); var container = parent.parentElement; var pagination_delivery = container.querySelector(".delivery-swiper-pagination"); // swiper parameters var swiperParamsdelivery = { spaceBetween: 24, slidesPerView: 1, watchOverflow: true, breakpoints: { 768: { slidesPerView: 2, pagination: { enabled: true, } }, 1200: { slidesPerView: 3, pagination: { enabled: true, } }, }, pagination: { enabled: false, el: pagination_delivery, clickable: true, }, navigation: { nextEl: next_element, prevEl: prev_element, }, on: { lock: function () { swiperEldelivery.classList.add('nav-lock'); }, unlock: function () { swiperEldelivery.classList.remove('nav-lock'); } } }; // now we need to assign all parameters to Swiper element Object.assign(swiperEldelivery, swiperParamsdelivery); // and now initialize it swiperEldelivery.initialize(); }); } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".cardSwiper").length) { var swiperCards = document.querySelectorAll(".cardSwiper"); swiperCards.forEach(function (swiperElcard) { var parent = swiperElcard.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); var container = parent.parentElement; var pagination_card = container.querySelector(".card-swiper-pagination"); var swiperParamsCards = { slidesPerView: 1, spaceBetween: 16, breakpoints: { 690: { slidesPerView: 2, spaceBetween: 16, }, 768: { pagination: { enabled: true, }, }, 992: { slidesPerView: 2, spaceBetween: 24, pagination: { enabled: true, }, }, 1100: { slidesPerView: 3, spaceBetween: 32, pagination: { enabled: true, }, }, }, pagination: { el: pagination_card, clickable: true, enabled: false, }, navigation: { nextEl: next_element, prevEl: prev_element, }, on: { lock: function () { swiperElcard.classList.add('nav-lock'); }, unlock: function () { swiperElcard.classList.remove('nav-lock'); } } }; // now we need to assign all parameters to Swiper element Object.assign(swiperElcard, swiperParamsCards); // and now initialize it swiperElcard.initialize(); }) } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".servicesSwiper").length) { // swiper element var swiperElServices = document.querySelectorAll(".servicesSwiper"); swiperElServices.forEach(function (swiperElService) { var parent = swiperElService.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); var container = parent.parentElement; var pagination_services = container.querySelector(".services-swiper-pagination"); var n_items = jquery__WEBPACK_IMPORTED_MODULE_0___default()(swiperElService).attr('data-n'); var items_desktop = (n_items > 2) ? 3 : 2; // swiper parameters var swiperParamsServices = { spaceBetween: 16, slidesPerView: 1, watchOverflow: true, breakpoints: { 500: { slidesPerView: 2, spaceBetween: 16, }, 768: { spaceBetween: 24, slidesPerView: 2, pagination: { enabled: true, } }, 1200: { slidesPerView: items_desktop, pagination: { enabled: true, } }, }, pagination: { enabled: false, el: pagination_services, clickable: true, }, navigation: { nextEl: next_element, prevEl: prev_element, }, on: { lock: function () { swiperElService.classList.add('nav-lock'); }, unlock: function () { swiperElService.classList.remove('nav-lock'); } } }; // now we need to assign all parameters to Swiper element Object.assign(swiperElService, swiperParamsServices); // and now initialize it swiperElService.initialize(); }) } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".productsSwiper").length) { // swiper element var swiperElProducts = document.querySelectorAll(".productsSwiper"); swiperElProducts.forEach(function (swiperElProduct) { var parent = swiperElProduct.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); var container = parent.parentElement; var pagination_products = container.querySelector(".products-swiper-pagination"); var swiperParamsProducts = { spaceBetween: 16, slidesPerView: 1, breakpoints: { 690: { slidesPerView: 2, }, 768: { spaceBetween: 24, slidesPerView: 3, pagination: { enabled: true }, }, 1024: { slidesPerView: 4, pagination: { enabled: true }, }, }, pagination: { el: pagination_products, clickable: true, enabled: false }, navigation: { nextEl: next_element, prevEl: prev_element, }, on: { lock: function () { swiperElProduct.classList.add('nav-lock'); }, unlock: function () { swiperElProduct.classList.remove('nav-lock'); } } }; // now we need to assign all parameters to Swiper element Object.assign(swiperElProduct, swiperParamsProducts); // and now initialize it swiperElProduct.initialize(); }) } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".stepsSwiper").length) { // swiper element var swiperElSteps = document.querySelectorAll(".stepsSwiper"); swiperElSteps.forEach(function (swiperElStep) { var parent = swiperElStep.parentElement; var next_step = parent.querySelector(".swiper-button-next"); var prev_step = parent.querySelector(".swiper-button-prev"); var container = parent.parentElement; var pagination_steps = container.querySelector(".steps-swiper-pagination"); // swiper parameters var swiperParamsSteps = { spaceBetween: 16, slidesPerView: 1, watchOverflow: true, navigation: { nextEl: next_step, prevEl: prev_step, }, breakpoints: { 768: { pagination: { enabled: true, } }, }, pagination: { enabled: false, el: pagination_steps, clickable: true, }, on: { lock: function () { swiperElStep.classList.add('nav-lock'); }, unlock: function () { swiperElStep.classList.remove('nav-lock'); } } }; // now we need to assign all parameters to Swiper element Object.assign(swiperElStep, swiperParamsSteps); // and now initialize it swiperElStep.initialize(); }) } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".precisionSwiper").length) { // swiper element var swiperElPrecision = document.querySelectorAll(".precisionSwiper"); swiperElPrecision.forEach(function (swiperElPrecisionItem) { var parent = swiperElPrecisionItem.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); var container = parent.parentElement; var pagination_precision = container.querySelector(".precision-swiper-pagination"); var swiperParamsPrecision = null; // swiper parameters swiperParamsPrecision = { spaceBetween: 16, slidesPerView: 1, watchOverflow: true, breakpoints: { 768: { spaceBetween: 24, slidesPerView: 2, pagination: { enabled: true, }, }, 1200: { slidesPerView: 3, pagination: { enabled: true, }, }, }, pagination: { el: pagination_precision, clickable: true, enabled: false, }, navigation: { nextEl: next_element, prevEl: prev_element, }, on: { lock: function () { swiperElPrecisionItem.classList.add('nav-lock'); }, unlock: function () { swiperElPrecisionItem.classList.remove('nav-lock'); } } }; // now we need to assign all parameters to Swiper element Object.assign(swiperElPrecisionItem, swiperParamsPrecision); // and now initialize it swiperElPrecisionItem.initialize(); }) } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".caseStudiesSwiper").length) { // swiper element var swiperElcaseStudies = document.querySelectorAll(".caseStudiesSwiper"); swiperElcaseStudies.forEach(function (swiperElcaseStudiesItem) { var parent = swiperElcaseStudiesItem.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); var container = parent.parentElement; var pagination_caseStudies = container.querySelector(".caseStudies-swiper-pagination"); var swiperParamscaseStudies = null; // swiper parameters swiperParamscaseStudies = { spaceBetween: 16, slidesPerView: 1, watchOverflow: true, breakpoints: { 500: { slidesPerView: 2, spaceBetween: 16, }, 768: { spaceBetween: 24, slidesPerView: 2, pagination: { enabled: true, }, }, 1200: { slidesPerView: 3, pagination: { enabled: true, }, spaceBetween: 24, }, }, pagination: { el: pagination_caseStudies, clickable: true, enabled: false, }, navigation: { nextEl: next_element, prevEl: prev_element, }, on: { lock: function () { swiperElcaseStudiesItem.classList.add('nav-lock'); }, unlock: function () { swiperElcaseStudiesItem.classList.remove('nav-lock'); } } }; // now we need to assign all parameters to Swiper element Object.assign(swiperElcaseStudiesItem, swiperParamscaseStudies); // and now initialize it swiperElcaseStudiesItem.initialize(); }) } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".iconsSwiper").length) { // swiper element var swiperElIcons = document.querySelectorAll(".iconsSwiper"); swiperElIcons.forEach(function (swiperElIcon) { var parent = swiperElIcon.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); var container = parent.parentElement; var pagination_icons = container.querySelector(".icons-swiper-pagination"); // swiper parameters var swiperParamsIcons = { spaceBetween: 16, slidesPerView: 1, watchOverflow: true, centerInsufficientSlides: true, breakpoints: { 550: { slidesPerView: 2, }, 768: { slidesPerView: 2, pagination: { enabled: true, } }, 950: { pagination: { enabled: true, }, slidesPerView: 3, }, 1230: { pagination: { enabled: true, }, slidesPerView: 4, }, }, pagination: { enabled: false, el: pagination_icons, clickable: true, }, navigation: { nextEl: next_element, prevEl: prev_element, }, on: { lock: function () { swiperElIcon.classList.add('nav-lock'); }, unlock: function () { swiperElIcon.classList.remove('nav-lock'); } } }; // now we need to assign all parameters to Swiper element Object.assign(swiperElIcon, swiperParamsIcons); // and now initialize it swiperElIcon.initialize(); }) } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".relatedPostsSwiper").length) { // swiper element var swiperRelatedPosts = document.querySelectorAll(".relatedPostsSwiper"); swiperRelatedPosts.forEach(function (swiperRelatedPost) { var parent = swiperRelatedPost.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); var container = parent.parentElement; var pagination_related = container.querySelector('.related-post-pagination'); var swiperParamsRelatedPosts = { spaceBetween: 16, slidesPerView: 1, watchOverflow: true, navigation: { nextEl: next_element, prevEl: prev_element, }, pagination: { enabled: false, el: pagination_related, clickable: true, }, breakpoints: { 500: { slidesPerView: 2, }, 768: { spaceBetween: 24, slidesPerView: 3, pagination: { enabled: true, } }, 1200: { slidesPerView: 4, pagination: { enabled: true, } }, }, on: { lock: function () { swiperRelatedPost.classList.add('nav-lock'); }, unlock: function () { swiperRelatedPost.classList.remove('nav-lock'); } } }; // now we need to assign all parameters to Swiper element Object.assign(swiperRelatedPost, swiperParamsRelatedPosts); // and now initialize it swiperRelatedPost.initialize(); }) } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".paackstoriesSwiper").length) { // swiper element var swiperElPaackStories = document.querySelectorAll(".paackstoriesSwiper"); swiperElPaackStories.forEach(function (swiperElPaackStory) { var parent = swiperElPaackStory.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); var container = parent.parentElement; var pagination_paackstories = container.querySelector(".swiper-pagination-paackstories"); // swiper parameters var swiperParamsPaackStories = { spaceBetween: 20, slidesPerView: 1, watchOverflow: true, pagination: { enabled: false, el: pagination_paackstories, clickable: true, }, breakpoints: { 500: { slidesPerView: 2, }, 768: { slidesPerView: 3, pagination: { enabled: true, } }, 1200: { slidesPerView: 4, pagination: { enabled: true, } }, }, navigation: { nextEl: next_element, prevEl: prev_element, }, on: { lock: function () { swiperElPaackStory.classList.add('nav-lock'); }, unlock: function () { swiperElPaackStory.classList.remove('nav-lock'); } } }; // now we need to assign all parameters to Swiper element Object.assign(swiperElPaackStory, swiperParamsPaackStories); // and now initialize it swiperElPaackStory.initialize(); }) } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".borderCardsSwiper").length) { // swiper element var swiperElBorderCards = document.querySelectorAll(".borderCardsSwiper"); swiperElBorderCards.forEach(function (swiperElBorderCard) { var parent = swiperElBorderCard.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); var container = parent.parentElement; var pagination_border_cards = container.querySelector(".swiper-pagination-border-cards"); // swiper parameters var swiperParamsBorderCards = { spaceBetween: 16, slidesPerView: 1, watchOverflow: true, pagination: { enabled: false, el: pagination_border_cards, clickable: true, }, breakpoints: { 500: { slidesPerView: 2, spaceBetween: 16, }, 768: { slidesPerView: 2, spaceBetween: 16, pagination: { enabled: false, }, }, 1200: { slidesPerView: 3, spaceBetween: 24, pagination: { enabled: false, }, }, }, navigation: { nextEl: next_element, prevEl: prev_element, }, on: { lock: function () { swiperElBorderCard.classList.add('nav-lock'); }, unlock: function () { swiperElBorderCard.classList.remove('nav-lock'); } } }; // now we need to assign all parameters to Swiper element Object.assign(swiperElBorderCard, swiperParamsBorderCards); // and now initialize it swiperElBorderCard.initialize(); }) } if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(".logosSwiper").length) { // swiper element var logosEl = document.querySelectorAll(".logosSwiper"); logosEl.forEach(function (logoEl) { var parent = logoEl.parentElement; var prev_element = parent.querySelector(".swiper-button-prev"); var next_element = parent.querySelector(".swiper-button-next"); var container = parent.parentElement; var pagination_logos = container.querySelector(".swiper-pagination-logos"); // swiper parameters var swiperParamsLogos = { spaceBetween: 48, slidesPerView: 1, watchOverflow: true, pagination: { enabled: false, el: pagination_logos, clickable: true, }, breakpoints: { 500: { slidesPerView: 2, }, 768: { slidesPerView: 3, pagination: { enabled: true, }, }, 1007: { slidesPerView: 4, pagination: { enabled: true, }, }, }, navigation: { nextEl: next_element, prevEl: prev_element, }, on: { lock: function () { logoEl.classList.add('nav-lock'); }, unlock: function () { logoEl.classList.remove('nav-lock'); } } }; // now we need to assign all parameters to Swiper element Object.assign(logoEl, swiperParamsLogos); // and now initialize it logoEl.initialize(); }) } } /***/ }), /***/ "./scripts/modules/spacer.js": /*!***********************************!*\ !*** ./scripts/modules/spacer.js ***! \***********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ init; } /* harmony export */ }); /* harmony import */ var gsap__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! gsap */ "../../node_modules/gsap/index.js"); /* harmony import */ var gsap_ScrollTrigger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! gsap/ScrollTrigger */ "../../node_modules/gsap/ScrollTrigger.js"); /* harmony import */ var split_type__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! split-type */ "../../node_modules/split-type/dist/index.js"); /* harmony import */ var _studio_freight_lenis__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @studio-freight/lenis */ "../../node_modules/@studio-freight/lenis/dist/lenis.modern.mjs"); /* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery"); /* eslint-disable */ function init() { if(jQuery('.orangeWrapper').length == 0){ return; } // JavaScript to be fired on the home page gsap__WEBPACK_IMPORTED_MODULE_1__.gsap.registerPlugin(gsap_ScrollTrigger__WEBPACK_IMPORTED_MODULE_2__.ScrollTrigger); var splitTypes = document.querySelectorAll(".reveal-type"); splitTypes.forEach(function (word, i) { var bg = word.dataset.bgColor; var fg = word.dataset.fgColor; var text = new split_type__WEBPACK_IMPORTED_MODULE_0__["default"](word, { types: "words" }); gsap__WEBPACK_IMPORTED_MODULE_1__.gsap.fromTo( text.words, { color: bg, }, { color: fg, duration: 0.8, stagger: 0.05, scrollTrigger: { trigger: word, start: "50% 50%", end: "+=200%", scrub: true, markers: false, toggleActions: "play play reverse reverse", }, } ); }); var lenis = new _studio_freight_lenis__WEBPACK_IMPORTED_MODULE_3__["default"](); function raf(time) { lenis.raf(time); requestAnimationFrame(raf); } requestAnimationFrame(raf); var tl = gsap__WEBPACK_IMPORTED_MODULE_1__.gsap .timeline({ scrollTrigger: { trigger: ".orangeWrapper", scrub: true, pin: true, start: "50% 50%", end: "+=200%", onUpdate: function(self){ if(self.progress > 0.85){ jQuery('.orangeWrapper').addClass("show_video"); } else { jQuery('.orangeWrapper').removeClass("show_video"); } } }, }) jQuery('.orangeWrapper').on('click',function(){ var orangeWrapper = jQuery(this); if(orangeWrapper.hasClass('show_video')){ var video = orangeWrapper.find('video'); if(orangeWrapper.hasClass('playing')){ video[0].pause(); orangeWrapper.removeClass('playing'); } else { video[0].play(); orangeWrapper.addClass('playing'); } } }) }; /***/ }), /***/ "./scripts/modules/truncate_text.js": /*!******************************************!*\ !*** ./scripts/modules/truncate_text.js ***! \******************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ init; } /* harmony export */ }); /* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery"); function init() { jQuery('.truncate').each(function(){ var truncateEl = jQuery(this).get(0); var truncateRect = truncateEl.getBoundingClientRect(); truncateEl.style.setProperty("--truncate-height", ((truncateRect.height) + "px")); }); jQuery('.read-more-truncate-text').on('click',function(){ var truncate_container = jQuery(this).closest('.truncate-container'); var truncate_text_content = truncate_container.find('.truncate'); var truncate__inner = truncate_text_content.find('.truncate__inner'); truncate_text_content.removeClass('truncate--line-clamped'); var truncateEl = truncate_text_content.get(0); var truncateInnerEl = truncate__inner.get(0); window.requestAnimationFrame(function () { var truncateInnerRect = truncateInnerEl.getBoundingClientRect(); truncateEl.style.setProperty("--truncate-height-expanded", ((truncateInnerRect.height) + "px")); truncate_text_content.addClass('truncate--expanded'); }); jQuery(this).hide(); }); } /***/ }), /***/ "./scripts/modules/video.js": /*!**********************************!*\ !*** ./scripts/modules/video.js ***! \**********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* binding */ init; } /* harmony export */ }); /* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery"); /* eslint-disable */ function init() { if (jQuery(".js-playvideo").height) { jQuery(".js-playvideo").on("click", function () { var that = jQuery(this); that.addClass("hidden"); var js_video = jQuery(this).next(".js-video"); if(js_video.hasClass('local')){ var video = js_video.find('video')[0]; video.play(); video.addEventListener("click", function(e) { // Reanudar la reproducción del video si estaba reproduciéndose antes de hacer clic en la barra de progreso if (!video.paused) { video.play(); } }); } else if(js_video.hasClass('vimeo')){ var iframe = js_video.find('iframe'); var player = new Vimeo.Player(iframe); player.play(); player.on('pause', function(data) { that.removeClass("hidden"); js_video.addClass("hidden"); }); } js_video.removeClass("hidden"); }); } jQuery(".ml-video").magnificPopup({ preloader: true, type: "iframe", iframe: { patterns: { youtube: { index: "youtube.com/", id: "v=", src: "//www.youtube.com/embed/%id%?enablejsapi=1&autoplay=1&rel=0", // set enablejsapi to 1 }, }, srcAction: "iframe_src", }, }); } /***/ }), /***/ "./scripts/routes/blogpost.js": /*!************************************!*\ !*** ./scripts/routes/blogpost.js ***! \************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var lity_dist_lity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lity/dist/lity */ "../../node_modules/lity/dist/lity.js"); /* harmony import */ var lity_dist_lity__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lity_dist_lity__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _modules_modal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../modules/modal */ "./scripts/modules/modal.js"); /* harmony import */ var _modules_modal__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_modules_modal__WEBPACK_IMPORTED_MODULE_1__); /* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery"); /* eslint-disable */ /* harmony default export */ __webpack_exports__["default"] = ({ init: function init() { // JavaScript to be fired on the about us page jQuery(".c-header").attr("data-mode", "dark"); }, }); /***/ }), /***/ "./scripts/routes/common.js": /*!**********************************!*\ !*** ./scripts/routes/common.js ***! \**********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var aos__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! aos */ "../../node_modules/aos/dist/aos.js"); /* harmony import */ var aos__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aos__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _vendor_jquery_magnific_popup_min__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vendor/jquery.magnific-popup.min */ "./scripts/vendor/jquery.magnific-popup.min.js"); /* harmony import */ var _vendor_jquery_magnific_popup_min__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_vendor_jquery_magnific_popup_min__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var _modules_menu_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../modules/menu.js */ "./scripts/modules/menu.js"); /* harmony import */ var _grubersjoe_slide_menu_dist_slide_menu__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @grubersjoe/slide-menu/dist/slide-menu */ "../../node_modules/@grubersjoe/slide-menu/dist/slide-menu.js"); /* harmony import */ var _grubersjoe_slide_menu_dist_slide_menu__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_grubersjoe_slide_menu_dist_slide_menu__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var _modules_footer_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../modules/footer.js */ "./scripts/modules/footer.js"); /* harmony import */ var _modules_slider_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../modules/slider.js */ "./scripts/modules/slider.js"); /* harmony import */ var _modules_anchor_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../modules/anchor.js */ "./scripts/modules/anchor.js"); /* harmony import */ var _modules_video_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../modules/video.js */ "./scripts/modules/video.js"); /* harmony import */ var _modules_forms_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../modules/forms.js */ "./scripts/modules/forms.js"); /* harmony import */ var _modules_banner_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../modules/banner.js */ "./scripts/modules/banner.js"); /* harmony import */ var _modules_truncate_text_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../modules/truncate_text.js */ "./scripts/modules/truncate_text.js"); /* harmony import */ var _modules_spacer_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../modules/spacer.js */ "./scripts/modules/spacer.js"); /* harmony import */ var _modules_cobertura_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../modules/cobertura.js */ "./scripts/modules/cobertura.js"); /* harmony import */ var _modules_nav_blog_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../modules/nav_blog.js */ "./scripts/modules/nav_blog.js"); /* harmony import */ var _modules_custom_selects_location_form_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../modules/custom_selects_location_form.js */ "./scripts/modules/custom_selects_location_form.js"); /* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery"); /* eslint-disable */ /* harmony default export */ __webpack_exports__["default"] = ({ init: function init() { // JavaScript to be fired on all pages (0,_modules_footer_js__WEBPACK_IMPORTED_MODULE_4__["default"])(); (0,_modules_cobertura_js__WEBPACK_IMPORTED_MODULE_12__["default"])(); (0,_modules_slider_js__WEBPACK_IMPORTED_MODULE_5__["default"])(); (0,_modules_anchor_js__WEBPACK_IMPORTED_MODULE_6__["default"])(); (0,_modules_video_js__WEBPACK_IMPORTED_MODULE_7__["default"])(); (0,_modules_forms_js__WEBPACK_IMPORTED_MODULE_8__["default"])(); (0,_modules_banner_js__WEBPACK_IMPORTED_MODULE_9__["default"])(); (0,_modules_truncate_text_js__WEBPACK_IMPORTED_MODULE_10__["default"])(); (0,_modules_spacer_js__WEBPACK_IMPORTED_MODULE_11__["default"])(); (0,_modules_nav_blog_js__WEBPACK_IMPORTED_MODULE_13__["default"])(); (0,_modules_custom_selects_location_form_js__WEBPACK_IMPORTED_MODULE_14__["default"])(); }, finalize: function finalize() { // JavaScript to be fired on all pages, after page specific JS is fired (0,_modules_menu_js__WEBPACK_IMPORTED_MODULE_2__["default"])(); aos__WEBPACK_IMPORTED_MODULE_0___default().init({ startEvent: "DOMContentLoaded", disable: 'mobile' }); jQuery(".smart-page-loader").hide(); }, }); /***/ }), /***/ "./scripts/routes/error.js": /*!*********************************!*\ !*** ./scripts/routes/error.js ***! \*********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* provided dependency */ var jQuery = __webpack_require__(/*! jquery */ "jquery"); /* eslint-disable */ /* harmony default export */ __webpack_exports__["default"] = ({ init: function init() { // JavaScript to be fired on the about us page jQuery(".c-header").attr("data-mode", "dark"); }, }); /***/ }), /***/ "./scripts/util/Router.js": /*!********************************!*\ !*** ./scripts/util/Router.js ***! \********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _camelCase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./camelCase */ "./scripts/util/camelCase.js"); /* eslint-disable */ /** * DOM-based Routing * * Based on {@link http://goo.gl/EUTi53|Markup-based Unobtrusive Comprehensive DOM-ready Execution} by Paul Irish * * The routing fires all common scripts, followed by the page specific scripts. * Add additional events for more control over timing e.g. a finalize event */ var Router = function Router(routes) { this.routes = routes; }; /** * Fire Router events * @param {string} route DOM-based route derived from body classes (``) * @param {string} [event] Events on the route. By default, `init` and `finalize` events are called. * @param {string} [arg] Any custom argument to be passed to the event. */ Router.prototype.fire = function fire (route, event, arg) { if ( event === void 0 ) event = "init"; document.dispatchEvent( new CustomEvent("routed", { bubbles: true, detail: { route: route, fn: event, }, }) ); var fire = route !== "" && this.routes[route] && typeof this.routes[route][event] === "function"; if (fire) { this.routes[route][event](arg); } }; /** * Automatically load and fire Router events * * Events are fired in the following order: ** common init ** page-specific init ** page-specific finalize ** common finalize */ Router.prototype.loadEvents = function loadEvents () { var this$1 = this; // Fire common init JS this.fire("common"); // Fire page-specific init JS, and then finalize JS document.body.className .toLowerCase() .replace(/-/g, "_") .split(/\s+/) .map(_camelCase__WEBPACK_IMPORTED_MODULE_0__["default"]) .forEach(function (className) { this$1.fire(className); this$1.fire(className, "finalize"); }); // Fire common finalize JS this.fire("common", "finalize"); }; /* harmony default export */ __webpack_exports__["default"] = (Router); /***/ }), /***/ "./scripts/util/camelCase.js": /*!***********************************!*\ !*** ./scripts/util/camelCase.js ***! \***********************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; } /* harmony export */ }); /** * the most terrible camelizer on the internet, guaranteed! * @param {string} str String that isn't camel-case, e.g., CAMeL_CaSEiS-harD * @return {string} String converted to camel-case, e.g., camelCaseIsHard */ /* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(str) { return ("" + (str.charAt(0).toLowerCase()) + (str.replace(/[\W_]/g, '|').split('|') .map(function (part) { return ("" + (part.charAt(0).toUpperCase()) + (part.slice(1))); }) .join('') .slice(1))); }; /***/ }), /***/ "./scripts/vendor/jquery.magnific-popup.min.js": /*!*****************************************************!*\ !*** ./scripts/vendor/jquery.magnific-popup.min.js ***! \*****************************************************/ /***/ (function(module, exports, __webpack_require__) { /* provided dependency */ var __webpack_provided_window_dot_jQuery = __webpack_require__(/*! jquery */ "jquery"); var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* eslint-disable */ /*! Magnific Popup - v1.1.0 - 2016-02-20 * http://dimsemenov.com/plugins/magnific-popup/ * Copyright (c) 2016 Dmitry Semenov; */ !(function (a) { true ? !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! jquery */ "jquery")], __WEBPACK_AMD_DEFINE_FACTORY__ = (a), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : 0; })(function (a) { var b, c, d, e, f, g, h = "Close", i = "BeforeClose", j = "AfterClose", k = "BeforeAppend", l = "MarkupParse", m = "Open", n = "Change", o = "mfp", p = "." + o, q = "mfp-ready", r = "mfp-removing", s = "mfp-prevent-close", t = function () {}, u = !!__webpack_provided_window_dot_jQuery, v = a(window), w = function (a, c) { b.ev.on(o + a + p, c); }, x = function (b, c, d, e) { var f = document.createElement("div"); return ( (f.className = "mfp-" + b), d && (f.innerHTML = d), e ? c && c.appendChild(f) : ((f = a(f)), c && f.appendTo(c)), f ); }, y = function (c, d) { b.ev.triggerHandler(o + c, d), b.st.callbacks && ((c = c.charAt(0).toLowerCase() + c.slice(1)), b.st.callbacks[c] && b.st.callbacks[c].apply(b, a.isArray(d) ? d : [d])); }, z = function (c) { return ( (c === g && b.currTemplate.closeBtn) || ((b.currTemplate.closeBtn = a( b.st.closeMarkup.replace("%title%", b.st.tClose) )), (g = c)), b.currTemplate.closeBtn ); }, A = function () { a.magnificPopup.instance || ((b = new t()), b.init(), (a.magnificPopup.instance = b)); }, B = function () { var a = document.createElement("p").style, b = ["ms", "O", "Moz", "Webkit"]; if (void 0 !== a.transition) { return !0; } for (; b.length; ) { if (b.pop() + "Transition" in a) { return !0; } } return !1; }; (t.prototype = { constructor: t, init: function () { var c = navigator.appVersion; (b.isLowIE = b.isIE8 = document.all && !document.addEventListener), (b.isAndroid = /android/gi.test(c)), (b.isIOS = /iphone|ipad|ipod/gi.test(c)), (b.supportsTransition = B()), (b.probablyMobile = b.isAndroid || b.isIOS || /(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test( navigator.userAgent )), (d = a(document)), (b.popupsCache = {}); }, open: function (c) { var e; if (c.isObj === !1) { (b.items = c.items.toArray()), (b.index = 0); var g, h = c.items; for (e = 0; e < h.length; e++) { if (((g = h[e]), g.parsed && (g = g.el[0]), g === c.el[0])) { b.index = e; break; } } } else { (b.items = a.isArray(c.items) ? c.items : [c.items]), (b.index = c.index || 0); } if (b.isOpen) { return void b.updateItemHTML(); } (b.types = []), (f = ""), c.mainEl && c.mainEl.length ? (b.ev = c.mainEl.eq(0)) : (b.ev = d), c.key ? (b.popupsCache[c.key] || (b.popupsCache[c.key] = {}), (b.currTemplate = b.popupsCache[c.key])) : (b.currTemplate = {}), (b.st = a.extend(!0, {}, a.magnificPopup.defaults, c)), (b.fixedContentPos = "auto" === b.st.fixedContentPos ? !b.probablyMobile : b.st.fixedContentPos), b.st.modal && ((b.st.closeOnContentClick = !1), (b.st.closeOnBgClick = !1), (b.st.showCloseBtn = !1), (b.st.enableEscapeKey = !1)), b.bgOverlay || ((b.bgOverlay = x("bg").on("click" + p, function () { b.close(); })), (b.wrap = x("wrap") .attr("tabindex", -1) .on("click" + p, function (a) { b._checkIfClose(a.target) && b.close(); })), (b.container = x("container", b.wrap))), (b.contentContainer = x("content")), b.st.preloader && (b.preloader = x("preloader", b.container, b.st.tLoading)); var i = a.magnificPopup.modules; for (e = 0; e < i.length; e++) { var j = i[e]; (j = j.charAt(0).toUpperCase() + j.slice(1)), b["init" + j].call(b); } y("BeforeOpen"), b.st.showCloseBtn && (b.st.closeBtnInside ? (w(l, function (a, b, c, d) { c.close_replaceWith = z(d.type); }), (f += " mfp-close-btn-in")) : b.wrap.append(z())), b.st.alignTop && (f += " mfp-align-top"), b.fixedContentPos ? b.wrap.css({ overflow: b.st.overflowY, overflowX: "hidden", overflowY: b.st.overflowY, }) : b.wrap.css({ top: v.scrollTop(), position: "absolute" }), (b.st.fixedBgPos === !1 || ("auto" === b.st.fixedBgPos && !b.fixedContentPos)) && b.bgOverlay.css({ height: d.height(), position: "absolute" }), b.st.enableEscapeKey && d.on("keyup" + p, function (a) { 27 === a.keyCode && b.close(); }), v.on("resize" + p, function () { b.updateSize(); }), b.st.closeOnContentClick || (f += " mfp-auto-cursor"), f && b.wrap.addClass(f); var k = (b.wH = v.height()), n = {}; if (b.fixedContentPos && b._hasScrollBar(k)) { var o = b._getScrollbarSize(); o && (n.marginRight = o); } b.fixedContentPos && (b.isIE7 ? a("body, html").css("overflow", "hidden") : (n.overflow = "hidden")); var r = b.st.mainClass; return ( b.isIE7 && (r += " mfp-ie7"), r && b._addClassToMFP(r), b.updateItemHTML(), y("BuildControls"), a("html").css(n), b.bgOverlay.add(b.wrap).prependTo(b.st.prependTo || a(document.body)), (b._lastFocusedEl = document.activeElement), setTimeout(function () { b.content ? (b._addClassToMFP(q), b._setFocus()) : b.bgOverlay.addClass(q), d.on("focusin" + p, b._onFocusIn); }, 16), (b.isOpen = !0), b.updateSize(k), y(m), c ); }, close: function () { b.isOpen && (y(i), (b.isOpen = !1), b.st.removalDelay && !b.isLowIE && b.supportsTransition ? (b._addClassToMFP(r), setTimeout(function () { b._close(); }, b.st.removalDelay)) : b._close()); }, _close: function () { y(h); var c = r + " " + q + " "; if ( (b.bgOverlay.detach(), b.wrap.detach(), b.container.empty(), b.st.mainClass && (c += b.st.mainClass + " "), b._removeClassFromMFP(c), b.fixedContentPos) ) { var e = { marginRight: "" }; b.isIE7 ? a("body, html").css("overflow", "") : (e.overflow = ""), a("html").css(e); } d.off("keyup" + p + " focusin" + p), b.ev.off(p), b.wrap.attr("class", "mfp-wrap").removeAttr("style"), b.bgOverlay.attr("class", "mfp-bg"), b.container.attr("class", "mfp-container"), !b.st.showCloseBtn || (b.st.closeBtnInside && b.currTemplate[b.currItem.type] !== !0) || (b.currTemplate.closeBtn && b.currTemplate.closeBtn.detach()), b.st.autoFocusLast && b._lastFocusedEl && a(b._lastFocusedEl).focus(), (b.currItem = null), (b.content = null), (b.currTemplate = null), (b.prevHeight = 0), y(j); }, updateSize: function (a) { if (b.isIOS) { var c = document.documentElement.clientWidth / window.innerWidth, d = window.innerHeight * c; b.wrap.css("height", d), (b.wH = d); } else { b.wH = a || v.height(); } b.fixedContentPos || b.wrap.css("height", b.wH), y("Resize"); }, updateItemHTML: function () { var c = b.items[b.index]; b.contentContainer.detach(), b.content && b.content.detach(), c.parsed || (c = b.parseEl(b.index)); var d = c.type; if ( (y("BeforeChange", [b.currItem ? b.currItem.type : "", d]), (b.currItem = c), !b.currTemplate[d]) ) { var f = b.st[d] ? b.st[d].markup : !1; y("FirstMarkupParse", f), f ? (b.currTemplate[d] = a(f)) : (b.currTemplate[d] = !0); } e && e !== c.type && b.container.removeClass("mfp-" + e + "-holder"); var g = b["get" + d.charAt(0).toUpperCase() + d.slice(1)]( c, b.currTemplate[d] ); b.appendContent(g, d), (c.preloaded = !0), y(n, c), (e = c.type), b.container.prepend(b.contentContainer), y("AfterChange"); }, appendContent: function (a, c) { (b.content = a), a ? b.st.showCloseBtn && b.st.closeBtnInside && b.currTemplate[c] === !0 ? b.content.find(".mfp-close").length || b.content.append(z()) : (b.content = a) : (b.content = ""), y(k), b.container.addClass("mfp-" + c + "-holder"), b.contentContainer.append(b.content); }, parseEl: function (c) { var d, e = b.items[c]; if ( (e.tagName ? (e = { el: a(e) }) : ((d = e.type), (e = { data: e, src: e.src })), e.el) ) { for (var f = b.types, g = 0; g < f.length; g++) { if (e.el.hasClass("mfp-" + f[g])) { d = f[g]; break; } } (e.src = e.el.attr("data-mfp-src")), e.src || (e.src = e.el.attr("href")); } return ( (e.type = d || b.st.type || "inline"), (e.index = c), (e.parsed = !0), (b.items[c] = e), y("ElementParse", e), b.items[c] ); }, addGroup: function (a, c) { var d = function (d) { (d.mfpEl = this), b._openClick(d, a, c); }; c || (c = {}); var e = "click.magnificPopup"; (c.mainEl = a), c.items ? ((c.isObj = !0), a.off(e).on(e, d)) : ((c.isObj = !1), c.delegate ? a.off(e).on(e, c.delegate, d) : ((c.items = a), a.off(e).on(e, d))); }, _openClick: function (c, d, e) { var f = void 0 !== e.midClick ? e.midClick : a.magnificPopup.defaults.midClick; if ( f || !(2 === c.which || c.ctrlKey || c.metaKey || c.altKey || c.shiftKey) ) { var g = void 0 !== e.disableOn ? e.disableOn : a.magnificPopup.defaults.disableOn; if (g) { if (a.isFunction(g)) { if (!g.call(b)) { return !0; } } else if (v.width() < g) { return !0; } } c.type && (c.preventDefault(), b.isOpen && c.stopPropagation()), (e.el = a(c.mfpEl)), e.delegate && (e.items = d.find(e.delegate)), b.open(e); } }, updateStatus: function (a, d) { if (b.preloader) { c !== a && b.container.removeClass("mfp-s-" + c), d || "loading" !== a || (d = b.st.tLoading); var e = { status: a, text: d }; y("UpdateStatus", e), (a = e.status), (d = e.text), b.preloader.html(d), b.preloader.find("a").on("click", function (a) { a.stopImmediatePropagation(); }), b.container.addClass("mfp-s-" + a), (c = a); } }, _checkIfClose: function (c) { if (!a(c).hasClass(s)) { var d = b.st.closeOnContentClick, e = b.st.closeOnBgClick; if (d && e) { return !0; } if ( !b.content || a(c).hasClass("mfp-close") || (b.preloader && c === b.preloader[0]) ) { return !0; } if (c === b.content[0] || a.contains(b.content[0], c)) { if (d) { return !0; } } else if (e && a.contains(document, c)) { return !0; } return !1; } }, _addClassToMFP: function (a) { b.bgOverlay.addClass(a), b.wrap.addClass(a); }, _removeClassFromMFP: function (a) { this.bgOverlay.removeClass(a), b.wrap.removeClass(a); }, _hasScrollBar: function (a) { return ( (b.isIE7 ? d.height() : document.body.scrollHeight) > (a || v.height()) ); }, _setFocus: function () { (b.st.focus ? b.content.find(b.st.focus).eq(0) : b.wrap).focus(); }, _onFocusIn: function (c) { return c.target === b.wrap[0] || a.contains(b.wrap[0], c.target) ? void 0 : (b._setFocus(), !1); }, _parseMarkup: function (b, c, d) { var e; d.data && (c = a.extend(d.data, c)), y(l, [b, c, d]), a.each(c, function (c, d) { if (void 0 === d || d === !1) { return !0; } if (((e = c.split("_")), e.length > 1)) { var f = b.find(p + "-" + e[0]); if (f.length > 0) { var g = e[1]; "replaceWith" === g ? f[0] !== d[0] && f.replaceWith(d) : "img" === g ? f.is("img") ? f.attr("src", d) : f.replaceWith( a("").attr("src", d).attr("class", f.attr("class")) ) : f.attr(e[1], d); } } else { b.find(p + "-" + c).html(d); } }); }, _getScrollbarSize: function () { if (void 0 === b.scrollbarSize) { var a = document.createElement("div"); (a.style.cssText = "width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;"), document.body.appendChild(a), (b.scrollbarSize = a.offsetWidth - a.clientWidth), document.body.removeChild(a); } return b.scrollbarSize; }, }), (a.magnificPopup = { instance: null, proto: t.prototype, modules: [], open: function (b, c) { return ( A(), (b = b ? a.extend(!0, {}, b) : {}), (b.isObj = !0), (b.index = c || 0), this.instance.open(b) ); }, close: function () { return a.magnificPopup.instance && a.magnificPopup.instance.close(); }, registerModule: function (b, c) { c.options && (a.magnificPopup.defaults[b] = c.options), a.extend(this.proto, c.proto), this.modules.push(b); }, defaults: { disableOn: 0, key: null, midClick: !1, mainClass: "", preloader: !0, focus: "", closeOnContentClick: !1, closeOnBgClick: !0, closeBtnInside: !0, showCloseBtn: !0, enableEscapeKey: !0, modal: !1, alignTop: !1, removalDelay: 0, prependTo: null, fixedContentPos: "auto", fixedBgPos: "auto", overflowY: "auto", closeMarkup: '', tClose: "Close (Esc)", tLoading: "Loading...", autoFocusLast: !0, }, }), (a.fn.magnificPopup = function (c) { A(); var d = a(this); if ("string" == typeof c) { if ("open" === c) { var e, f = u ? d.data("magnificPopup") : d[0].magnificPopup, g = parseInt(arguments[1], 10) || 0; f.items ? (e = f.items[g]) : ((e = d), f.delegate && (e = e.find(f.delegate)), (e = e.eq(g))), b._openClick({ mfpEl: e }, d, f); } else { b.isOpen && b[c].apply(b, Array.prototype.slice.call(arguments, 1)); } } else { (c = a.extend(!0, {}, c)), u ? d.data("magnificPopup", c) : (d[0].magnificPopup = c), b.addGroup(d, c); } return d; }); var C, D, E, F = "inline", G = function () { E && (D.after(E.addClass(C)).detach(), (E = null)); }; a.magnificPopup.registerModule(F, { options: { hiddenClass: "hide", markup: "", tNotFound: "Content not found", }, proto: { initInline: function () { b.types.push(F), w(h + "." + F, function () { G(); }); }, getInline: function (c, d) { if ((G(), c.src)) { var e = b.st.inline, f = a(c.src); if (f.length) { var g = f[0].parentNode; g && g.tagName && (D || ((C = e.hiddenClass), (D = x(C)), (C = "mfp-" + C)), (E = f.after(D).detach().removeClass(C))), b.updateStatus("ready"); } else { b.updateStatus("error", e.tNotFound), (f = a("
")); } return (c.inlineElement = f), f; } return b.updateStatus("ready"), b._parseMarkup(d, {}, c), d; }, }, }); var H, I = "ajax", J = function () { H && a(document.body).removeClass(H); }, K = function () { J(), b.req && b.req.abort(); }; a.magnificPopup.registerModule(I, { options: { settings: null, cursor: "mfp-ajax-cur", tError: 'The content could not be loaded.', }, proto: { initAjax: function () { b.types.push(I), (H = b.st.ajax.cursor), w(h + "." + I, K), w("BeforeChange." + I, K); }, getAjax: function (c) { H && a(document.body).addClass(H), b.updateStatus("loading"); var d = a.extend( { url: c.src, success: function (d, e, f) { var g = { data: d, xhr: f }; y("ParseAjax", g), b.appendContent(a(g.data), I), (c.finished = !0), J(), b._setFocus(), setTimeout(function () { b.wrap.addClass(q); }, 16), b.updateStatus("ready"), y("AjaxContentAdded"); }, error: function () { J(), (c.finished = c.loadError = !0), b.updateStatus( "error", b.st.ajax.tError.replace("%url%", c.src) ); }, }, b.st.ajax.settings ); return (b.req = a.ajax(d)), ""; }, }, }); var L, M = function (c) { if (c.data && void 0 !== c.data.title) { return c.data.title; } var d = b.st.image.titleSrc; if (d) { if (a.isFunction(d)) { return d.call(b, c); } if (c.el) { return c.el.attr(d) || ""; } } return ""; }; a.magnificPopup.registerModule("image", { options: { markup: '
', cursor: "mfp-zoom-out-cur", titleSrc: "title", verticalFit: !0, tError: 'The image could not be loaded.', }, proto: { initImage: function () { var c = b.st.image, d = ".image"; b.types.push("image"), w(m + d, function () { "image" === b.currItem.type && c.cursor && a(document.body).addClass(c.cursor); }), w(h + d, function () { c.cursor && a(document.body).removeClass(c.cursor), v.off("resize" + p); }), w("Resize" + d, b.resizeImage), b.isLowIE && w("AfterChange", b.resizeImage); }, resizeImage: function () { var a = b.currItem; if (a && a.img && b.st.image.verticalFit) { var c = 0; b.isLowIE && (c = parseInt(a.img.css("padding-top"), 10) + parseInt(a.img.css("padding-bottom"), 10)), a.img.css("max-height", b.wH - c); } }, _onImageHasSize: function (a) { a.img && ((a.hasSize = !0), L && clearInterval(L), (a.isCheckingImgSize = !1), y("ImageHasSize", a), a.imgHidden && (b.content && b.content.removeClass("mfp-loading"), (a.imgHidden = !1))); }, findImageSize: function (a) { var c = 0, d = a.img[0], e = function (f) { L && clearInterval(L), (L = setInterval(function () { return d.naturalWidth > 0 ? void b._onImageHasSize(a) : (c > 200 && clearInterval(L), c++, void (3 === c ? e(10) : 40 === c ? e(50) : 100 === c && e(500))); }, f)); }; e(1); }, getImage: function (c, d) { var e = 0, f = function () { c && (c.img[0].complete ? (c.img.off(".mfploader"), c === b.currItem && (b._onImageHasSize(c), b.updateStatus("ready")), (c.hasSize = !0), (c.loaded = !0), y("ImageLoadComplete")) : (e++, 200 > e ? setTimeout(f, 100) : g())); }, g = function () { c && (c.img.off(".mfploader"), c === b.currItem && (b._onImageHasSize(c), b.updateStatus("error", h.tError.replace("%url%", c.src))), (c.hasSize = !0), (c.loaded = !0), (c.loadError = !0)); }, h = b.st.image, i = d.find(".mfp-img"); if (i.length) { var j = document.createElement("img"); (j.className = "mfp-img"), c.el && c.el.find("img").length && (j.alt = c.el.find("img").attr("alt")), (c.img = a(j).on("load.mfploader", f).on("error.mfploader", g)), (j.src = c.src), i.is("img") && (c.img = c.img.clone()), (j = c.img[0]), j.naturalWidth > 0 ? (c.hasSize = !0) : j.width || (c.hasSize = !1); } return ( b._parseMarkup(d, { title: M(c), img_replaceWith: c.img }, c), b.resizeImage(), c.hasSize ? (L && clearInterval(L), c.loadError ? (d.addClass("mfp-loading"), b.updateStatus("error", h.tError.replace("%url%", c.src))) : (d.removeClass("mfp-loading"), b.updateStatus("ready")), d) : (b.updateStatus("loading"), (c.loading = !0), c.hasSize || ((c.imgHidden = !0), d.addClass("mfp-loading"), b.findImageSize(c)), d) ); }, }, }); var N, O = function () { return ( void 0 === N && (N = void 0 !== document.createElement("p").style.MozTransform), N ); }; a.magnificPopup.registerModule("zoom", { options: { enabled: !1, easing: "ease-in-out", duration: 300, opener: function (a) { return a.is("img") ? a : a.find("img"); }, }, proto: { initZoom: function () { var a, c = b.st.zoom, d = ".zoom"; if (c.enabled && b.supportsTransition) { var e, f, g = c.duration, j = function (a) { var b = a .clone() .removeAttr("style") .removeAttr("class") .addClass("mfp-animated-image"), d = "all " + c.duration / 1e3 + "s " + c.easing, e = { position: "fixed", zIndex: 9999, left: 0, top: 0, "-webkit-backface-visibility": "hidden", }, f = "transition"; return ( (e["-webkit-" + f] = e["-moz-" + f] = e["-o-" + f] = e[f] = d), b.css(e), b ); }, k = function () { b.content.css("visibility", "visible"); }; w("BuildControls" + d, function () { if (b._allowZoom()) { if ( (clearTimeout(e), b.content.css("visibility", "hidden"), (a = b._getItemToZoom()), !a) ) { return void k(); } (f = j(a)), f.css(b._getOffset()), b.wrap.append(f), (e = setTimeout(function () { f.css(b._getOffset(!0)), (e = setTimeout(function () { k(), setTimeout(function () { f.remove(), (a = f = null), y("ZoomAnimationEnded"); }, 16); }, g)); }, 16)); } }), w(i + d, function () { if (b._allowZoom()) { if ((clearTimeout(e), (b.st.removalDelay = g), !a)) { if (((a = b._getItemToZoom()), !a)) { return; } f = j(a); } f.css(b._getOffset(!0)), b.wrap.append(f), b.content.css("visibility", "hidden"), setTimeout(function () { f.css(b._getOffset()); }, 16); } }), w(h + d, function () { b._allowZoom() && (k(), f && f.remove(), (a = null)); }); } }, _allowZoom: function () { return "image" === b.currItem.type; }, _getItemToZoom: function () { return b.currItem.hasSize ? b.currItem.img : !1; }, _getOffset: function (c) { var d; d = c ? b.currItem.img : b.st.zoom.opener(b.currItem.el || b.currItem); var e = d.offset(), f = parseInt(d.css("padding-top"), 10), g = parseInt(d.css("padding-bottom"), 10); e.top -= a(window).scrollTop() - f; var h = { width: d.width(), height: (u ? d.innerHeight() : d[0].offsetHeight) - g - f, }; return ( O() ? (h["-moz-transform"] = h.transform = "translate(" + e.left + "px," + e.top + "px)") : ((h.left = e.left), (h.top = e.top)), h ); }, }, }); var P = "iframe", Q = "//about:blank", R = function (a) { if (b.currTemplate[P]) { var c = b.currTemplate[P].find("iframe"); c.length && (a || (c[0].src = Q), b.isIE8 && c.css("display", a ? "block" : "none")); } }; a.magnificPopup.registerModule(P, { options: { markup: '
', srcAction: "iframe_src", patterns: { youtube: { index: "youtube.com", id: "v=", src: "//www.youtube.com/embed/%id%?autoplay=1", }, vimeo: { index: "vimeo.com/", id: "/", src: "//player.vimeo.com/video/%id%?autoplay=1", }, gmaps: { index: "//maps.google.", src: "%id%&output=embed" }, }, }, proto: { initIframe: function () { b.types.push(P), w("BeforeChange", function (a, b, c) { b !== c && (b === P ? R() : c === P && R(!0)); }), w(h + "." + P, function () { R(); }); }, getIframe: function (c, d) { var e = c.src, f = b.st.iframe; a.each(f.patterns, function () { return e.indexOf(this.index) > -1 ? (this.id && (e = "string" == typeof this.id ? e.substr( e.lastIndexOf(this.id) + this.id.length, e.length ) : this.id.call(this, e)), (e = this.src.replace("%id%", e)), !1) : void 0; }); var g = {}; return ( f.srcAction && (g[f.srcAction] = e), b._parseMarkup(d, g, c), b.updateStatus("ready"), d ); }, }, }); var S = function (a) { var c = b.items.length; return a > c - 1 ? a - c : 0 > a ? c + a : a; }, T = function (a, b, c) { return a.replace(/%curr%/gi, b + 1).replace(/%total%/gi, c); }; a.magnificPopup.registerModule("gallery", { options: { enabled: !1, arrowMarkup: '', preload: [0, 2], navigateByImgClick: !0, arrows: !0, tPrev: "Previous (Left arrow key)", tNext: "Next (Right arrow key)", tCounter: "%curr% of %total%", }, proto: { initGallery: function () { var c = b.st.gallery, e = ".mfp-gallery"; return ( (b.direction = !0), c && c.enabled ? ((f += " mfp-gallery"), w(m + e, function () { c.navigateByImgClick && b.wrap.on("click" + e, ".mfp-img", function () { return b.items.length > 1 ? (b.next(), !1) : void 0; }), d.on("keydown" + e, function (a) { 37 === a.keyCode ? b.prev() : 39 === a.keyCode && b.next(); }); }), w("UpdateStatus" + e, function (a, c) { c.text && (c.text = T(c.text, b.currItem.index, b.items.length)); }), w(l + e, function (a, d, e, f) { var g = b.items.length; e.counter = g > 1 ? T(c.tCounter, f.index, g) : ""; }), w("BuildControls" + e, function () { if (b.items.length > 1 && c.arrows && !b.arrowLeft) { var d = c.arrowMarkup, e = (b.arrowLeft = a( d.replace(/%title%/gi, c.tPrev).replace(/%dir%/gi, "left") ).addClass(s)), f = (b.arrowRight = a( d .replace(/%title%/gi, c.tNext) .replace(/%dir%/gi, "right") ).addClass(s)); e.click(function () { b.prev(); }), f.click(function () { b.next(); }), b.container.append(e.add(f)); } }), w(n + e, function () { b._preloadTimeout && clearTimeout(b._preloadTimeout), (b._preloadTimeout = setTimeout(function () { b.preloadNearbyImages(), (b._preloadTimeout = null); }, 16)); }), void w(h + e, function () { d.off(e), b.wrap.off("click" + e), (b.arrowRight = b.arrowLeft = null); })) : !1 ); }, next: function () { (b.direction = !0), (b.index = S(b.index + 1)), b.updateItemHTML(); }, prev: function () { (b.direction = !1), (b.index = S(b.index - 1)), b.updateItemHTML(); }, goTo: function (a) { (b.direction = a >= b.index), (b.index = a), b.updateItemHTML(); }, preloadNearbyImages: function () { var a, c = b.st.gallery.preload, d = Math.min(c[0], b.items.length), e = Math.min(c[1], b.items.length); for (a = 1; a <= (b.direction ? e : d); a++) { b._preloadItem(b.index + a); } for (a = 1; a <= (b.direction ? d : e); a++) { b._preloadItem(b.index - a); } }, _preloadItem: function (c) { if (((c = S(c)), !b.items[c].preloaded)) { var d = b.items[c]; d.parsed || (d = b.parseEl(c)), y("LazyLoad", d), "image" === d.type && (d.img = a('') .on("load.mfploader", function () { d.hasSize = !0; }) .on("error.mfploader", function () { (d.hasSize = !0), (d.loadError = !0), y("LazyLoadError", d); }) .attr("src", d.src)), (d.preloaded = !0); } }, }, }); var U = "retina"; a.magnificPopup.registerModule(U, { options: { replaceSrc: function (a) { return a.src.replace(/\.\w+$/, function (a) { return "@2x" + a; }); }, ratio: 1, }, proto: { initRetina: function () { if (window.devicePixelRatio > 1) { var a = b.st.retina, c = a.ratio; (c = isNaN(c) ? c() : c), c > 1 && (w("ImageHasSize." + U, function (a, b) { b.img.css({ "max-width": b.img[0].naturalWidth / c, width: "100%", }); }), w("ElementParse." + U, function (b, d) { d.src = a.replaceSrc(d, c); })); } }, }, }), A(); }); /***/ }), /***/ "../../node_modules/gsap/CSSPlugin.js": /*!********************************************!*\ !*** ../../node_modules/gsap/CSSPlugin.js ***! \********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ CSSPlugin: function() { return /* binding */ CSSPlugin; }, /* harmony export */ _createElement: function() { return /* binding */ _createElement; }, /* harmony export */ _getBBox: function() { return /* binding */ _getBBox; }, /* harmony export */ checkPrefix: function() { return /* binding */ _checkPropPrefix; }, /* harmony export */ "default": function() { return /* binding */ CSSPlugin; } /* harmony export */ }); /* harmony import */ var _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./gsap-core.js */ "../../node_modules/gsap/gsap-core.js"); /*! * CSSPlugin 3.12.2 * https://greensock.com * * Copyright 2008-2023, GreenSock. All rights reserved. * Subject to the terms at https://greensock.com/standard-license or for * Club GreenSock members, the agreement issued with that membership. * @author: Jack Doyle, jack@greensock.com */ /* eslint-disable */ var _win, _doc, _docElement, _pluginInitted, _tempDiv, _tempDivStyler, _recentSetterPlugin, _reverting, _windowExists = function _windowExists() { return typeof window !== "undefined"; }, _transformProps = {}, _RAD2DEG = 180 / Math.PI, _DEG2RAD = Math.PI / 180, _atan2 = Math.atan2, _bigNum = 1e8, _capsExp = /([A-Z])/g, _horizontalExp = /(left|right|width|margin|padding|x)/i, _complexExp = /[\s,\(]\S/, _propertyAliases = { autoAlpha: "opacity,visibility", scale: "scaleX,scaleY", alpha: "opacity" }, _renderCSSProp = function _renderCSSProp(ratio, data) { return data.set(data.t, data.p, Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u, data); }, _renderPropWithEnd = function _renderPropWithEnd(ratio, data) { return data.set(data.t, data.p, ratio === 1 ? data.e : Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u, data); }, _renderCSSPropWithBeginning = function _renderCSSPropWithBeginning(ratio, data) { return data.set(data.t, data.p, ratio ? Math.round((data.s + data.c * ratio) * 10000) / 10000 + data.u : data.b, data); }, //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) _renderRoundedCSSProp = function _renderRoundedCSSProp(ratio, data) { var value = data.s + data.c * ratio; data.set(data.t, data.p, ~~(value + (value < 0 ? -.5 : .5)) + data.u, data); }, _renderNonTweeningValue = function _renderNonTweeningValue(ratio, data) { return data.set(data.t, data.p, ratio ? data.e : data.b, data); }, _renderNonTweeningValueOnlyAtEnd = function _renderNonTweeningValueOnlyAtEnd(ratio, data) { return data.set(data.t, data.p, ratio !== 1 ? data.b : data.e, data); }, _setterCSSStyle = function _setterCSSStyle(target, property, value) { return target.style[property] = value; }, _setterCSSProp = function _setterCSSProp(target, property, value) { return target.style.setProperty(property, value); }, _setterTransform = function _setterTransform(target, property, value) { return target._gsap[property] = value; }, _setterScale = function _setterScale(target, property, value) { return target._gsap.scaleX = target._gsap.scaleY = value; }, _setterScaleWithRender = function _setterScaleWithRender(target, property, value, data, ratio) { var cache = target._gsap; cache.scaleX = cache.scaleY = value; cache.renderTransform(ratio, cache); }, _setterTransformWithRender = function _setterTransformWithRender(target, property, value, data, ratio) { var cache = target._gsap; cache[property] = value; cache.renderTransform(ratio, cache); }, _transformProp = "transform", _transformOriginProp = _transformProp + "Origin", _saveStyle = function _saveStyle(property, isNotCSS) { var _this = this; var target = this.target, style = target.style; if (property in _transformProps && style) { this.tfm = this.tfm || {}; if (property !== "transform") { property = _propertyAliases[property] || property; ~property.indexOf(",") ? property.split(",").forEach(function (a) { return _this.tfm[a] = _get(target, a); }) : this.tfm[property] = target._gsap.x ? target._gsap[property] : _get(target, property); // note: scale would map to "scaleX,scaleY", thus we loop and apply them both. } else { return _propertyAliases.transform.split(",").forEach(function (p) { return _saveStyle.call(_this, p, isNotCSS); }); } if (this.props.indexOf(_transformProp) >= 0) { return; } if (target._gsap.svg) { this.svgo = target.getAttribute("data-svg-origin"); this.props.push(_transformOriginProp, isNotCSS, ""); } property = _transformProp; } (style || isNotCSS) && this.props.push(property, isNotCSS, style[property]); }, _removeIndependentTransforms = function _removeIndependentTransforms(style) { if (style.translate) { style.removeProperty("translate"); style.removeProperty("scale"); style.removeProperty("rotate"); } }, _revertStyle = function _revertStyle() { var props = this.props, target = this.target, style = target.style, cache = target._gsap, i, p; for (i = 0; i < props.length; i += 3) { // stored like this: property, isNotCSS, value props[i + 1] ? target[props[i]] = props[i + 2] : props[i + 2] ? style[props[i]] = props[i + 2] : style.removeProperty(props[i].substr(0, 2) === "--" ? props[i] : props[i].replace(_capsExp, "-$1").toLowerCase()); } if (this.tfm) { for (p in this.tfm) { cache[p] = this.tfm[p]; } if (cache.svg) { cache.renderTransform(); target.setAttribute("data-svg-origin", this.svgo || ""); } i = _reverting(); if ((!i || !i.isStart) && !style[_transformProp]) { _removeIndependentTransforms(style); 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. } } }, _getStyleSaver = function _getStyleSaver(target, properties) { var saver = { target: target, props: [], revert: _revertStyle, save: _saveStyle }; 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. properties && properties.split(",").forEach(function (p) { return saver.save(p); }); return saver; }, _supports3D, _createElement = function _createElement(type, ns) { 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. return 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://greensock.com/forums/topic/20215-problem-using-tweenmax-in-standalone-self-containing-svg-file-err-cannot-set-property-csstext-of-undefined/). }, _getComputedProperty = function _getComputedProperty(target, property, skipPrefixFallback) { var cs = getComputedStyle(target); 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. }, _prefixes = "O,Moz,ms,Ms,Webkit".split(","), _checkPropPrefix = function _checkPropPrefix(property, element, preferPrefix) { var e = element || _tempDiv, s = e.style, i = 5; if (property in s && !preferPrefix) { return property; } property = property.charAt(0).toUpperCase() + property.substr(1); while (i-- && !(_prefixes[i] + property in s)) {} return i < 0 ? null : (i === 3 ? "ms" : i >= 0 ? _prefixes[i] : "") + property; }, _initCore = function _initCore() { if (_windowExists() && window.document) { _win = window; _doc = _win.document; _docElement = _doc.documentElement; _tempDiv = _createElement("div") || { style: {} }; _tempDivStyler = _createElement("div"); _transformProp = _checkPropPrefix(_transformProp); _transformOriginProp = _transformProp + "Origin"; _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. _supports3D = !!_checkPropPrefix("perspective"); _reverting = _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.gsap.core.reverting; _pluginInitted = 1; } }, _getBBoxHack = function _getBBoxHack(swapIfPossible) { //works around issues in some browsers (like Firefox) that don't correctly report getBBox() on SVG elements inside a element and/or . 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). var svg = _createElement("svg", this.ownerSVGElement && this.ownerSVGElement.getAttribute("xmlns") || "http://www.w3.org/2000/svg"), oldParent = this.parentNode, oldSibling = this.nextSibling, oldCSS = this.style.cssText, bbox; _docElement.appendChild(svg); svg.appendChild(this); this.style.display = "block"; if (swapIfPossible) { try { bbox = this.getBBox(); this._gsapBBox = this.getBBox; //store the original this.getBBox = _getBBoxHack; } catch (e) {} } else if (this._gsapBBox) { bbox = this._gsapBBox(); } if (oldParent) { if (oldSibling) { oldParent.insertBefore(this, oldSibling); } else { oldParent.appendChild(this); } } _docElement.removeChild(svg); this.style.cssText = oldCSS; return bbox; }, _getAttributeFallbacks = function _getAttributeFallbacks(target, attributesArray) { var i = attributesArray.length; while (i--) { if (target.hasAttribute(attributesArray[i])) { return target.getAttribute(attributesArray[i]); } } }, _getBBox = function _getBBox(target) { var bounds; try { bounds = target.getBBox(); //Firefox throws errors if you try calling getBBox() on an SVG element that's not rendered (like in a or ). https://bugzilla.mozilla.org/show_bug.cgi?id=612118 } catch (error) { bounds = _getBBoxHack.call(target, true); } bounds && (bounds.width || bounds.height) || target.getBBox === _getBBoxHack || (bounds = _getBBoxHack.call(target, true)); //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. return bounds && !bounds.width && !bounds.x && !bounds.y ? { x: +_getAttributeFallbacks(target, ["x", "cx", "x1"]) || 0, y: +_getAttributeFallbacks(target, ["y", "cy", "y1"]) || 0, width: 0, height: 0 } : bounds; }, _isSVG = function _isSVG(e) { return !!(e.getCTM && (!e.parentNode || e.ownerSVGElement) && _getBBox(e)); }, //reports if the element is an SVG on which getBBox() actually works _removeProperty = function _removeProperty(target, property) { if (property) { var style = target.style; if (property in _transformProps && property !== _transformOriginProp) { property = _transformProp; } if (style.removeProperty) { if (property.substr(0, 2) === "ms" || property.substr(0, 6) === "webkit") { //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) property = "-" + property; } style.removeProperty(property.replace(_capsExp, "-$1").toLowerCase()); } else { //note: old versions of IE use "removeAttribute()" instead of "removeProperty()" style.removeAttribute(property); } } }, _addNonTweeningPT = function _addNonTweeningPT(plugin, target, property, beginning, end, onlySetAtEnd) { var pt = new _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.PropTween(plugin._pt, target, property, 0, 1, onlySetAtEnd ? _renderNonTweeningValueOnlyAtEnd : _renderNonTweeningValue); plugin._pt = pt; pt.b = beginning; pt.e = end; plugin._props.push(property); return pt; }, _nonConvertibleUnits = { deg: 1, rad: 1, turn: 1 }, _nonStandardLayouts = { grid: 1, flex: 1 }, //takes a single value like 20px and converts it to the unit specified, like "%", returning only the numeric amount. _convertToUnit = function _convertToUnit(target, property, value, unit) { var curValue = parseFloat(value) || 0, curUnit = (value + "").trim().substr((curValue + "").length) || "px", // some browsers leave extra whitespace at the beginning of CSS variables, hence the need to trim() style = _tempDiv.style, horizontal = _horizontalExp.test(property), isRootSVG = target.tagName.toLowerCase() === "svg", measureProperty = (isRootSVG ? "client" : "offset") + (horizontal ? "Width" : "Height"), amount = 100, toPixels = unit === "px", toPercent = unit === "%", px, parent, cache, isSVG; if (unit === curUnit || !curValue || _nonConvertibleUnits[unit] || _nonConvertibleUnits[curUnit]) { return curValue; } curUnit !== "px" && !toPixels && (curValue = _convertToUnit(target, property, value, "px")); isSVG = target.getCTM && _isSVG(target); if ((toPercent || curUnit === "%") && (_transformProps[property] || ~property.indexOf("adius"))) { px = isSVG ? target.getBBox()[horizontal ? "width" : "height"] : target[measureProperty]; return (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(toPercent ? curValue / px * amount : curValue / 100 * px); } style[horizontal ? "width" : "height"] = amount + (toPixels ? curUnit : unit); parent = ~property.indexOf("adius") || unit === "em" && target.appendChild && !isRootSVG ? target : target.parentNode; if (isSVG) { parent = (target.ownerSVGElement || {}).parentNode; } if (!parent || parent === _doc || !parent.appendChild) { parent = _doc.body; } cache = parent._gsap; if (cache && toPercent && cache.width && horizontal && cache.time === _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._ticker.time && !cache.uncache) { return (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(curValue / cache.width * amount); } else { (toPercent || curUnit === "%") && !_nonStandardLayouts[_getComputedProperty(parent, "display")] && (style.position = _getComputedProperty(target, "position")); 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. parent.appendChild(_tempDiv); px = _tempDiv[measureProperty]; parent.removeChild(_tempDiv); style.position = "absolute"; if (horizontal && toPercent) { cache = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._getCache)(parent); cache.time = _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._ticker.time; cache.width = parent[measureProperty]; } } return (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(toPixels ? px * curValue / amount : px && curValue ? amount / px * curValue : 0); }, _get = function _get(target, property, unit, uncache) { var value; _pluginInitted || _initCore(); if (property in _propertyAliases && property !== "transform") { property = _propertyAliases[property]; if (~property.indexOf(",")) { property = property.split(",")[0]; } } if (_transformProps[property] && property !== "transform") { value = _parseTransform(target, uncache); value = property !== "transformOrigin" ? value[property] : value.svg ? value.origin : _firstTwoOnly(_getComputedProperty(target, _transformOriginProp)) + " " + value.zOrigin + "px"; } else { value = target.style[property]; if (!value || value === "auto" || uncache || ~(value + "").indexOf("calc(")) { 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 } } return unit && !~(value + "").trim().indexOf(" ") ? _convertToUnit(target, property, value, unit) + unit : value; }, _tweenComplexCSSString = function _tweenComplexCSSString(target, prop, start, end) { // 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. if (!start || start === "none") { // 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://greensock.com/forums/topic/18310-clippath-doesnt-work-on-ios/ var p = _checkPropPrefix(prop, target, 1), s = p && _getComputedProperty(target, p, 1); if (s && s !== start) { prop = p; start = s; } else if (prop === "borderColor") { start = _getComputedProperty(target, "borderTopColor"); // Firefox bug: always reports "borderColor" as "", so we must fall back to borderTopColor. See https://greensock.com/forums/topic/24583-how-to-return-colors-that-i-had-after-reverse/ } } 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), index = 0, matchIndex = 0, a, result, startValues, startNum, color, startValue, endValue, endNum, chunk, endUnit, startUnit, endValues; pt.b = start; pt.e = end; start += ""; // ensure values are strings end += ""; if (end === "auto") { target.style[prop] = end; end = _getComputedProperty(target, prop) || end; target.style[prop] = start; } a = [start, end]; (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(). start = a[0]; end = a[1]; startValues = start.match(_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._numWithUnitExp) || []; endValues = end.match(_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._numWithUnitExp) || []; if (endValues.length) { while (result = _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._numWithUnitExp.exec(end)) { endValue = result[0]; chunk = end.substring(index, result.index); if (color) { color = (color + 1) % 5; } else if (chunk.substr(-5) === "rgba(" || chunk.substr(-5) === "hsla(") { color = 1; } if (endValue !== (startValue = startValues[matchIndex++] || "")) { startNum = parseFloat(startValue) || 0; startUnit = startValue.substr((startNum + "").length); endValue.charAt(1) === "=" && (endValue = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._parseRelative)(startNum, endValue) + startUnit); endNum = parseFloat(endValue); endUnit = endValue.substr((endNum + "").length); index = _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._numWithUnitExp.lastIndex - endUnit.length; if (!endUnit) { //if something like "perspective:300" is passed in and we must add a unit to the end endUnit = endUnit || _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._config.units[prop] || startUnit; if (index === end.length) { end += endUnit; pt.e += endUnit; } } if (startUnit !== endUnit) { startNum = _convertToUnit(target, prop, startValue, endUnit) || 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. pt._pt = { _next: pt._pt, p: chunk || matchIndex === 1 ? chunk : ",", //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. s: startNum, c: endNum - startNum, m: color && color < 4 || prop === "zIndex" ? Math.round : 0 }; } } 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) } else { pt.r = prop === "display" && end === "none" ? _renderNonTweeningValueOnlyAtEnd : _renderNonTweeningValue; } _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). 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. return pt; }, _keywordToPercent = { top: "0%", bottom: "100%", left: "0%", right: "100%", center: "50%" }, _convertKeywordsToPercentages = function _convertKeywordsToPercentages(value) { var split = value.split(" "), x = split[0], y = split[1] || "50%"; if (x === "top" || x === "bottom" || y === "left" || y === "right") { //the user provided them in the wrong order, so flip them value = x; x = y; y = value; } split[0] = _keywordToPercent[x] || x; split[1] = _keywordToPercent[y] || y; return split.join(" "); }, _renderClearProps = function _renderClearProps(ratio, data) { if (data.tween && data.tween._time === data.tween._dur) { var target = data.t, style = target.style, props = data.u, cache = target._gsap, prop, clearTransforms, i; if (props === "all" || props === true) { style.cssText = ""; clearTransforms = 1; } else { props = props.split(","); i = props.length; while (--i > -1) { prop = props[i]; if (_transformProps[prop]) { clearTransforms = 1; prop = prop === "transformOrigin" ? _transformOriginProp : _transformProp; } _removeProperty(target, prop); } } if (clearTransforms) { _removeProperty(target, _transformProp); if (cache) { cache.svg && target.removeAttribute("transform"); _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. cache.uncache = 1; _removeIndependentTransforms(style); } } } }, // note: specialProps should return 1 if (and only if) they have a non-zero priority. It indicates we need to sort the linked list. _specialProps = { clearProps: function clearProps(plugin, target, property, endValue, tween) { if (tween.data !== "isFromStart") { var pt = plugin._pt = new _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.PropTween(plugin._pt, target, property, 0, 0, _renderClearProps); pt.u = endValue; pt.pr = -10; pt.tween = tween; plugin._props.push(property); return 1; } } /* className feature (about 0.4kb gzipped). , className(plugin, target, property, endValue, tween) { let _renderClassName = (ratio, data) => { data.css.render(ratio, data.css); if (!ratio || ratio === 1) { let inline = data.rmv, target = data.t, p; target.setAttribute("class", ratio ? data.e : data.b); for (p in inline) { _removeProperty(target, p); } } }, _getAllStyles = (target) => { let styles = {}, computed = getComputedStyle(target), p; for (p in computed) { if (isNaN(p) && p !== "cssText" && p !== "length") { styles[p] = computed[p]; } } _setDefaults(styles, _parseTransform(target, 1)); return styles; }, startClassList = target.getAttribute("class"), style = target.style, cssText = style.cssText, cache = target._gsap, classPT = cache.classPT, inlineToRemoveAtEnd = {}, 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) : "")}, changingVars = {}, startVars = _getAllStyles(target), transformRelated = /(transform|perspective)/i, endVars, p; if (classPT) { classPT.r(1, classPT.d); _removeLinkedListItem(classPT.d.plugin, classPT, "_pt"); } target.setAttribute("class", data.e); endVars = _getAllStyles(target, true); target.setAttribute("class", startClassList); for (p in endVars) { if (endVars[p] !== startVars[p] && !transformRelated.test(p)) { changingVars[p] = endVars[p]; if (!style[p] && style[p] !== "0") { inlineToRemoveAtEnd[p] = 1; } } } cache.classPT = plugin._pt = new PropTween(plugin._pt, target, "className", 0, 0, _renderClassName, data, 0, -11); 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://greensock.com/forums/topic/20368-possible-gsap-bug-switching-classnames-in-chrome/. 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). } _parseTransform(target, true); //to clear the caching of transforms data.css = new gsap.plugins.css(); data.css.init(target, changingVars, tween); plugin._props.push(...data.css._props); return 1; } */ }, /* * -------------------------------------------------------------------------------------- * TRANSFORMS * -------------------------------------------------------------------------------------- */ _identity2DMatrix = [1, 0, 0, 1, 0, 0], _rotationalProperties = {}, _isNullTransform = function _isNullTransform(value) { return value === "matrix(1, 0, 0, 1, 0, 0)" || value === "none" || !value; }, _getComputedTransformMatrixAsArray = function _getComputedTransformMatrixAsArray(target) { var matrixString = _getComputedProperty(target, _transformProp); return _isNullTransform(matrixString) ? _identity2DMatrix : matrixString.substr(7).match(_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._numExp).map(_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round); }, _getMatrix = function _getMatrix(target, force2D) { var cache = target._gsap || (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._getCache)(target), style = target.style, matrix = _getComputedTransformMatrixAsArray(target), parent, nextSibling, temp, addedToDOM; if (cache.svg && target.getAttribute("transform")) { 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. matrix = [temp.a, temp.b, temp.c, temp.d, temp.e, temp.f]; return matrix.join(",") === "1,0,0,1,0,0" ? _identity2DMatrix : matrix; } else if (matrix === _identity2DMatrix && !target.offsetParent && target !== _docElement && !cache.svg) { //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 //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). temp = style.display; style.display = "block"; parent = target.parentNode; if (!parent || !target.offsetParent) { // 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 addedToDOM = 1; //flag nextSibling = target.nextElementSibling; _docElement.appendChild(target); //we must add it to the DOM in order to get values properly } matrix = _getComputedTransformMatrixAsArray(target); temp ? style.display = temp : _removeProperty(target, "display"); if (addedToDOM) { nextSibling ? parent.insertBefore(target, nextSibling) : parent ? parent.appendChild(target) : _docElement.removeChild(target); } } return force2D && matrix.length > 6 ? [matrix[0], matrix[1], matrix[4], matrix[5], matrix[12], matrix[13]] : matrix; }, _applySVGOrigin = function _applySVGOrigin(target, origin, originIsAbsolute, smooth, matrixArray, pluginToAddPropTweensTo) { var cache = target._gsap, matrix = matrixArray || _getMatrix(target, true), xOriginOld = cache.xOrigin || 0, yOriginOld = cache.yOrigin || 0, xOffsetOld = cache.xOffset || 0, yOffsetOld = cache.yOffset || 0, a = matrix[0], b = matrix[1], c = matrix[2], d = matrix[3], tx = matrix[4], ty = matrix[5], originSplit = origin.split(" "), xOrigin = parseFloat(originSplit[0]) || 0, yOrigin = parseFloat(originSplit[1]) || 0, bounds, determinant, x, y; if (!originIsAbsolute) { bounds = _getBBox(target); xOrigin = bounds.x + (~originSplit[0].indexOf("%") ? xOrigin / 100 * bounds.width : xOrigin); yOrigin = bounds.y + (~(originSplit[1] || originSplit[0]).indexOf("%") ? yOrigin / 100 * bounds.height : yOrigin); } else if (matrix !== _identity2DMatrix && (determinant = a * d - b * c)) { //if it's zero (like if scaleX and scaleY are zero), skip it to avoid errors with dividing by zero. x = xOrigin * (d / determinant) + yOrigin * (-c / determinant) + (c * ty - d * tx) / determinant; y = xOrigin * (-b / determinant) + yOrigin * (a / determinant) - (a * ty - b * tx) / determinant; xOrigin = x; yOrigin = y; } if (smooth || smooth !== false && cache.smooth) { tx = xOrigin - xOriginOld; ty = yOrigin - yOriginOld; cache.xOffset = xOffsetOld + (tx * a + ty * c) - tx; cache.yOffset = yOffsetOld + (tx * b + ty * d) - ty; } else { cache.xOffset = cache.yOffset = 0; } cache.xOrigin = xOrigin; cache.yOrigin = yOrigin; cache.smooth = !!smooth; cache.origin = origin; cache.originIsAbsolute = !!originIsAbsolute; 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). if (pluginToAddPropTweensTo) { _addNonTweeningPT(pluginToAddPropTweensTo, cache, "xOrigin", xOriginOld, xOrigin); _addNonTweeningPT(pluginToAddPropTweensTo, cache, "yOrigin", yOriginOld, yOrigin); _addNonTweeningPT(pluginToAddPropTweensTo, cache, "xOffset", xOffsetOld, cache.xOffset); _addNonTweeningPT(pluginToAddPropTweensTo, cache, "yOffset", yOffsetOld, cache.yOffset); } target.setAttribute("data-svg-origin", xOrigin + " " + yOrigin); }, _parseTransform = function _parseTransform(target, uncache) { var cache = target._gsap || new _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.GSCache(target); if ("x" in cache && !uncache && !cache.uncache) { return cache; } var style = target.style, invertedScaleX = cache.scaleX < 0, px = "px", deg = "deg", cs = getComputedStyle(target), origin = _getComputedProperty(target, _transformOriginProp) || "0", x, y, z, scaleX, scaleY, rotation, rotationX, rotationY, skewX, skewY, perspective, xOrigin, yOrigin, matrix, angle, cos, sin, a, b, c, d, a12, a22, t1, t2, t3, a13, a23, a33, a42, a43, a32; x = y = z = rotation = rotationX = rotationY = skewX = skewY = perspective = 0; scaleX = scaleY = 1; cache.svg = !!(target.getCTM && _isSVG(target)); if (cs.translate) { // accommodate independent transforms by combining them into normal ones. if (cs.translate !== "none" || cs.scale !== "none" || cs.rotate !== "none") { 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] : ""); } style.scale = style.rotate = style.translate = "none"; } matrix = _getMatrix(target, cache.svg); if (cache.svg) { if (cache.uncache) { // 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. t2 = target.getBBox(); origin = cache.xOrigin - t2.x + "px " + (cache.yOrigin - t2.y) + "px"; t1 = ""; } else { 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. } _applySVGOrigin(target, t1 || origin, !!t1 || cache.originIsAbsolute, cache.smooth !== false, matrix); } xOrigin = cache.xOrigin || 0; yOrigin = cache.yOrigin || 0; if (matrix !== _identity2DMatrix) { a = matrix[0]; //a11 b = matrix[1]; //a21 c = matrix[2]; //a31 d = matrix[3]; //a41 x = a12 = matrix[4]; y = a22 = matrix[5]; //2D matrix if (matrix.length === 6) { scaleX = Math.sqrt(a * a + b * b); scaleY = Math.sqrt(d * d + c * c); 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). skewX = c || d ? _atan2(c, d) * _RAD2DEG + rotation : 0; skewX && (scaleY *= Math.abs(Math.cos(skewX * _DEG2RAD))); if (cache.svg) { x -= xOrigin - (xOrigin * a + yOrigin * c); y -= yOrigin - (xOrigin * b + yOrigin * d); } //3D matrix } else { a32 = matrix[6]; a42 = matrix[7]; a13 = matrix[8]; a23 = matrix[9]; a33 = matrix[10]; a43 = matrix[11]; x = matrix[12]; y = matrix[13]; z = matrix[14]; angle = _atan2(a32, a33); rotationX = angle * _RAD2DEG; //rotationX if (angle) { cos = Math.cos(-angle); sin = Math.sin(-angle); t1 = a12 * cos + a13 * sin; t2 = a22 * cos + a23 * sin; t3 = a32 * cos + a33 * sin; a13 = a12 * -sin + a13 * cos; a23 = a22 * -sin + a23 * cos; a33 = a32 * -sin + a33 * cos; a43 = a42 * -sin + a43 * cos; a12 = t1; a22 = t2; a32 = t3; } //rotationY angle = _atan2(-c, a33); rotationY = angle * _RAD2DEG; if (angle) { cos = Math.cos(-angle); sin = Math.sin(-angle); t1 = a * cos - a13 * sin; t2 = b * cos - a23 * sin; t3 = c * cos - a33 * sin; a43 = d * sin + a43 * cos; a = t1; b = t2; c = t3; } //rotationZ angle = _atan2(b, a); rotation = angle * _RAD2DEG; if (angle) { cos = Math.cos(angle); sin = Math.sin(angle); t1 = a * cos + b * sin; t2 = a12 * cos + a22 * sin; b = b * cos - a * sin; a22 = a22 * cos - a12 * sin; a = t1; a12 = t2; } if (rotationX && Math.abs(rotationX) + Math.abs(rotation) > 359.9) { //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. rotationX = rotation = 0; rotationY = 180 - rotationY; } scaleX = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(Math.sqrt(a * a + b * b + c * c)); scaleY = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(Math.sqrt(a22 * a22 + a32 * a32)); angle = _atan2(a12, a22); skewX = Math.abs(angle) > 0.0002 ? angle * _RAD2DEG : 0; perspective = a43 ? 1 / (a43 < 0 ? -a43 : a43) : 0; } if (cache.svg) { //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). t1 = target.getAttribute("transform"); cache.forceCSS = target.setAttribute("transform", "") || !_isNullTransform(_getComputedProperty(target, _transformProp)); t1 && target.setAttribute("transform", t1); } } if (Math.abs(skewX) > 90 && Math.abs(skewX) < 270) { if (invertedScaleX) { scaleX *= -1; skewX += rotation <= 0 ? 180 : -180; rotation += rotation <= 0 ? 180 : -180; } else { scaleY *= -1; skewX += skewX <= 0 ? 180 : -180; } } uncache = uncache || cache.uncache; 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; 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; cache.z = z + px; cache.scaleX = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(scaleX); cache.scaleY = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(scaleY); cache.rotation = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(rotation) + deg; cache.rotationX = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(rotationX) + deg; cache.rotationY = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(rotationY) + deg; cache.skewX = skewX + deg; cache.skewY = skewY + deg; cache.transformPerspective = perspective + px; if (cache.zOrigin = parseFloat(origin.split(" ")[2]) || 0) { style[_transformOriginProp] = _firstTwoOnly(origin); } cache.xOffset = cache.yOffset = 0; cache.force3D = _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._config.force3D; cache.renderTransform = cache.svg ? _renderSVGTransforms : _supports3D ? _renderCSSTransforms : _renderNon3DTransforms; cache.uncache = 0; return cache; }, _firstTwoOnly = function _firstTwoOnly(value) { return (value = value.split(" "))[0] + " " + value[1]; }, //for handling transformOrigin values, stripping out the 3rd dimension _addPxTranslate = function _addPxTranslate(target, start, value) { var unit = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.getUnit)(start); return (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(parseFloat(start) + parseFloat(_convertToUnit(target, "x", value + "px", unit))) + unit; }, _renderNon3DTransforms = function _renderNon3DTransforms(ratio, cache) { cache.z = "0px"; cache.rotationY = cache.rotationX = "0deg"; cache.force3D = 0; _renderCSSTransforms(ratio, cache); }, _zeroDeg = "0deg", _zeroPx = "0px", _endParenthesis = ") ", _renderCSSTransforms = function _renderCSSTransforms(ratio, cache) { var _ref = cache || this, xPercent = _ref.xPercent, yPercent = _ref.yPercent, x = _ref.x, y = _ref.y, z = _ref.z, rotation = _ref.rotation, rotationY = _ref.rotationY, rotationX = _ref.rotationX, skewX = _ref.skewX, skewY = _ref.skewY, scaleX = _ref.scaleX, scaleY = _ref.scaleY, transformPerspective = _ref.transformPerspective, force3D = _ref.force3D, target = _ref.target, zOrigin = _ref.zOrigin, transforms = "", 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) if (zOrigin && (rotationX !== _zeroDeg || rotationY !== _zeroDeg)) { var angle = parseFloat(rotationY) * _DEG2RAD, a13 = Math.sin(angle), a33 = Math.cos(angle), cos; angle = parseFloat(rotationX) * _DEG2RAD; cos = Math.cos(angle); x = _addPxTranslate(target, x, a13 * cos * -zOrigin); y = _addPxTranslate(target, y, -Math.sin(angle) * -zOrigin); z = _addPxTranslate(target, z, a33 * cos * -zOrigin + zOrigin); } if (transformPerspective !== _zeroPx) { transforms += "perspective(" + transformPerspective + _endParenthesis; } if (xPercent || yPercent) { transforms += "translate(" + xPercent + "%, " + yPercent + "%) "; } if (use3D || x !== _zeroPx || y !== _zeroPx || z !== _zeroPx) { transforms += z !== _zeroPx || use3D ? "translate3d(" + x + ", " + y + ", " + z + ") " : "translate(" + x + ", " + y + _endParenthesis; } if (rotation !== _zeroDeg) { transforms += "rotate(" + rotation + _endParenthesis; } if (rotationY !== _zeroDeg) { transforms += "rotateY(" + rotationY + _endParenthesis; } if (rotationX !== _zeroDeg) { transforms += "rotateX(" + rotationX + _endParenthesis; } if (skewX !== _zeroDeg || skewY !== _zeroDeg) { transforms += "skew(" + skewX + ", " + skewY + _endParenthesis; } if (scaleX !== 1 || scaleY !== 1) { transforms += "scale(" + scaleX + ", " + scaleY + _endParenthesis; } target.style[_transformProp] = transforms || "translate(0, 0)"; }, _renderSVGTransforms = function _renderSVGTransforms(ratio, cache) { var _ref2 = cache || this, xPercent = _ref2.xPercent, yPercent = _ref2.yPercent, x = _ref2.x, y = _ref2.y, rotation = _ref2.rotation, skewX = _ref2.skewX, skewY = _ref2.skewY, scaleX = _ref2.scaleX, scaleY = _ref2.scaleY, target = _ref2.target, xOrigin = _ref2.xOrigin, yOrigin = _ref2.yOrigin, xOffset = _ref2.xOffset, yOffset = _ref2.yOffset, forceCSS = _ref2.forceCSS, tx = parseFloat(x), ty = parseFloat(y), a11, a21, a12, a22, temp; rotation = parseFloat(rotation); skewX = parseFloat(skewX); skewY = parseFloat(skewY); if (skewY) { //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. skewY = parseFloat(skewY); skewX += skewY; rotation += skewY; } if (rotation || skewX) { rotation *= _DEG2RAD; skewX *= _DEG2RAD; a11 = Math.cos(rotation) * scaleX; a21 = Math.sin(rotation) * scaleX; a12 = Math.sin(rotation - skewX) * -scaleY; a22 = Math.cos(rotation - skewX) * scaleY; if (skewX) { skewY *= _DEG2RAD; temp = Math.tan(skewX - skewY); temp = Math.sqrt(1 + temp * temp); a12 *= temp; a22 *= temp; if (skewY) { temp = Math.tan(skewY); temp = Math.sqrt(1 + temp * temp); a11 *= temp; a21 *= temp; } } a11 = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(a11); a21 = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(a21); a12 = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(a12); a22 = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(a22); } else { a11 = scaleX; a22 = scaleY; a21 = a12 = 0; } if (tx && !~(x + "").indexOf("px") || ty && !~(y + "").indexOf("px")) { tx = _convertToUnit(target, "x", x, "px"); ty = _convertToUnit(target, "y", y, "px"); } if (xOrigin || yOrigin || xOffset || yOffset) { tx = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(tx + xOrigin - (xOrigin * a11 + yOrigin * a12) + xOffset); ty = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(ty + yOrigin - (xOrigin * a21 + yOrigin * a22) + yOffset); } if (xPercent || yPercent) { //The SVG spec doesn't support percentage-based translation in the "transform" attribute, so we merge it into the translation to simulate it. temp = target.getBBox(); tx = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(tx + xPercent / 100 * temp.width); ty = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._round)(ty + yPercent / 100 * temp.height); } temp = "matrix(" + a11 + "," + a21 + "," + a12 + "," + a22 + "," + tx + "," + ty + ")"; target.setAttribute("transform", temp); 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!) }, _addRotationalPropTween = function _addRotationalPropTween(plugin, target, property, startNum, endValue) { var cap = 360, isString = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._isString)(endValue), endNum = parseFloat(endValue) * (isString && ~endValue.indexOf("rad") ? _RAD2DEG : 1), change = endNum - startNum, finalValue = startNum + change + "deg", direction, pt; if (isString) { direction = endValue.split("_")[1]; if (direction === "short") { change %= cap; if (change !== change % (cap / 2)) { change += change < 0 ? cap : -cap; } } if (direction === "cw" && change < 0) { change = (change + cap * _bigNum) % cap - ~~(change / cap) * cap; } else if (direction === "ccw" && change > 0) { change = (change - cap * _bigNum) % cap - ~~(change / cap) * cap; } } plugin._pt = pt = new _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.PropTween(plugin._pt, target, property, startNum, change, _renderPropWithEnd); pt.e = finalValue; pt.u = "deg"; plugin._props.push(property); return pt; }, _assign = function _assign(target, source) { // Internet Explorer doesn't have Object.assign(), so we recreate it here. for (var p in source) { target[p] = source[p]; } return target; }, _addRawTransformPTs = function _addRawTransformPTs(plugin, transforms, target) { //for handling cases where someone passes in a whole transform string, like transform: "scale(2, 3) rotate(20deg) translateY(30em)" var startCache = _assign({}, target._gsap), exclude = "perspective,force3D,transformOrigin,svgOrigin", style = target.style, endCache, p, startValue, endValue, startNum, endNum, startUnit, endUnit; if (startCache.svg) { startValue = target.getAttribute("transform"); target.setAttribute("transform", ""); style[_transformProp] = transforms; endCache = _parseTransform(target, 1); _removeProperty(target, _transformProp); target.setAttribute("transform", startValue); } else { startValue = getComputedStyle(target)[_transformProp]; style[_transformProp] = transforms; endCache = _parseTransform(target, 1); style[_transformProp] = startValue; } for (p in _transformProps) { startValue = startCache[p]; endValue = endCache[p]; if (startValue !== endValue && exclude.indexOf(p) < 0) { //tweening to no perspective gives very unintuitive results - just keep the same perspective in that case. startUnit = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.getUnit)(startValue); endUnit = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.getUnit)(endValue); startNum = startUnit !== endUnit ? _convertToUnit(target, p, startValue, endUnit) : parseFloat(startValue); endNum = parseFloat(endValue); plugin._pt = new _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.PropTween(plugin._pt, endCache, p, startNum, endNum - startNum, _renderCSSProp); plugin._pt.u = endUnit || 0; plugin._props.push(p); } } _assign(endCache, startCache); }; // 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. (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._forEachName)("padding,margin,Width,Radius", function (name, index) { var t = "Top", r = "Right", b = "Bottom", l = "Left", props = (index < 3 ? [t, r, b, l] : [t + l, t + r, b + r, b + l]).map(function (side) { return index < 2 ? name + side : "border" + side + name; }); _specialProps[index > 1 ? "border" + name : name] = function (plugin, target, property, endValue, tween) { var a, vars; if (arguments.length < 4) { // getter, passed target, property, and unit (from _get()) a = props.map(function (prop) { return _get(plugin, prop, property); }); vars = a.join(" "); return vars.split(a[0]).length === 5 ? a[0] : vars; } a = (endValue + "").split(" "); vars = {}; props.forEach(function (prop, i) { return vars[prop] = a[i] = a[i] || a[(i - 1) / 2 | 0]; }); plugin.init(target, vars, tween); }; }); var CSSPlugin = { name: "css", register: _initCore, targetTest: function targetTest(target) { return target.style && target.nodeType; }, init: function init(target, vars, tween, index, targets) { var props = this._props, style = target.style, startAt = tween.vars.startAt, startValue, endValue, endNum, startNum, type, specialProp, p, startUnit, endUnit, relative, isTransformRelated, transformPropTween, cache, smooth, hasPriority, inlineProps; _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 this.styles = this.styles || _getStyleSaver(target); inlineProps = this.styles.props; this.tween = tween; for (p in vars) { if (p === "autoRound") { continue; } endValue = vars[p]; 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)) { // plugins continue; } type = typeof endValue; specialProp = _specialProps[p]; if (type === "function") { endValue = endValue.call(tween, index, target, targets); type = typeof endValue; } if (type === "string" && ~endValue.indexOf("random(")) { endValue = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._replaceRandom)(endValue); } if (specialProp) { specialProp(this, target, p, endValue, tween) && (hasPriority = 1); } else if (p.substr(0, 2) === "--") { //CSS variable startValue = (getComputedStyle(target).getPropertyValue(p) + "").trim(); endValue += ""; _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._colorExp.lastIndex = 0; if (!_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._colorExp.test(startValue)) { // colors don't have units startUnit = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.getUnit)(startValue); endUnit = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.getUnit)(endValue); } endUnit ? startUnit !== endUnit && (startValue = _convertToUnit(target, p, startValue, endUnit) + endUnit) : startUnit && (endValue += startUnit); this.add(style, "setProperty", startValue, endValue, index, targets, 0, 0, p); props.push(p); inlineProps.push(p, 0, style[p]); } else if (type !== "undefined") { if (startAt && p in startAt) { // 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) startValue = typeof startAt[p] === "function" ? startAt[p].call(tween, index, target, targets) : startAt[p]; (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._isString)(startValue) && ~startValue.indexOf("random(") && (startValue = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._replaceRandom)(startValue)); (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.getUnit)(startValue + "") || (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. (startValue + "").charAt(1) === "=" && (startValue = _get(target, p)); // can't work with relative values } else { startValue = _get(target, p); } startNum = parseFloat(startValue); relative = type === "string" && endValue.charAt(1) === "=" && endValue.substr(0, 2); relative && (endValue = endValue.substr(2)); endNum = parseFloat(endValue); if (p in _propertyAliases) { if (p === "autoAlpha") { //special case where we control the visibility along with opacity. We still allow the opacity value to pass through and get tweened. if (startNum === 1 && _get(target, "visibility") === "hidden" && endNum) { //if visibility is initially set to "hidden", we should interpret that as intent to make opacity 0 (a convenience) startNum = 0; } inlineProps.push("visibility", 0, style.visibility); _addNonTweeningPT(this, style, "visibility", startNum ? "inherit" : "hidden", endNum ? "inherit" : "hidden", !endNum); } if (p !== "scale" && p !== "transform") { p = _propertyAliases[p]; ~p.indexOf(",") && (p = p.split(",")[0]); } } isTransformRelated = p in _transformProps; //--- TRANSFORM-RELATED --- if (isTransformRelated) { this.styles.save(p); if (!transformPropTween) { cache = target._gsap; 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. smooth = vars.smoothOrigin !== false && cache.smooth; 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) 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. } if (p === "scale") { 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); this._pt.u = 0; props.push("scaleY", p); p += "X"; } else if (p === "transformOrigin") { inlineProps.push(_transformOriginProp, 0, style[_transformOriginProp]); endValue = _convertKeywordsToPercentages(endValue); //in case something like "left top" or "bottom right" is passed in. Convert to percentages. if (cache.svg) { _applySVGOrigin(target, endValue, 0, smooth, 0, this); } else { endUnit = parseFloat(endValue.split(" ")[2]) || 0; //handle the zOrigin separately! endUnit !== cache.zOrigin && _addNonTweeningPT(this, cache, "zOrigin", cache.zOrigin, endUnit); _addNonTweeningPT(this, style, p, _firstTwoOnly(startValue), _firstTwoOnly(endValue)); } continue; } else if (p === "svgOrigin") { _applySVGOrigin(target, endValue, 1, smooth, 0, this); continue; } else if (p in _rotationalProperties) { _addRotationalPropTween(this, cache, p, startNum, relative ? (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._parseRelative)(startNum, relative + endValue) : endValue); continue; } else if (p === "smoothOrigin") { _addNonTweeningPT(this, cache, "smooth", cache.smooth, endValue); continue; } else if (p === "force3D") { cache[p] = endValue; continue; } else if (p === "transform") { _addRawTransformPTs(this, endValue, target); continue; } } else if (!(p in style)) { p = _checkPropPrefix(p) || p; } if (isTransformRelated || (endNum || endNum === 0) && (startNum || startNum === 0) && !_complexExp.test(endValue) && p in style) { startUnit = (startValue + "").substr((startNum + "").length); endNum || (endNum = 0); // protect against NaN 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); startUnit !== endUnit && (startNum = _convertToUnit(target, p, startValue, endUnit)); 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, !isTransformRelated && (endUnit === "px" || p === "zIndex") && vars.autoRound !== false ? _renderRoundedCSSProp : _renderCSSProp); this._pt.u = endUnit || 0; if (startUnit !== endUnit && endUnit !== "%") { //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) this._pt.b = startValue; this._pt.r = _renderCSSPropWithBeginning; } } else if (!(p in style)) { if (p in target) { //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. this.add(target, p, startValue || target[p], relative ? relative + endValue : endValue, index, targets); } else if (p !== "parseTransform") { (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._missingPlugin)(p, endValue); continue; } } else { _tweenComplexCSSString.call(this, target, p, startValue, relative ? relative + endValue : endValue); } isTransformRelated || (p in style ? inlineProps.push(p, 0, style[p]) : inlineProps.push(p, 1, startValue || target[p])); props.push(p); } } hasPriority && (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._sortPropTweensByPriority)(this); }, render: function render(ratio, data) { if (data.tween._time || !_reverting()) { var pt = data._pt; while (pt) { pt.r(ratio, pt.d); pt = pt._next; } } else { data.styles.revert(); } }, get: _get, aliases: _propertyAliases, getSetter: function getSetter(target, property, plugin) { //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. var p = _propertyAliases[property]; p && p.indexOf(",") < 0 && (property = p); 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); }, core: { _removeProperty: _removeProperty, _getMatrix: _getMatrix } }; _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.gsap.utils.checkPrefix = _checkPropPrefix; _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.gsap.core.getStyleSaver = _getStyleSaver; (function (positionAndScale, rotation, others, aliases) { var all = (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._forEachName)(positionAndScale + "," + rotation + "," + others, function (name) { _transformProps[name] = 1; }); (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._forEachName)(rotation, function (name) { _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._config.units[name] = "deg"; _rotationalProperties[name] = 1; }); _propertyAliases[all[13]] = positionAndScale + "," + rotation; (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._forEachName)(aliases, function (name) { var split = name.split(":"); _propertyAliases[split[1]] = all[split[0]]; }); })("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"); (0,_gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._forEachName)("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective", function (name) { _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__._config.units[name] = "px"; }); _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.gsap.registerPlugin(CSSPlugin); /***/ }), /***/ "../../node_modules/gsap/Observer.js": /*!*******************************************!*\ !*** ../../node_modules/gsap/Observer.js ***! \*******************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Observer: function() { return /* binding */ Observer; }, /* harmony export */ _getProxyProp: function() { return /* binding */ _getProxyProp; }, /* harmony export */ _getScrollFunc: function() { return /* binding */ _getScrollFunc; }, /* harmony export */ _getTarget: function() { return /* binding */ _getTarget; }, /* harmony export */ _getVelocityProp: function() { return /* binding */ _getVelocityProp; }, /* harmony export */ _horizontal: function() { return /* binding */ _horizontal; }, /* harmony export */ _isViewport: function() { return /* binding */ _isViewport; }, /* harmony export */ _proxies: function() { return /* binding */ _proxies; }, /* harmony export */ _scrollers: function() { return /* binding */ _scrollers; }, /* harmony export */ _vertical: function() { return /* binding */ _vertical; }, /* harmony export */ "default": function() { return /* binding */ Observer; } /* harmony export */ }); function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /*! * Observer 3.12.2 * https://greensock.com * * @license Copyright 2008-2023, GreenSock. All rights reserved. * Subject to the terms at https://greensock.com/standard-license or for * Club GreenSock members, the agreement issued with that membership. * @author: Jack Doyle, jack@greensock.com */ /* eslint-disable */ var gsap, _coreInitted, _clamp, _win, _doc, _docEl, _body, _isTouch, _pointerType, ScrollTrigger, _root, _normalizer, _eventTypes, _context, _getGSAP = function _getGSAP() { return gsap || typeof window !== "undefined" && (gsap = window.gsap) && gsap.registerPlugin && gsap; }, _startup = 1, _observers = [], _scrollers = [], _proxies = [], _getTime = Date.now, _bridge = function _bridge(name, value) { return value; }, _integrate = function _integrate() { var core = ScrollTrigger.core, data = core.bridge || {}, scrollers = core._scrollers, proxies = core._proxies; scrollers.push.apply(scrollers, _scrollers); proxies.push.apply(proxies, _proxies); _scrollers = scrollers; _proxies = proxies; _bridge = function _bridge(name, value) { return data[name](value); }; }, _getProxyProp = function _getProxyProp(element, property) { return ~_proxies.indexOf(element) && _proxies[_proxies.indexOf(element) + 1][property]; }, _isViewport = function _isViewport(el) { return !!~_root.indexOf(el); }, _addListener = function _addListener(element, type, func, nonPassive, capture) { return element.addEventListener(type, func, { passive: !nonPassive, capture: !!capture }); }, _removeListener = function _removeListener(element, type, func, capture) { return element.removeEventListener(type, func, !!capture); }, _scrollLeft = "scrollLeft", _scrollTop = "scrollTop", _onScroll = function _onScroll() { return _normalizer && _normalizer.isPressed || _scrollers.cache++; }, _scrollCacheFunc = function _scrollCacheFunc(f, doNotCache) { var cachingFunc = function cachingFunc(value) { // since reading the scrollTop/scrollLeft/pageOffsetY/pageOffsetX can trigger a layout, this function allows us to cache the value so it only gets read fresh after a "scroll" event fires (or while we're refreshing because that can lengthen the page and alter the scroll position). when "soft" is true, that means don't actually set the scroll, but cache the new value instead (useful in ScrollSmoother) if (value || value === 0) { _startup && (_win.history.scrollRestoration = "manual"); // otherwise the new position will get overwritten by the browser onload. var isNormalizing = _normalizer && _normalizer.isPressed; value = cachingFunc.v = Math.round(value) || (_normalizer && _normalizer.iOS ? 1 : 0); //TODO: iOS Bug: if you allow it to go to 0, Safari can start to report super strange (wildly inaccurate) touch positions! f(value); cachingFunc.cacheID = _scrollers.cache; isNormalizing && _bridge("ss", value); // set scroll (notify ScrollTrigger so it can dispatch a "scrollStart" event if necessary } else if (doNotCache || _scrollers.cache !== cachingFunc.cacheID || _bridge("ref")) { cachingFunc.cacheID = _scrollers.cache; cachingFunc.v = f(); } return cachingFunc.v + cachingFunc.offset; }; cachingFunc.offset = 0; return f && cachingFunc; }, _horizontal = { s: _scrollLeft, p: "left", p2: "Left", os: "right", os2: "Right", d: "width", d2: "Width", a: "x", sc: _scrollCacheFunc(function (value) { return arguments.length ? _win.scrollTo(value, _vertical.sc()) : _win.pageXOffset || _doc[_scrollLeft] || _docEl[_scrollLeft] || _body[_scrollLeft] || 0; }) }, _vertical = { s: _scrollTop, p: "top", p2: "Top", os: "bottom", os2: "Bottom", d: "height", d2: "Height", a: "y", op: _horizontal, sc: _scrollCacheFunc(function (value) { return arguments.length ? _win.scrollTo(_horizontal.sc(), value) : _win.pageYOffset || _doc[_scrollTop] || _docEl[_scrollTop] || _body[_scrollTop] || 0; }) }, _getTarget = function _getTarget(t, self) { return (self && self._ctx && self._ctx.selector || gsap.utils.toArray)(t)[0] || (typeof t === "string" && gsap.config().nullTargetWarn !== false ? console.warn("Element not found:", t) : null); }, _getScrollFunc = function _getScrollFunc(element, _ref) { var s = _ref.s, sc = _ref.sc; // we store the scroller functions in an alternating sequenced Array like [element, verticalScrollFunc, horizontalScrollFunc, ...] so that we can minimize memory, maximize performance, and we also record the last position as a ".rec" property in order to revert to that after refreshing to ensure things don't shift around. _isViewport(element) && (element = _doc.scrollingElement || _docEl); var i = _scrollers.indexOf(element), offset = sc === _vertical.sc ? 1 : 2; !~i && (i = _scrollers.push(element) - 1); _scrollers[i + offset] || _addListener(element, "scroll", _onScroll); // clear the cache when a scroll occurs var prev = _scrollers[i + offset], func = prev || (_scrollers[i + offset] = _scrollCacheFunc(_getProxyProp(element, s), true) || (_isViewport(element) ? sc : _scrollCacheFunc(function (value) { return arguments.length ? element[s] = value : element[s]; }))); func.target = element; prev || (func.smooth = gsap.getProperty(element, "scrollBehavior") === "smooth"); // only set it the first time (don't reset every time a scrollFunc is requested because perhaps it happens during a refresh() when it's disabled in ScrollTrigger. return func; }, _getVelocityProp = function _getVelocityProp(value, minTimeRefresh, useDelta) { var v1 = value, v2 = value, t1 = _getTime(), t2 = t1, min = minTimeRefresh || 50, dropToZeroTime = Math.max(500, min * 3), update = function update(value, force) { var t = _getTime(); if (force || t - t1 > min) { v2 = v1; v1 = value; t2 = t1; t1 = t; } else if (useDelta) { v1 += value; } else { // not totally necessary, but makes it a bit more accurate by adjusting the v1 value according to the new slope. This way we're not just ignoring the incoming data. Removing for now because it doesn't seem to make much practical difference and it's probably not worth the kb. v1 = v2 + (value - v2) / (t - t2) * (t1 - t2); } }, reset = function reset() { v2 = v1 = useDelta ? 0 : v1; t2 = t1 = 0; }, getVelocity = function getVelocity(latestValue) { var tOld = t2, vOld = v2, t = _getTime(); (latestValue || latestValue === 0) && latestValue !== v1 && update(latestValue); return t1 === t2 || t - t2 > dropToZeroTime ? 0 : (v1 + (useDelta ? vOld : -vOld)) / ((useDelta ? t : t1) - tOld) * 1000; }; return { update: update, reset: reset, getVelocity: getVelocity }; }, _getEvent = function _getEvent(e, preventDefault) { preventDefault && !e._gsapAllow && e.preventDefault(); return e.changedTouches ? e.changedTouches[0] : e; }, _getAbsoluteMax = function _getAbsoluteMax(a) { var max = Math.max.apply(Math, a), min = Math.min.apply(Math, a); return Math.abs(max) >= Math.abs(min) ? max : min; }, _setScrollTrigger = function _setScrollTrigger() { ScrollTrigger = gsap.core.globals().ScrollTrigger; ScrollTrigger && ScrollTrigger.core && _integrate(); }, _initCore = function _initCore(core) { gsap = core || _getGSAP(); if (gsap && typeof document !== "undefined" && document.body) { _win = window; _doc = document; _docEl = _doc.documentElement; _body = _doc.body; _root = [_win, _doc, _docEl, _body]; _clamp = gsap.utils.clamp; _context = gsap.core.context || function () {}; _pointerType = "onpointerenter" in _body ? "pointer" : "mouse"; // isTouch is 0 if no touch, 1 if ONLY touch, and 2 if it can accommodate touch but also other types like mouse/pointer. _isTouch = Observer.isTouch = _win.matchMedia && _win.matchMedia("(hover: none), (pointer: coarse)").matches ? 1 : "ontouchstart" in _win || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0 ? 2 : 0; _eventTypes = Observer.eventTypes = ("ontouchstart" in _docEl ? "touchstart,touchmove,touchcancel,touchend" : !("onpointerdown" in _docEl) ? "mousedown,mousemove,mouseup,mouseup" : "pointerdown,pointermove,pointercancel,pointerup").split(","); setTimeout(function () { return _startup = 0; }, 500); _setScrollTrigger(); _coreInitted = 1; } return _coreInitted; }; _horizontal.op = _vertical; _scrollers.cache = 0; var Observer = /*#__PURE__*/function () { function Observer(vars) { this.init(vars); } var _proto = Observer.prototype; _proto.init = function init(vars) { _coreInitted || _initCore(gsap) || console.warn("Please gsap.registerPlugin(Observer)"); ScrollTrigger || _setScrollTrigger(); var tolerance = vars.tolerance, dragMinimum = vars.dragMinimum, type = vars.type, target = vars.target, lineHeight = vars.lineHeight, debounce = vars.debounce, preventDefault = vars.preventDefault, onStop = vars.onStop, onStopDelay = vars.onStopDelay, ignore = vars.ignore, wheelSpeed = vars.wheelSpeed, event = vars.event, onDragStart = vars.onDragStart, onDragEnd = vars.onDragEnd, onDrag = vars.onDrag, onPress = vars.onPress, onRelease = vars.onRelease, onRight = vars.onRight, onLeft = vars.onLeft, onUp = vars.onUp, onDown = vars.onDown, onChangeX = vars.onChangeX, onChangeY = vars.onChangeY, onChange = vars.onChange, onToggleX = vars.onToggleX, onToggleY = vars.onToggleY, onHover = vars.onHover, onHoverEnd = vars.onHoverEnd, onMove = vars.onMove, ignoreCheck = vars.ignoreCheck, isNormalizer = vars.isNormalizer, onGestureStart = vars.onGestureStart, onGestureEnd = vars.onGestureEnd, onWheel = vars.onWheel, onEnable = vars.onEnable, onDisable = vars.onDisable, onClick = vars.onClick, scrollSpeed = vars.scrollSpeed, capture = vars.capture, allowClicks = vars.allowClicks, lockAxis = vars.lockAxis, onLockAxis = vars.onLockAxis; this.target = target = _getTarget(target) || _docEl; this.vars = vars; ignore && (ignore = gsap.utils.toArray(ignore)); tolerance = tolerance || 1e-9; dragMinimum = dragMinimum || 0; wheelSpeed = wheelSpeed || 1; scrollSpeed = scrollSpeed || 1; type = type || "wheel,touch,pointer"; debounce = debounce !== false; lineHeight || (lineHeight = parseFloat(_win.getComputedStyle(_body).lineHeight) || 22); // note: browser may report "normal", so default to 22. var id, onStopDelayedCall, dragged, moved, wheeled, locked, axis, self = this, prevDeltaX = 0, prevDeltaY = 0, scrollFuncX = _getScrollFunc(target, _horizontal), scrollFuncY = _getScrollFunc(target, _vertical), scrollX = scrollFuncX(), scrollY = scrollFuncY(), limitToTouch = ~type.indexOf("touch") && !~type.indexOf("pointer") && _eventTypes[0] === "pointerdown", // for devices that accommodate mouse events and touch events, we need to distinguish. isViewport = _isViewport(target), ownerDoc = target.ownerDocument || _doc, deltaX = [0, 0, 0], // wheel, scroll, pointer/touch deltaY = [0, 0, 0], onClickTime = 0, clickCapture = function clickCapture() { return onClickTime = _getTime(); }, _ignoreCheck = function _ignoreCheck(e, isPointerOrTouch) { return (self.event = e) && ignore && ~ignore.indexOf(e.target) || isPointerOrTouch && limitToTouch && e.pointerType !== "touch" || ignoreCheck && ignoreCheck(e, isPointerOrTouch); }, onStopFunc = function onStopFunc() { self._vx.reset(); self._vy.reset(); onStopDelayedCall.pause(); onStop && onStop(self); }, update = function update() { var dx = self.deltaX = _getAbsoluteMax(deltaX), dy = self.deltaY = _getAbsoluteMax(deltaY), changedX = Math.abs(dx) >= tolerance, changedY = Math.abs(dy) >= tolerance; onChange && (changedX || changedY) && onChange(self, dx, dy, deltaX, deltaY); // in ScrollTrigger.normalizeScroll(), we need to know if it was touch/pointer so we need access to the deltaX/deltaY Arrays before we clear them out. if (changedX) { onRight && self.deltaX > 0 && onRight(self); onLeft && self.deltaX < 0 && onLeft(self); onChangeX && onChangeX(self); onToggleX && self.deltaX < 0 !== prevDeltaX < 0 && onToggleX(self); prevDeltaX = self.deltaX; deltaX[0] = deltaX[1] = deltaX[2] = 0; } if (changedY) { onDown && self.deltaY > 0 && onDown(self); onUp && self.deltaY < 0 && onUp(self); onChangeY && onChangeY(self); onToggleY && self.deltaY < 0 !== prevDeltaY < 0 && onToggleY(self); prevDeltaY = self.deltaY; deltaY[0] = deltaY[1] = deltaY[2] = 0; } if (moved || dragged) { onMove && onMove(self); if (dragged) { onDrag(self); dragged = false; } moved = false; } locked && !(locked = false) && onLockAxis && onLockAxis(self); if (wheeled) { onWheel(self); wheeled = false; } id = 0; }, onDelta = function onDelta(x, y, index) { deltaX[index] += x; deltaY[index] += y; self._vx.update(x); self._vy.update(y); debounce ? id || (id = requestAnimationFrame(update)) : update(); }, onTouchOrPointerDelta = function onTouchOrPointerDelta(x, y) { if (lockAxis && !axis) { self.axis = axis = Math.abs(x) > Math.abs(y) ? "x" : "y"; locked = true; } if (axis !== "y") { deltaX[2] += x; self._vx.update(x, true); // update the velocity as frequently as possible instead of in the debounced function so that very quick touch-scrolls (flicks) feel natural. If it's the mouse/touch/pointer, force it so that we get snappy/accurate momentum scroll. } if (axis !== "x") { deltaY[2] += y; self._vy.update(y, true); } debounce ? id || (id = requestAnimationFrame(update)) : update(); }, _onDrag = function _onDrag(e) { if (_ignoreCheck(e, 1)) { return; } e = _getEvent(e, preventDefault); var x = e.clientX, y = e.clientY, dx = x - self.x, dy = y - self.y, isDragging = self.isDragging; self.x = x; self.y = y; if (isDragging || Math.abs(self.startX - x) >= dragMinimum || Math.abs(self.startY - y) >= dragMinimum) { onDrag && (dragged = true); isDragging || (self.isDragging = true); onTouchOrPointerDelta(dx, dy); isDragging || onDragStart && onDragStart(self); } }, _onPress = self.onPress = function (e) { if (_ignoreCheck(e, 1) || e && e.button) { return; } self.axis = axis = null; onStopDelayedCall.pause(); self.isPressed = true; e = _getEvent(e); // note: may need to preventDefault(?) Won't side-scroll on iOS Safari if we do, though. prevDeltaX = prevDeltaY = 0; self.startX = self.x = e.clientX; self.startY = self.y = e.clientY; self._vx.reset(); // otherwise the t2 may be stale if the user touches and flicks super fast and releases in less than 2 requestAnimationFrame ticks, causing velocity to be 0. self._vy.reset(); _addListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, preventDefault, true); self.deltaX = self.deltaY = 0; onPress && onPress(self); }, _onRelease = self.onRelease = function (e) { if (_ignoreCheck(e, 1)) { return; } _removeListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, true); var isTrackingDrag = !isNaN(self.y - self.startY), wasDragging = self.isDragging && (Math.abs(self.x - self.startX) > 3 || Math.abs(self.y - self.startY) > 3), // some touch devices need some wiggle room in terms of sensing clicks - the finger may move a few pixels. eventData = _getEvent(e); if (!wasDragging && isTrackingDrag) { self._vx.reset(); self._vy.reset(); if (preventDefault && allowClicks) { gsap.delayedCall(0.08, function () { // some browsers (like Firefox) won't trust script-generated clicks, so if the user tries to click on a video to play it, for example, it simply won't work. Since a regular "click" event will most likely be generated anyway (one that has its isTrusted flag set to true), we must slightly delay our script-generated click so that the "real"/trusted one is prioritized. Remember, when there are duplicate events in quick succession, we suppress all but the first one. Some browsers don't even trigger the "real" one at all, so our synthetic one is a safety valve that ensures that no matter what, a click event does get dispatched. if (_getTime() - onClickTime > 300 && !e.defaultPrevented) { if (e.target.click) { //some browsers (like mobile Safari) don't properly trigger the click event e.target.click(); } else if (ownerDoc.createEvent) { var syntheticEvent = ownerDoc.createEvent("MouseEvents"); syntheticEvent.initMouseEvent("click", true, true, _win, 1, eventData.screenX, eventData.screenY, eventData.clientX, eventData.clientY, false, false, false, false, 0, null); e.target.dispatchEvent(syntheticEvent); } } }); } } self.isDragging = self.isGesturing = self.isPressed = false; onStop && !isNormalizer && onStopDelayedCall.restart(true); onDragEnd && wasDragging && onDragEnd(self); onRelease && onRelease(self, wasDragging); }, _onGestureStart = function _onGestureStart(e) { return e.touches && e.touches.length > 1 && (self.isGesturing = true) && onGestureStart(e, self.isDragging); }, _onGestureEnd = function _onGestureEnd() { return (self.isGesturing = false) || onGestureEnd(self); }, onScroll = function onScroll(e) { if (_ignoreCheck(e)) { return; } var x = scrollFuncX(), y = scrollFuncY(); onDelta((x - scrollX) * scrollSpeed, (y - scrollY) * scrollSpeed, 1); scrollX = x; scrollY = y; onStop && onStopDelayedCall.restart(true); }, _onWheel = function _onWheel(e) { if (_ignoreCheck(e)) { return; } e = _getEvent(e, preventDefault); onWheel && (wheeled = true); var multiplier = (e.deltaMode === 1 ? lineHeight : e.deltaMode === 2 ? _win.innerHeight : 1) * wheelSpeed; onDelta(e.deltaX * multiplier, e.deltaY * multiplier, 0); onStop && !isNormalizer && onStopDelayedCall.restart(true); }, _onMove = function _onMove(e) { if (_ignoreCheck(e)) { return; } var x = e.clientX, y = e.clientY, dx = x - self.x, dy = y - self.y; self.x = x; self.y = y; moved = true; (dx || dy) && onTouchOrPointerDelta(dx, dy); }, _onHover = function _onHover(e) { self.event = e; onHover(self); }, _onHoverEnd = function _onHoverEnd(e) { self.event = e; onHoverEnd(self); }, _onClick = function _onClick(e) { return _ignoreCheck(e) || _getEvent(e, preventDefault) && onClick(self); }; onStopDelayedCall = self._dc = gsap.delayedCall(onStopDelay || 0.25, onStopFunc).pause(); self.deltaX = self.deltaY = 0; self._vx = _getVelocityProp(0, 50, true); self._vy = _getVelocityProp(0, 50, true); self.scrollX = scrollFuncX; self.scrollY = scrollFuncY; self.isDragging = self.isGesturing = self.isPressed = false; _context(this); self.enable = function (e) { if (!self.isEnabled) { _addListener(isViewport ? ownerDoc : target, "scroll", _onScroll); type.indexOf("scroll") >= 0 && _addListener(isViewport ? ownerDoc : target, "scroll", onScroll, preventDefault, capture); type.indexOf("wheel") >= 0 && _addListener(target, "wheel", _onWheel, preventDefault, capture); if (type.indexOf("touch") >= 0 && _isTouch || type.indexOf("pointer") >= 0) { _addListener(target, _eventTypes[0], _onPress, preventDefault, capture); _addListener(ownerDoc, _eventTypes[2], _onRelease); _addListener(ownerDoc, _eventTypes[3], _onRelease); allowClicks && _addListener(target, "click", clickCapture, false, true); onClick && _addListener(target, "click", _onClick); onGestureStart && _addListener(ownerDoc, "gesturestart", _onGestureStart); onGestureEnd && _addListener(ownerDoc, "gestureend", _onGestureEnd); onHover && _addListener(target, _pointerType + "enter", _onHover); onHoverEnd && _addListener(target, _pointerType + "leave", _onHoverEnd); onMove && _addListener(target, _pointerType + "move", _onMove); } self.isEnabled = true; e && e.type && _onPress(e); onEnable && onEnable(self); } return self; }; self.disable = function () { if (self.isEnabled) { // only remove the _onScroll listener if there aren't any others that rely on the functionality. _observers.filter(function (o) { return o !== self && _isViewport(o.target); }).length || _removeListener(isViewport ? ownerDoc : target, "scroll", _onScroll); if (self.isPressed) { self._vx.reset(); self._vy.reset(); _removeListener(isNormalizer ? target : ownerDoc, _eventTypes[1], _onDrag, true); } _removeListener(isViewport ? ownerDoc : target, "scroll", onScroll, capture); _removeListener(target, "wheel", _onWheel, capture); _removeListener(target, _eventTypes[0], _onPress, capture); _removeListener(ownerDoc, _eventTypes[2], _onRelease); _removeListener(ownerDoc, _eventTypes[3], _onRelease); _removeListener(target, "click", clickCapture, true); _removeListener(target, "click", _onClick); _removeListener(ownerDoc, "gesturestart", _onGestureStart); _removeListener(ownerDoc, "gestureend", _onGestureEnd); _removeListener(target, _pointerType + "enter", _onHover); _removeListener(target, _pointerType + "leave", _onHoverEnd); _removeListener(target, _pointerType + "move", _onMove); self.isEnabled = self.isPressed = self.isDragging = false; onDisable && onDisable(self); } }; self.kill = self.revert = function () { self.disable(); var i = _observers.indexOf(self); i >= 0 && _observers.splice(i, 1); _normalizer === self && (_normalizer = 0); }; _observers.push(self); isNormalizer && _isViewport(target) && (_normalizer = self); self.enable(event); }; _createClass(Observer, [{ key: "velocityX", get: function get() { return this._vx.getVelocity(); } }, { key: "velocityY", get: function get() { return this._vy.getVelocity(); } }]); return Observer; }(); Observer.version = "3.12.2"; Observer.create = function (vars) { return new Observer(vars); }; Observer.register = _initCore; Observer.getAll = function () { return _observers.slice(); }; Observer.getById = function (id) { return _observers.filter(function (o) { return o.vars.id === id; })[0]; }; _getGSAP() && gsap.registerPlugin(Observer); /***/ }), /***/ "../../node_modules/gsap/ScrollTrigger.js": /*!************************************************!*\ !*** ../../node_modules/gsap/ScrollTrigger.js ***! \************************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ ScrollTrigger: function() { return /* binding */ ScrollTrigger; }, /* harmony export */ "default": function() { return /* binding */ ScrollTrigger; } /* harmony export */ }); /* harmony import */ var _Observer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Observer.js */ "../../node_modules/gsap/Observer.js"); /*! * ScrollTrigger 3.12.2 * https://greensock.com * * @license Copyright 2008-2023, GreenSock. All rights reserved. * Subject to the terms at https://greensock.com/standard-license or for * Club GreenSock members, the agreement issued with that membership. * @author: Jack Doyle, jack@greensock.com */ /* eslint-disable */ var gsap, _coreInitted, _win, _doc, _docEl, _body, _root, _resizeDelay, _toArray, _clamp, _time2, _syncInterval, _refreshing, _pointerIsDown, _transformProp, _i, _prevWidth, _prevHeight, _autoRefresh, _sort, _suppressOverwrites, _ignoreResize, _normalizer, _ignoreMobileResize, _baseScreenHeight, _baseScreenWidth, _fixIOSBug, _context, _scrollRestoration, _div100vh, _100vh, _limitCallbacks, // if true, we'll only trigger callbacks if the active state toggles, so if you scroll immediately past both the start and end positions of a ScrollTrigger (thus inactive to inactive), neither its onEnter nor onLeave will be called. This is useful during startup. _startup = 1, _getTime = Date.now, _time1 = _getTime(), _lastScrollTime = 0, _enabled = 0, _parseClamp = function _parseClamp(value, type, self) { var clamp = _isString(value) && (value.substr(0, 6) === "clamp(" || value.indexOf("max") > -1); self["_" + type + "Clamp"] = clamp; return clamp ? value.substr(6, value.length - 7) : value; }, _keepClamp = function _keepClamp(value, clamp) { return clamp && (!_isString(value) || value.substr(0, 6) !== "clamp(") ? "clamp(" + value + ")" : value; }, _rafBugFix = function _rafBugFix() { return _enabled && requestAnimationFrame(_rafBugFix); }, // in some browsers (like Firefox), screen repaints weren't consistent unless we had SOMETHING queued up in requestAnimationFrame()! So this just creates a super simple loop to keep it alive and smooth out repaints. _pointerDownHandler = function _pointerDownHandler() { return _pointerIsDown = 1; }, _pointerUpHandler = function _pointerUpHandler() { return _pointerIsDown = 0; }, _passThrough = function _passThrough(v) { return v; }, _round = function _round(value) { return Math.round(value * 100000) / 100000 || 0; }, _windowExists = function _windowExists() { return typeof window !== "undefined"; }, _getGSAP = function _getGSAP() { return gsap || _windowExists() && (gsap = window.gsap) && gsap.registerPlugin && gsap; }, _isViewport = function _isViewport(e) { return !!~_root.indexOf(e); }, _getViewportDimension = function _getViewportDimension(dimensionProperty) { return (dimensionProperty === "Height" ? _100vh : _win["inner" + dimensionProperty]) || _docEl["client" + dimensionProperty] || _body["client" + dimensionProperty]; }, _getBoundsFunc = function _getBoundsFunc(element) { return (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getProxyProp)(element, "getBoundingClientRect") || (_isViewport(element) ? function () { _winOffsets.width = _win.innerWidth; _winOffsets.height = _100vh; return _winOffsets; } : function () { return _getBounds(element); }); }, _getSizeFunc = function _getSizeFunc(scroller, isViewport, _ref) { var d = _ref.d, d2 = _ref.d2, a = _ref.a; return (a = (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getProxyProp)(scroller, "getBoundingClientRect")) ? function () { return a()[d]; } : function () { return (isViewport ? _getViewportDimension(d2) : scroller["client" + d2]) || 0; }; }, _getOffsetsFunc = function _getOffsetsFunc(element, isViewport) { return !isViewport || ~_Observer_js__WEBPACK_IMPORTED_MODULE_0__._proxies.indexOf(element) ? _getBoundsFunc(element) : function () { return _winOffsets; }; }, _maxScroll = function _maxScroll(element, _ref2) { var s = _ref2.s, d2 = _ref2.d2, d = _ref2.d, a = _ref2.a; return Math.max(0, (s = "scroll" + d2) && (a = (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getProxyProp)(element, s)) ? a() - _getBoundsFunc(element)()[d] : _isViewport(element) ? (_docEl[s] || _body[s]) - _getViewportDimension(d2) : element[s] - element["offset" + d2]); }, _iterateAutoRefresh = function _iterateAutoRefresh(func, events) { for (var i = 0; i < _autoRefresh.length; i += 3) { (!events || ~events.indexOf(_autoRefresh[i + 1])) && func(_autoRefresh[i], _autoRefresh[i + 1], _autoRefresh[i + 2]); } }, _isString = function _isString(value) { return typeof value === "string"; }, _isFunction = function _isFunction(value) { return typeof value === "function"; }, _isNumber = function _isNumber(value) { return typeof value === "number"; }, _isObject = function _isObject(value) { return typeof value === "object"; }, _endAnimation = function _endAnimation(animation, reversed, pause) { return animation && animation.progress(reversed ? 0 : 1) && pause && animation.pause(); }, _callback = function _callback(self, func) { if (self.enabled) { var result = func(self); result && result.totalTime && (self.callbackAnimation = result); } }, _abs = Math.abs, _left = "left", _top = "top", _right = "right", _bottom = "bottom", _width = "width", _height = "height", _Right = "Right", _Left = "Left", _Top = "Top", _Bottom = "Bottom", _padding = "padding", _margin = "margin", _Width = "Width", _Height = "Height", _px = "px", _getComputedStyle = function _getComputedStyle(element) { return _win.getComputedStyle(element); }, _makePositionable = function _makePositionable(element) { // if the element already has position: absolute or fixed, leave that, otherwise make it position: relative var position = _getComputedStyle(element).position; element.style.position = position === "absolute" || position === "fixed" ? position : "relative"; }, _setDefaults = function _setDefaults(obj, defaults) { for (var p in defaults) { p in obj || (obj[p] = defaults[p]); } return obj; }, _getBounds = function _getBounds(element, withoutTransforms) { var tween = withoutTransforms && _getComputedStyle(element)[_transformProp] !== "matrix(1, 0, 0, 1, 0, 0)" && gsap.to(element, { x: 0, y: 0, xPercent: 0, yPercent: 0, rotation: 0, rotationX: 0, rotationY: 0, scale: 1, skewX: 0, skewY: 0 }).progress(1), bounds = element.getBoundingClientRect(); tween && tween.progress(0).kill(); return bounds; }, _getSize = function _getSize(element, _ref3) { var d2 = _ref3.d2; return element["offset" + d2] || element["client" + d2] || 0; }, _getLabelRatioArray = function _getLabelRatioArray(timeline) { var a = [], labels = timeline.labels, duration = timeline.duration(), p; for (p in labels) { a.push(labels[p] / duration); } return a; }, _getClosestLabel = function _getClosestLabel(animation) { return function (value) { return gsap.utils.snap(_getLabelRatioArray(animation), value); }; }, _snapDirectional = function _snapDirectional(snapIncrementOrArray) { var snap = gsap.utils.snap(snapIncrementOrArray), a = Array.isArray(snapIncrementOrArray) && snapIncrementOrArray.slice(0).sort(function (a, b) { return a - b; }); return a ? function (value, direction, threshold) { if (threshold === void 0) { threshold = 1e-3; } var i; if (!direction) { return snap(value); } if (direction > 0) { value -= threshold; // to avoid rounding errors. If we're too strict, it might snap forward, then immediately again, and again. for (i = 0; i < a.length; i++) { if (a[i] >= value) { return a[i]; } } return a[i - 1]; } else { i = a.length; value += threshold; while (i--) { if (a[i] <= value) { return a[i]; } } } return a[0]; } : function (value, direction, threshold) { if (threshold === void 0) { threshold = 1e-3; } var snapped = snap(value); return !direction || Math.abs(snapped - value) < threshold || snapped - value < 0 === direction < 0 ? snapped : snap(direction < 0 ? value - snapIncrementOrArray : value + snapIncrementOrArray); }; }, _getLabelAtDirection = function _getLabelAtDirection(timeline) { return function (value, st) { return _snapDirectional(_getLabelRatioArray(timeline))(value, st.direction); }; }, _multiListener = function _multiListener(func, element, types, callback) { return types.split(",").forEach(function (type) { return func(element, type, callback); }); }, _addListener = function _addListener(element, type, func, nonPassive, capture) { return element.addEventListener(type, func, { passive: !nonPassive, capture: !!capture }); }, _removeListener = function _removeListener(element, type, func, capture) { return element.removeEventListener(type, func, !!capture); }, _wheelListener = function _wheelListener(func, el, scrollFunc) { scrollFunc = scrollFunc && scrollFunc.wheelHandler; if (scrollFunc) { func(el, "wheel", scrollFunc); func(el, "touchmove", scrollFunc); } }, _markerDefaults = { startColor: "green", endColor: "red", indent: 0, fontSize: "16px", fontWeight: "normal" }, _defaults = { toggleActions: "play", anticipatePin: 0 }, _keywords = { top: 0, left: 0, center: 0.5, bottom: 1, right: 1 }, _offsetToPx = function _offsetToPx(value, size) { if (_isString(value)) { var eqIndex = value.indexOf("="), relative = ~eqIndex ? +(value.charAt(eqIndex - 1) + 1) * parseFloat(value.substr(eqIndex + 1)) : 0; if (~eqIndex) { value.indexOf("%") > eqIndex && (relative *= size / 100); value = value.substr(0, eqIndex - 1); } value = relative + (value in _keywords ? _keywords[value] * size : ~value.indexOf("%") ? parseFloat(value) * size / 100 : parseFloat(value) || 0); } return value; }, _createMarker = function _createMarker(type, name, container, direction, _ref4, offset, matchWidthEl, containerAnimation) { var startColor = _ref4.startColor, endColor = _ref4.endColor, fontSize = _ref4.fontSize, indent = _ref4.indent, fontWeight = _ref4.fontWeight; var e = _doc.createElement("div"), useFixedPosition = _isViewport(container) || (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getProxyProp)(container, "pinType") === "fixed", isScroller = type.indexOf("scroller") !== -1, parent = useFixedPosition ? _body : container, isStart = type.indexOf("start") !== -1, color = isStart ? startColor : endColor, 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;"; css += "position:" + ((isScroller || containerAnimation) && useFixedPosition ? "fixed;" : "absolute;"); (isScroller || containerAnimation || !useFixedPosition) && (css += (direction === _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical ? _right : _bottom) + ":" + (offset + parseFloat(indent)) + "px;"); matchWidthEl && (css += "box-sizing:border-box;text-align:left;width:" + matchWidthEl.offsetWidth + "px;"); e._isStart = isStart; e.setAttribute("class", "gsap-marker-" + type + (name ? " marker-" + name : "")); e.style.cssText = css; e.innerText = name || name === 0 ? type + "-" + name : type; parent.children[0] ? parent.insertBefore(e, parent.children[0]) : parent.appendChild(e); e._offset = e["offset" + direction.op.d2]; _positionMarker(e, 0, direction, isStart); return e; }, _positionMarker = function _positionMarker(marker, start, direction, flipped) { var vars = { display: "block" }, side = direction[flipped ? "os2" : "p2"], oppositeSide = direction[flipped ? "p2" : "os2"]; marker._isFlipped = flipped; vars[direction.a + "Percent"] = flipped ? -100 : 0; vars[direction.a] = flipped ? "1px" : 0; vars["border" + side + _Width] = 1; vars["border" + oppositeSide + _Width] = 0; vars[direction.p] = start + "px"; gsap.set(marker, vars); }, _triggers = [], _ids = {}, _rafID, _sync = function _sync() { return _getTime() - _lastScrollTime > 34 && (_rafID || (_rafID = requestAnimationFrame(_updateAll))); }, _onScroll = function _onScroll() { // previously, we tried to optimize performance by batching/deferring to the next requestAnimationFrame(), but discovered that Safari has a few bugs that make this unworkable (especially on iOS). See https://codepen.io/GreenSock/pen/16c435b12ef09c38125204818e7b45fc?editors=0010 and https://codepen.io/GreenSock/pen/JjOxYpQ/3dd65ccec5a60f1d862c355d84d14562?editors=0010 and https://codepen.io/GreenSock/pen/ExbrPNa/087cef197dc35445a0951e8935c41503?editors=0010 if (!_normalizer || !_normalizer.isPressed || _normalizer.startX > _body.clientWidth) { // if the user is dragging the scrollbar, allow it. _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.cache++; if (_normalizer) { _rafID || (_rafID = requestAnimationFrame(_updateAll)); } else { _updateAll(); // Safari in particular (on desktop) NEEDS the immediate update rather than waiting for a requestAnimationFrame() whereas iOS seems to benefit from waiting for the requestAnimationFrame() tick, at least when normalizing. See https://codepen.io/GreenSock/pen/qBYozqO?editors=0110 } _lastScrollTime || _dispatch("scrollStart"); _lastScrollTime = _getTime(); } }, _setBaseDimensions = function _setBaseDimensions() { _baseScreenWidth = _win.innerWidth; _baseScreenHeight = _win.innerHeight; }, _onResize = function _onResize() { _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.cache++; !_refreshing && !_ignoreResize && !_doc.fullscreenElement && !_doc.webkitFullscreenElement && (!_ignoreMobileResize || _baseScreenWidth !== _win.innerWidth || Math.abs(_win.innerHeight - _baseScreenHeight) > _win.innerHeight * 0.25) && _resizeDelay.restart(true); }, // ignore resizes triggered by refresh() _listeners = {}, _emptyArray = [], _softRefresh = function _softRefresh() { return _removeListener(ScrollTrigger, "scrollEnd", _softRefresh) || _refreshAll(true); }, _dispatch = function _dispatch(type) { return _listeners[type] && _listeners[type].map(function (f) { return f(); }) || _emptyArray; }, _savedStyles = [], // when ScrollTrigger.saveStyles() is called, the inline styles are recorded in this Array in a sequential format like [element, cssText, gsCache, media]. This keeps it very memory-efficient and fast to iterate through. _revertRecorded = function _revertRecorded(media) { for (var i = 0; i < _savedStyles.length; i += 5) { if (!media || _savedStyles[i + 4] && _savedStyles[i + 4].query === media) { _savedStyles[i].style.cssText = _savedStyles[i + 1]; _savedStyles[i].getBBox && _savedStyles[i].setAttribute("transform", _savedStyles[i + 2] || ""); _savedStyles[i + 3].uncache = 1; } } }, _revertAll = function _revertAll(kill, media) { var trigger; for (_i = 0; _i < _triggers.length; _i++) { trigger = _triggers[_i]; if (trigger && (!media || trigger._ctx === media)) { if (kill) { trigger.kill(1); } else { trigger.revert(true, true); } } } media && _revertRecorded(media); media || _dispatch("revert"); }, _clearScrollMemory = function _clearScrollMemory(scrollRestoration, force) { // zero-out all the recorded scroll positions. Don't use _triggers because if, for example, .matchMedia() is used to create some ScrollTriggers and then the user resizes and it removes ALL ScrollTriggers, and then go back to a size where there are ScrollTriggers, it would have kept the position(s) saved from the initial state. _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.cache++; (force || !_refreshingAll) && _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.forEach(function (obj) { return _isFunction(obj) && obj.cacheID++ && (obj.rec = 0); }); _isString(scrollRestoration) && (_win.history.scrollRestoration = _scrollRestoration = scrollRestoration); }, _refreshingAll, _refreshID = 0, _queueRefreshID, _queueRefreshAll = function _queueRefreshAll() { // we don't want to call _refreshAll() every time we create a new ScrollTrigger (for performance reasons) - it's better to batch them. Some frameworks dynamically load content and we can't rely on the window's "load" or "DOMContentLoaded" events to trigger it. if (_queueRefreshID !== _refreshID) { var id = _queueRefreshID = _refreshID; requestAnimationFrame(function () { return id === _refreshID && _refreshAll(true); }); } }, _refresh100vh = function _refresh100vh() { _body.appendChild(_div100vh); _100vh = _div100vh.offsetHeight || _win.innerHeight; _body.removeChild(_div100vh); }, _refreshAll = function _refreshAll(force, skipRevert) { if (_lastScrollTime && !force) { _addListener(ScrollTrigger, "scrollEnd", _softRefresh); return; } _refresh100vh(); _refreshingAll = ScrollTrigger.isRefreshing = true; _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.forEach(function (obj) { return _isFunction(obj) && ++obj.cacheID && (obj.rec = obj()); }); // force the clearing of the cache because some browsers take a little while to dispatch the "scroll" event and the user may have changed the scroll position and then called ScrollTrigger.refresh() right away var refreshInits = _dispatch("refreshInit"); _sort && ScrollTrigger.sort(); skipRevert || _revertAll(); _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.forEach(function (obj) { if (_isFunction(obj)) { obj.smooth && (obj.target.style.scrollBehavior = "auto"); // smooth scrolling interferes obj(0); } }); _triggers.slice(0).forEach(function (t) { return t.refresh(); }); // don't loop with _i because during a refresh() someone could call ScrollTrigger.update() which would iterate through _i resulting in a skip. _triggers.forEach(function (t, i) { // nested pins (pinnedContainer) with pinSpacing may expand the container, so we must accommodate that here. if (t._subPinOffset && t.pin) { var prop = t.vars.horizontal ? "offsetWidth" : "offsetHeight", original = t.pin[prop]; t.revert(true, 1); t.adjustPinSpacing(t.pin[prop] - original); t.refresh(); } }); _triggers.forEach(function (t) { // the scroller's max scroll position may change after all the ScrollTriggers refreshed (like pinning could push it down), so we need to loop back and correct any with end: "max". Same for anything with a clamped end var max = _maxScroll(t.scroller, t._dir); (t.vars.end === "max" || t._endClamp && t.end > max) && t.setPositions(t.start, Math.max(t.start + 1, max), true); }); refreshInits.forEach(function (result) { return result && result.render && result.render(-1); }); // if the onRefreshInit() returns an animation (typically a gsap.set()), revert it. This makes it easy to put things in a certain spot before refreshing for measurement purposes, and then put things back. _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.forEach(function (obj) { if (_isFunction(obj)) { obj.smooth && requestAnimationFrame(function () { return obj.target.style.scrollBehavior = "smooth"; }); obj.rec && obj(obj.rec); } }); _clearScrollMemory(_scrollRestoration, 1); _resizeDelay.pause(); _refreshID++; _refreshingAll = 2; _updateAll(2); _triggers.forEach(function (t) { return _isFunction(t.vars.onRefresh) && t.vars.onRefresh(t); }); _refreshingAll = ScrollTrigger.isRefreshing = false; _dispatch("refresh"); }, _lastScroll = 0, _direction = 1, _primary, _updateAll = function _updateAll(force) { if (!_refreshingAll || force === 2) { ScrollTrigger.isUpdating = true; _primary && _primary.update(0); // ScrollSmoother uses refreshPriority -9999 to become the primary that gets updated before all others because it affects the scroll position. var l = _triggers.length, time = _getTime(), recordVelocity = time - _time1 >= 50, scroll = l && _triggers[0].scroll(); _direction = _lastScroll > scroll ? -1 : 1; _refreshingAll || (_lastScroll = scroll); if (recordVelocity) { if (_lastScrollTime && !_pointerIsDown && time - _lastScrollTime > 200) { _lastScrollTime = 0; _dispatch("scrollEnd"); } _time2 = _time1; _time1 = time; } if (_direction < 0) { _i = l; while (_i-- > 0) { _triggers[_i] && _triggers[_i].update(0, recordVelocity); } _direction = 1; } else { for (_i = 0; _i < l; _i++) { _triggers[_i] && _triggers[_i].update(0, recordVelocity); } } ScrollTrigger.isUpdating = false; } _rafID = 0; }, _propNamesToCopy = [_left, _top, _bottom, _right, _margin + _Bottom, _margin + _Right, _margin + _Top, _margin + _Left, "display", "flexShrink", "float", "zIndex", "gridColumnStart", "gridColumnEnd", "gridRowStart", "gridRowEnd", "gridArea", "justifySelf", "alignSelf", "placeSelf", "order"], _stateProps = _propNamesToCopy.concat([_width, _height, "boxSizing", "max" + _Width, "max" + _Height, "position", _margin, _padding, _padding + _Top, _padding + _Right, _padding + _Bottom, _padding + _Left]), _swapPinOut = function _swapPinOut(pin, spacer, state) { _setState(state); var cache = pin._gsap; if (cache.spacerIsNative) { _setState(cache.spacerState); } else if (pin._gsap.swappedIn) { var parent = spacer.parentNode; if (parent) { parent.insertBefore(pin, spacer); parent.removeChild(spacer); } } pin._gsap.swappedIn = false; }, _swapPinIn = function _swapPinIn(pin, spacer, cs, spacerState) { if (!pin._gsap.swappedIn) { var i = _propNamesToCopy.length, spacerStyle = spacer.style, pinStyle = pin.style, p; while (i--) { p = _propNamesToCopy[i]; spacerStyle[p] = cs[p]; } spacerStyle.position = cs.position === "absolute" ? "absolute" : "relative"; cs.display === "inline" && (spacerStyle.display = "inline-block"); pinStyle[_bottom] = pinStyle[_right] = "auto"; spacerStyle.flexBasis = cs.flexBasis || "auto"; spacerStyle.overflow = "visible"; spacerStyle.boxSizing = "border-box"; spacerStyle[_width] = _getSize(pin, _Observer_js__WEBPACK_IMPORTED_MODULE_0__._horizontal) + _px; spacerStyle[_height] = _getSize(pin, _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical) + _px; spacerStyle[_padding] = pinStyle[_margin] = pinStyle[_top] = pinStyle[_left] = "0"; _setState(spacerState); pinStyle[_width] = pinStyle["max" + _Width] = cs[_width]; pinStyle[_height] = pinStyle["max" + _Height] = cs[_height]; pinStyle[_padding] = cs[_padding]; if (pin.parentNode !== spacer) { pin.parentNode.insertBefore(spacer, pin); spacer.appendChild(pin); } pin._gsap.swappedIn = true; } }, _capsExp = /([A-Z])/g, _setState = function _setState(state) { if (state) { var style = state.t.style, l = state.length, i = 0, p, value; (state.t._gsap || gsap.core.getCache(state.t)).uncache = 1; // otherwise transforms may be off for (; i < l; i += 2) { value = state[i + 1]; p = state[i]; if (value) { style[p] = value; } else if (style[p]) { style.removeProperty(p.replace(_capsExp, "-$1").toLowerCase()); } } } }, _getState = function _getState(element) { // returns an Array with alternating values like [property, value, property, value] and a "t" property pointing to the target (element). Makes it fast and cheap. var l = _stateProps.length, style = element.style, state = [], i = 0; for (; i < l; i++) { state.push(_stateProps[i], style[_stateProps[i]]); } state.t = element; return state; }, _copyState = function _copyState(state, override, omitOffsets) { var result = [], l = state.length, i = omitOffsets ? 8 : 0, // skip top, left, right, bottom if omitOffsets is true p; for (; i < l; i += 2) { p = state[i]; result.push(p, p in override ? override[p] : state[i + 1]); } result.t = state.t; return result; }, _winOffsets = { left: 0, top: 0 }, // // potential future feature (?) Allow users to calculate where a trigger hits (scroll position) like getScrollPosition("#id", "top bottom") // _getScrollPosition = (trigger, position, {scroller, containerAnimation, horizontal}) => { // scroller = _getTarget(scroller || _win); // let direction = horizontal ? _horizontal : _vertical, // isViewport = _isViewport(scroller); // _getSizeFunc(scroller, isViewport, direction); // return _parsePosition(position, _getTarget(trigger), _getSizeFunc(scroller, isViewport, direction)(), direction, _getScrollFunc(scroller, direction)(), 0, 0, 0, _getOffsetsFunc(scroller, isViewport)(), isViewport ? 0 : parseFloat(_getComputedStyle(scroller)["border" + direction.p2 + _Width]) || 0, 0, containerAnimation ? containerAnimation.duration() : _maxScroll(scroller), containerAnimation); // }, _parsePosition = function _parsePosition(value, trigger, scrollerSize, direction, scroll, marker, markerScroller, self, scrollerBounds, borderWidth, useFixedPosition, scrollerMax, containerAnimation, clampZeroProp) { _isFunction(value) && (value = value(self)); if (_isString(value) && value.substr(0, 3) === "max") { value = scrollerMax + (value.charAt(4) === "=" ? _offsetToPx("0" + value.substr(3), scrollerSize) : 0); } var time = containerAnimation ? containerAnimation.time() : 0, p1, p2, element; containerAnimation && containerAnimation.seek(0); isNaN(value) || (value = +value); // convert a string number like "45" to an actual number if (!_isNumber(value)) { _isFunction(trigger) && (trigger = trigger(self)); var offsets = (value || "0").split(" "), bounds, localOffset, globalOffset, display; element = (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getTarget)(trigger, self) || _body; bounds = _getBounds(element) || {}; if ((!bounds || !bounds.left && !bounds.top) && _getComputedStyle(element).display === "none") { // if display is "none", it won't report getBoundingClientRect() properly display = element.style.display; element.style.display = "block"; bounds = _getBounds(element); display ? element.style.display = display : element.style.removeProperty("display"); } localOffset = _offsetToPx(offsets[0], bounds[direction.d]); globalOffset = _offsetToPx(offsets[1] || "0", scrollerSize); value = bounds[direction.p] - scrollerBounds[direction.p] - borderWidth + localOffset + scroll - globalOffset; markerScroller && _positionMarker(markerScroller, globalOffset, direction, scrollerSize - globalOffset < 20 || markerScroller._isStart && globalOffset > 20); scrollerSize -= scrollerSize - globalOffset; // adjust for the marker } else { containerAnimation && (value = gsap.utils.mapRange(containerAnimation.scrollTrigger.start, containerAnimation.scrollTrigger.end, 0, scrollerMax, value)); markerScroller && _positionMarker(markerScroller, scrollerSize, direction, true); } if (clampZeroProp) { self[clampZeroProp] = value || -0.001; value < 0 && (value = 0); } if (marker) { var position = value + scrollerSize, isStart = marker._isStart; p1 = "scroll" + direction.d2; _positionMarker(marker, position, direction, isStart && position > 20 || !isStart && (useFixedPosition ? Math.max(_body[p1], _docEl[p1]) : marker.parentNode[p1]) <= position + 1); if (useFixedPosition) { scrollerBounds = _getBounds(markerScroller); useFixedPosition && (marker.style[direction.op.p] = scrollerBounds[direction.op.p] - direction.op.m - marker._offset + _px); } } if (containerAnimation && element) { p1 = _getBounds(element); containerAnimation.seek(scrollerMax); p2 = _getBounds(element); containerAnimation._caScrollDist = p1[direction.p] - p2[direction.p]; value = value / containerAnimation._caScrollDist * scrollerMax; } containerAnimation && containerAnimation.seek(time); return containerAnimation ? value : Math.round(value); }, _prefixExp = /(webkit|moz|length|cssText|inset)/i, _reparent = function _reparent(element, parent, top, left) { if (element.parentNode !== parent) { var style = element.style, p, cs; if (parent === _body) { element._stOrig = style.cssText; // record original inline styles so we can revert them later cs = _getComputedStyle(element); for (p in cs) { // must copy all relevant styles to ensure that nothing changes visually when we reparent to the . Skip the vendor prefixed ones. if (!+p && !_prefixExp.test(p) && cs[p] && typeof style[p] === "string" && p !== "0") { style[p] = cs[p]; } } style.top = top; style.left = left; } else { style.cssText = element._stOrig; } gsap.core.getCache(element).uncache = 1; parent.appendChild(element); } }, _interruptionTracker = function _interruptionTracker(getValueFunc, initialValue, onInterrupt) { var last1 = initialValue, last2 = last1; return function (value) { var current = Math.round(getValueFunc()); // round because in some [very uncommon] Windows environments, scroll can get reported with decimals even though it was set without. if (current !== last1 && current !== last2 && Math.abs(current - last1) > 3 && Math.abs(current - last2) > 3) { // if the user scrolls, kill the tween. iOS Safari intermittently misreports the scroll position, it may be the most recently-set one or the one before that! When Safari is zoomed (CMD-+), it often misreports as 1 pixel off too! So if we set the scroll position to 125, for example, it'll actually report it as 124. value = current; onInterrupt && onInterrupt(); } last2 = last1; last1 = value; return value; }; }, _shiftMarker = function _shiftMarker(marker, direction, value) { var vars = {}; vars[direction.p] = "+=" + value; gsap.set(marker, vars); }, // _mergeAnimations = animations => { // let tl = gsap.timeline({smoothChildTiming: true}).startTime(Math.min(...animations.map(a => a.globalTime(0)))); // animations.forEach(a => {let time = a.totalTime(); tl.add(a); a.totalTime(time); }); // tl.smoothChildTiming = false; // return tl; // }, // returns a function that can be used to tween the scroll position in the direction provided, and when doing so it'll add a .tween property to the FUNCTION itself, and remove it when the tween completes or gets killed. This gives us a way to have multiple ScrollTriggers use a central function for any given scroller and see if there's a scroll tween running (which would affect if/how things get updated) _getTweenCreator = function _getTweenCreator(scroller, direction) { var getScroll = (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getScrollFunc)(scroller, direction), prop = "_scroll" + direction.p2, // add a tweenable property to the scroller that's a getter/setter function, like _scrollTop or _scrollLeft. This way, if someone does gsap.killTweensOf(scroller) it'll kill the scroll tween. getTween = function getTween(scrollTo, vars, initialValue, change1, change2) { var tween = getTween.tween, onComplete = vars.onComplete, modifiers = {}; initialValue = initialValue || getScroll(); var checkForInterruption = _interruptionTracker(getScroll, initialValue, function () { tween.kill(); getTween.tween = 0; }); change2 = change1 && change2 || 0; // if change1 is 0, we set that to the difference and ignore change2. Otherwise, there would be a compound effect. change1 = change1 || scrollTo - initialValue; tween && tween.kill(); vars[prop] = scrollTo; vars.modifiers = modifiers; modifiers[prop] = function () { return checkForInterruption(initialValue + change1 * tween.ratio + change2 * tween.ratio * tween.ratio); }; vars.onUpdate = function () { _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.cache++; _updateAll(); }; vars.onComplete = function () { getTween.tween = 0; onComplete && onComplete.call(tween); }; tween = getTween.tween = gsap.to(scroller, vars); return tween; }; scroller[prop] = getScroll; getScroll.wheelHandler = function () { return getTween.tween && getTween.tween.kill() && (getTween.tween = 0); }; _addListener(scroller, "wheel", getScroll.wheelHandler); // Windows machines handle mousewheel scrolling in chunks (like "3 lines per scroll") meaning the typical strategy for cancelling the scroll isn't as sensitive. It's much more likely to match one of the previous 2 scroll event positions. So we kill any snapping as soon as there's a wheel event. ScrollTrigger.isTouch && _addListener(scroller, "touchmove", getScroll.wheelHandler); return getTween; }; var ScrollTrigger = /*#__PURE__*/function () { function ScrollTrigger(vars, animation) { _coreInitted || ScrollTrigger.register(gsap) || console.warn("Please gsap.registerPlugin(ScrollTrigger)"); _context(this); this.init(vars, animation); } var _proto = ScrollTrigger.prototype; _proto.init = function init(vars, animation) { this.progress = this.start = 0; this.vars && this.kill(true, true); // in case it's being initted again if (!_enabled) { this.update = this.refresh = this.kill = _passThrough; return; } vars = _setDefaults(_isString(vars) || _isNumber(vars) || vars.nodeType ? { trigger: vars } : vars, _defaults); var _vars = vars, onUpdate = _vars.onUpdate, toggleClass = _vars.toggleClass, id = _vars.id, onToggle = _vars.onToggle, onRefresh = _vars.onRefresh, scrub = _vars.scrub, trigger = _vars.trigger, pin = _vars.pin, pinSpacing = _vars.pinSpacing, invalidateOnRefresh = _vars.invalidateOnRefresh, anticipatePin = _vars.anticipatePin, onScrubComplete = _vars.onScrubComplete, onSnapComplete = _vars.onSnapComplete, once = _vars.once, snap = _vars.snap, pinReparent = _vars.pinReparent, pinSpacer = _vars.pinSpacer, containerAnimation = _vars.containerAnimation, fastScrollEnd = _vars.fastScrollEnd, preventOverlaps = _vars.preventOverlaps, direction = vars.horizontal || vars.containerAnimation && vars.horizontal !== false ? _Observer_js__WEBPACK_IMPORTED_MODULE_0__._horizontal : _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical, isToggle = !scrub && scrub !== 0, scroller = (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getTarget)(vars.scroller || _win), scrollerCache = gsap.core.getCache(scroller), isViewport = _isViewport(scroller), useFixedPosition = ("pinType" in vars ? vars.pinType : (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getProxyProp)(scroller, "pinType") || isViewport && "fixed") === "fixed", callbacks = [vars.onEnter, vars.onLeave, vars.onEnterBack, vars.onLeaveBack], toggleActions = isToggle && vars.toggleActions.split(" "), markers = "markers" in vars ? vars.markers : _defaults.markers, borderWidth = isViewport ? 0 : parseFloat(_getComputedStyle(scroller)["border" + direction.p2 + _Width]) || 0, self = this, onRefreshInit = vars.onRefreshInit && function () { return vars.onRefreshInit(self); }, getScrollerSize = _getSizeFunc(scroller, isViewport, direction), getScrollerOffsets = _getOffsetsFunc(scroller, isViewport), lastSnap = 0, lastRefresh = 0, prevProgress = 0, scrollFunc = (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getScrollFunc)(scroller, direction), tweenTo, pinCache, snapFunc, scroll1, scroll2, start, end, markerStart, markerEnd, markerStartTrigger, markerEndTrigger, markerVars, executingOnRefresh, change, pinOriginalState, pinActiveState, pinState, spacer, offset, pinGetter, pinSetter, pinStart, pinChange, spacingStart, spacerState, markerStartSetter, pinMoves, markerEndSetter, cs, snap1, snap2, scrubTween, scrubSmooth, snapDurClamp, snapDelayedCall, prevScroll, prevAnimProgress, caMarkerSetter, customRevertReturn; // for the sake of efficiency, _startClamp/_endClamp serve like a truthy value indicating that clamping was enabled on the start/end, and ALSO store the actual pre-clamped numeric value. We tap into that in ScrollSmoother for speed effects. So for example, if start="clamp(top bottom)" results in a start of -100 naturally, it would get clamped to 0 but -100 would be stored in _startClamp. self._startClamp = self._endClamp = false; self._dir = direction; anticipatePin *= 45; self.scroller = scroller; self.scroll = containerAnimation ? containerAnimation.time.bind(containerAnimation) : scrollFunc; scroll1 = scrollFunc(); self.vars = vars; animation = animation || vars.animation; if ("refreshPriority" in vars) { _sort = 1; vars.refreshPriority === -9999 && (_primary = self); // used by ScrollSmoother } scrollerCache.tweenScroll = scrollerCache.tweenScroll || { top: _getTweenCreator(scroller, _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical), left: _getTweenCreator(scroller, _Observer_js__WEBPACK_IMPORTED_MODULE_0__._horizontal) }; self.tweenTo = tweenTo = scrollerCache.tweenScroll[direction.p]; self.scrubDuration = function (value) { scrubSmooth = _isNumber(value) && value; if (!scrubSmooth) { scrubTween && scrubTween.progress(1).kill(); scrubTween = 0; } else { scrubTween ? scrubTween.duration(value) : scrubTween = gsap.to(animation, { ease: "expo", totalProgress: "+=0", duration: scrubSmooth, paused: true, onComplete: function onComplete() { return onScrubComplete && onScrubComplete(self); } }); } }; if (animation) { animation.vars.lazy = false; animation._initted && !self.isReverted || animation.vars.immediateRender !== false && vars.immediateRender !== false && animation.duration() && animation.render(0, true, true); // special case: if this ScrollTrigger gets re-initted, a from() tween with a stagger could get initted initially and then reverted on the re-init which means it'll need to get rendered again here to properly display things. Otherwise, See https://greensock.com/forums/topic/36777-scrollsmoother-splittext-nextjs/ and https://codepen.io/GreenSock/pen/eYPyPpd?editors=0010 self.animation = animation.pause(); animation.scrollTrigger = self; self.scrubDuration(scrub); snap1 = 0; id || (id = animation.vars.id); } if (snap) { // TODO: potential idea: use legitimate CSS scroll snapping by pushing invisible elements into the DOM that serve as snap positions, and toggle the document.scrollingElement.style.scrollSnapType onToggle. See https://codepen.io/GreenSock/pen/JjLrgWM for a quick proof of concept. if (!_isObject(snap) || snap.push) { snap = { snapTo: snap }; } "scrollBehavior" in _body.style && gsap.set(isViewport ? [_body, _docEl] : scroller, { scrollBehavior: "auto" }); // smooth scrolling doesn't work with snap. _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.forEach(function (o) { return _isFunction(o) && o.target === (isViewport ? _doc.scrollingElement || _docEl : scroller) && (o.smooth = false); }); // note: set smooth to false on both the vertical and horizontal scroll getters/setters snapFunc = _isFunction(snap.snapTo) ? snap.snapTo : snap.snapTo === "labels" ? _getClosestLabel(animation) : snap.snapTo === "labelsDirectional" ? _getLabelAtDirection(animation) : snap.directional !== false ? function (value, st) { return _snapDirectional(snap.snapTo)(value, _getTime() - lastRefresh < 500 ? 0 : st.direction); } : gsap.utils.snap(snap.snapTo); snapDurClamp = snap.duration || { min: 0.1, max: 2 }; snapDurClamp = _isObject(snapDurClamp) ? _clamp(snapDurClamp.min, snapDurClamp.max) : _clamp(snapDurClamp, snapDurClamp); snapDelayedCall = gsap.delayedCall(snap.delay || scrubSmooth / 2 || 0.1, function () { var scroll = scrollFunc(), refreshedRecently = _getTime() - lastRefresh < 500, tween = tweenTo.tween; if ((refreshedRecently || Math.abs(self.getVelocity()) < 10) && !tween && !_pointerIsDown && lastSnap !== scroll) { var progress = (scroll - start) / change, totalProgress = animation && !isToggle ? animation.totalProgress() : progress, velocity = refreshedRecently ? 0 : (totalProgress - snap2) / (_getTime() - _time2) * 1000 || 0, change1 = gsap.utils.clamp(-progress, 1 - progress, _abs(velocity / 2) * velocity / 0.185), naturalEnd = progress + (snap.inertia === false ? 0 : change1), endValue = _clamp(0, 1, snapFunc(naturalEnd, self)), endScroll = Math.round(start + endValue * change), _snap = snap, onStart = _snap.onStart, _onInterrupt = _snap.onInterrupt, _onComplete = _snap.onComplete; if (scroll <= end && scroll >= start && endScroll !== scroll) { if (tween && !tween._initted && tween.data <= _abs(endScroll - scroll)) { // there's an overlapping snap! So we must figure out which one is closer and let that tween live. return; } if (snap.inertia === false) { change1 = endValue - progress; } tweenTo(endScroll, { duration: snapDurClamp(_abs(Math.max(_abs(naturalEnd - totalProgress), _abs(endValue - totalProgress)) * 0.185 / velocity / 0.05 || 0)), ease: snap.ease || "power3", data: _abs(endScroll - scroll), // record the distance so that if another snap tween occurs (conflict) we can prioritize the closest snap. onInterrupt: function onInterrupt() { return snapDelayedCall.restart(true) && _onInterrupt && _onInterrupt(self); }, onComplete: function onComplete() { self.update(); lastSnap = scrollFunc(); snap1 = snap2 = animation && !isToggle ? animation.totalProgress() : self.progress; onSnapComplete && onSnapComplete(self); _onComplete && _onComplete(self); } }, scroll, change1 * change, endScroll - scroll - change1 * change); onStart && onStart(self, tweenTo.tween); } } else if (self.isActive && lastSnap !== scroll) { snapDelayedCall.restart(true); } }).pause(); } id && (_ids[id] = self); trigger = self.trigger = (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getTarget)(trigger || pin !== true && pin); // if a trigger has some kind of scroll-related effect applied that could contaminate the "y" or "x" position (like a ScrollSmoother effect), we needed a way to temporarily revert it, so we use the stRevert property of the gsCache. It can return another function that we'll call at the end so it can return to its normal state. customRevertReturn = trigger && trigger._gsap && trigger._gsap.stRevert; customRevertReturn && (customRevertReturn = customRevertReturn(self)); pin = pin === true ? trigger : (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getTarget)(pin); _isString(toggleClass) && (toggleClass = { targets: trigger, className: toggleClass }); if (pin) { pinSpacing === false || pinSpacing === _margin || (pinSpacing = !pinSpacing && pin.parentNode && pin.parentNode.style && _getComputedStyle(pin.parentNode).display === "flex" ? false : _padding); // if the parent is display: flex, don't apply pinSpacing by default. We should check that pin.parentNode is an element (not shadow dom window) self.pin = pin; pinCache = gsap.core.getCache(pin); if (!pinCache.spacer) { // record the spacer and pinOriginalState on the cache in case someone tries pinning the same element with MULTIPLE ScrollTriggers - we don't want to have multiple spacers or record the "original" pin state after it has already been affected by another ScrollTrigger. if (pinSpacer) { pinSpacer = (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getTarget)(pinSpacer); pinSpacer && !pinSpacer.nodeType && (pinSpacer = pinSpacer.current || pinSpacer.nativeElement); // for React & Angular pinCache.spacerIsNative = !!pinSpacer; pinSpacer && (pinCache.spacerState = _getState(pinSpacer)); } pinCache.spacer = spacer = pinSpacer || _doc.createElement("div"); spacer.classList.add("pin-spacer"); id && spacer.classList.add("pin-spacer-" + id); pinCache.pinState = pinOriginalState = _getState(pin); } else { pinOriginalState = pinCache.pinState; } vars.force3D !== false && gsap.set(pin, { force3D: true }); self.spacer = spacer = pinCache.spacer; cs = _getComputedStyle(pin); spacingStart = cs[pinSpacing + direction.os2]; pinGetter = gsap.getProperty(pin); pinSetter = gsap.quickSetter(pin, direction.a, _px); // pin.firstChild && !_maxScroll(pin, direction) && (pin.style.overflow = "hidden"); // protects from collapsing margins, but can have unintended consequences as demonstrated here: https://codepen.io/GreenSock/pen/1e42c7a73bfa409d2cf1e184e7a4248d so it was removed in favor of just telling people to set up their CSS to avoid the collapsing margins (overflow: hidden | auto is just one option. Another is border-top: 1px solid transparent). _swapPinIn(pin, spacer, cs); pinState = _getState(pin); } if (markers) { markerVars = _isObject(markers) ? _setDefaults(markers, _markerDefaults) : _markerDefaults; markerStartTrigger = _createMarker("scroller-start", id, scroller, direction, markerVars, 0); markerEndTrigger = _createMarker("scroller-end", id, scroller, direction, markerVars, 0, markerStartTrigger); offset = markerStartTrigger["offset" + direction.op.d2]; var content = (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getTarget)((0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getProxyProp)(scroller, "content") || scroller); markerStart = this.markerStart = _createMarker("start", id, content, direction, markerVars, offset, 0, containerAnimation); markerEnd = this.markerEnd = _createMarker("end", id, content, direction, markerVars, offset, 0, containerAnimation); containerAnimation && (caMarkerSetter = gsap.quickSetter([markerStart, markerEnd], direction.a, _px)); if (!useFixedPosition && !(_Observer_js__WEBPACK_IMPORTED_MODULE_0__._proxies.length && (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getProxyProp)(scroller, "fixedMarkers") === true)) { _makePositionable(isViewport ? _body : scroller); gsap.set([markerStartTrigger, markerEndTrigger], { force3D: true }); markerStartSetter = gsap.quickSetter(markerStartTrigger, direction.a, _px); markerEndSetter = gsap.quickSetter(markerEndTrigger, direction.a, _px); } } if (containerAnimation) { var oldOnUpdate = containerAnimation.vars.onUpdate, oldParams = containerAnimation.vars.onUpdateParams; containerAnimation.eventCallback("onUpdate", function () { self.update(0, 0, 1); oldOnUpdate && oldOnUpdate.apply(containerAnimation, oldParams || []); }); } self.previous = function () { return _triggers[_triggers.indexOf(self) - 1]; }; self.next = function () { return _triggers[_triggers.indexOf(self) + 1]; }; self.revert = function (revert, temp) { if (!temp) { return self.kill(true); } // for compatibility with gsap.context() and gsap.matchMedia() which call revert() var r = revert !== false || !self.enabled, prevRefreshing = _refreshing; if (r !== self.isReverted) { if (r) { prevScroll = Math.max(scrollFunc(), self.scroll.rec || 0); // record the scroll so we can revert later (repositioning/pinning things can affect scroll position). In the static refresh() method, we first record all the scroll positions as a reference. prevProgress = self.progress; prevAnimProgress = animation && animation.progress(); } markerStart && [markerStart, markerEnd, markerStartTrigger, markerEndTrigger].forEach(function (m) { return m.style.display = r ? "none" : "block"; }); if (r) { _refreshing = self; self.update(r); // make sure the pin is back in its original position so that all the measurements are correct. do this BEFORE swapping the pin out } if (pin && (!pinReparent || !self.isActive)) { if (r) { _swapPinOut(pin, spacer, pinOriginalState); } else { _swapPinIn(pin, spacer, _getComputedStyle(pin), spacerState); } } r || self.update(r); // when we're restoring, the update should run AFTER swapping the pin into its pin-spacer. _refreshing = prevRefreshing; // restore. We set it to true during the update() so that things fire properly in there. self.isReverted = r; } }; self.refresh = function (soft, force, position, pinOffset) { // position is typically only defined if it's coming from setPositions() - it's a way to skip the normal parsing. pinOffset is also only from setPositions() and is mostly related to fancy stuff we need to do in ScrollSmoother with effects if ((_refreshing || !self.enabled) && !force) { return; } if (pin && soft && _lastScrollTime) { _addListener(ScrollTrigger, "scrollEnd", _softRefresh); return; } !_refreshingAll && onRefreshInit && onRefreshInit(self); _refreshing = self; if (tweenTo.tween && !position) { // we skip this if a position is passed in because typically that's from .setPositions() and it's best to allow in-progress snapping to continue. tweenTo.tween.kill(); tweenTo.tween = 0; } scrubTween && scrubTween.pause(); invalidateOnRefresh && animation && animation.revert({ kill: false }).invalidate(); self.isReverted || self.revert(true, true); self._subPinOffset = false; // we'll set this to true in the sub-pins if we find any var size = getScrollerSize(), scrollerBounds = getScrollerOffsets(), max = containerAnimation ? containerAnimation.duration() : _maxScroll(scroller, direction), isFirstRefresh = change <= 0.01, offset = 0, otherPinOffset = pinOffset || 0, parsedEnd = _isObject(position) ? position.end : vars.end, parsedEndTrigger = vars.endTrigger || trigger, parsedStart = _isObject(position) ? position.start : vars.start || (vars.start === 0 || !trigger ? 0 : pin ? "0 0" : "0 100%"), pinnedContainer = self.pinnedContainer = vars.pinnedContainer && (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getTarget)(vars.pinnedContainer, self), triggerIndex = trigger && Math.max(0, _triggers.indexOf(self)) || 0, i = triggerIndex, cs, bounds, scroll, isVertical, override, curTrigger, curPin, oppositeScroll, initted, revertedPins, forcedOverflow, markerStartOffset, markerEndOffset; if (markers && _isObject(position)) { // if we alter the start/end positions with .setPositions(), it generally feeds in absolute NUMBERS which don't convey information about where to line up the markers, so to keep it intuitive, we record how far the trigger positions shift after applying the new numbers and then offset by that much in the opposite direction. We do the same to the associated trigger markers too of course. markerStartOffset = gsap.getProperty(markerStartTrigger, direction.p); markerEndOffset = gsap.getProperty(markerEndTrigger, direction.p); } while (i--) { // user might try to pin the same element more than once, so we must find any prior triggers with the same pin, revert them, and determine how long they're pinning so that we can offset things appropriately. Make sure we revert from last to first so that things "rewind" properly. curTrigger = _triggers[i]; curTrigger.end || curTrigger.refresh(0, 1) || (_refreshing = self); // if it's a timeline-based trigger that hasn't been fully initialized yet because it's waiting for 1 tick, just force the refresh() here, otherwise if it contains a pin that's supposed to affect other ScrollTriggers further down the page, they won't be adjusted properly. curPin = curTrigger.pin; if (curPin && (curPin === trigger || curPin === pin || curPin === pinnedContainer) && !curTrigger.isReverted) { revertedPins || (revertedPins = []); revertedPins.unshift(curTrigger); // we'll revert from first to last to make sure things reach their end state properly curTrigger.revert(true, true); } if (curTrigger !== _triggers[i]) { // in case it got removed. triggerIndex--; i--; } } _isFunction(parsedStart) && (parsedStart = parsedStart(self)); parsedStart = _parseClamp(parsedStart, "start", self); start = _parsePosition(parsedStart, trigger, size, direction, scrollFunc(), markerStart, markerStartTrigger, self, scrollerBounds, borderWidth, useFixedPosition, max, containerAnimation, self._startClamp && "_startClamp") || (pin ? -0.001 : 0); _isFunction(parsedEnd) && (parsedEnd = parsedEnd(self)); if (_isString(parsedEnd) && !parsedEnd.indexOf("+=")) { if (~parsedEnd.indexOf(" ")) { parsedEnd = (_isString(parsedStart) ? parsedStart.split(" ")[0] : "") + parsedEnd; } else { offset = _offsetToPx(parsedEnd.substr(2), size); parsedEnd = _isString(parsedStart) ? parsedStart : (containerAnimation ? gsap.utils.mapRange(0, containerAnimation.duration(), containerAnimation.scrollTrigger.start, containerAnimation.scrollTrigger.end, start) : start) + offset; // _parsePosition won't factor in the offset if the start is a number, so do it here. parsedEndTrigger = trigger; } } parsedEnd = _parseClamp(parsedEnd, "end", self); end = Math.max(start, _parsePosition(parsedEnd || (parsedEndTrigger ? "100% 0" : max), parsedEndTrigger, size, direction, scrollFunc() + offset, markerEnd, markerEndTrigger, self, scrollerBounds, borderWidth, useFixedPosition, max, containerAnimation, self._endClamp && "_endClamp")) || -0.001; offset = 0; i = triggerIndex; while (i--) { curTrigger = _triggers[i]; curPin = curTrigger.pin; if (curPin && curTrigger.start - curTrigger._pinPush <= start && !containerAnimation && curTrigger.end > 0) { cs = curTrigger.end - (self._startClamp ? Math.max(0, curTrigger.start) : curTrigger.start); if ((curPin === trigger && curTrigger.start - curTrigger._pinPush < start || curPin === pinnedContainer) && isNaN(parsedStart)) { // numeric start values shouldn't be offset at all - treat them as absolute offset += cs * (1 - curTrigger.progress); } curPin === pin && (otherPinOffset += cs); } } start += offset; end += offset; self._startClamp && (self._startClamp += offset); if (self._endClamp && !_refreshingAll) { self._endClamp = end || -0.001; end = Math.min(end, _maxScroll(scroller, direction)); } change = end - start || (start -= 0.01) && 0.001; if (isFirstRefresh) { // on the very first refresh(), the prevProgress couldn't have been accurate yet because the start/end were never calculated, so we set it here. Before 3.11.5, it could lead to an inaccurate scroll position restoration with snapping. prevProgress = gsap.utils.clamp(0, 1, gsap.utils.normalize(start, end, prevScroll)); } self._pinPush = otherPinOffset; if (markerStart && offset) { // offset the markers if necessary cs = {}; cs[direction.a] = "+=" + offset; pinnedContainer && (cs[direction.p] = "-=" + scrollFunc()); gsap.set([markerStart, markerEnd], cs); } if (pin) { cs = _getComputedStyle(pin); isVertical = direction === _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical; scroll = scrollFunc(); // recalculate because the triggers can affect the scroll pinStart = parseFloat(pinGetter(direction.a)) + otherPinOffset; if (!max && end > 1) { // makes sure the scroller has a scrollbar, otherwise if something has width: 100%, for example, it would be too big (exclude the scrollbar). See https://greensock.com/forums/topic/25182-scrolltrigger-width-of-page-increase-where-markers-are-set-to-false/ forcedOverflow = (isViewport ? _doc.scrollingElement || _docEl : scroller).style; forcedOverflow = { style: forcedOverflow, value: forcedOverflow["overflow" + direction.a.toUpperCase()] }; if (isViewport && _getComputedStyle(_body)["overflow" + direction.a.toUpperCase()] !== "scroll") { // avoid an extra scrollbar if BOTH and have overflow set to "scroll" forcedOverflow.style["overflow" + direction.a.toUpperCase()] = "scroll"; } } _swapPinIn(pin, spacer, cs); pinState = _getState(pin); // transforms will interfere with the top/left/right/bottom placement, so remove them temporarily. getBoundingClientRect() factors in transforms. bounds = _getBounds(pin, true); oppositeScroll = useFixedPosition && (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getScrollFunc)(scroller, isVertical ? _Observer_js__WEBPACK_IMPORTED_MODULE_0__._horizontal : _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical)(); if (pinSpacing) { spacerState = [pinSpacing + direction.os2, change + otherPinOffset + _px]; spacerState.t = spacer; i = pinSpacing === _padding ? _getSize(pin, direction) + change + otherPinOffset : 0; i && spacerState.push(direction.d, i + _px); // for box-sizing: border-box (must include padding). _setState(spacerState); if (pinnedContainer) { // in ScrollTrigger.refresh(), we need to re-evaluate the pinContainer's size because this pinSpacing may stretch it out, but we can't just add the exact distance because depending on layout, it may not push things down or it may only do so partially. _triggers.forEach(function (t) { if (t.pin === pinnedContainer && t.vars.pinSpacing !== false) { t._subPinOffset = true; } }); } useFixedPosition && scrollFunc(prevScroll); } if (useFixedPosition) { override = { top: bounds.top + (isVertical ? scroll - start : oppositeScroll) + _px, left: bounds.left + (isVertical ? oppositeScroll : scroll - start) + _px, boxSizing: "border-box", position: "fixed" }; override[_width] = override["max" + _Width] = Math.ceil(bounds.width) + _px; override[_height] = override["max" + _Height] = Math.ceil(bounds.height) + _px; override[_margin] = override[_margin + _Top] = override[_margin + _Right] = override[_margin + _Bottom] = override[_margin + _Left] = "0"; override[_padding] = cs[_padding]; override[_padding + _Top] = cs[_padding + _Top]; override[_padding + _Right] = cs[_padding + _Right]; override[_padding + _Bottom] = cs[_padding + _Bottom]; override[_padding + _Left] = cs[_padding + _Left]; pinActiveState = _copyState(pinOriginalState, override, pinReparent); _refreshingAll && scrollFunc(0); } if (animation) { // the animation might be affecting the transform, so we must jump to the end, check the value, and compensate accordingly. Otherwise, when it becomes unpinned, the pinSetter() will get set to a value that doesn't include whatever the animation did. initted = animation._initted; // if not, we must invalidate() after this step, otherwise it could lock in starting values prematurely. _suppressOverwrites(1); animation.render(animation.duration(), true, true); pinChange = pinGetter(direction.a) - pinStart + change + otherPinOffset; pinMoves = Math.abs(change - pinChange) > 1; useFixedPosition && pinMoves && pinActiveState.splice(pinActiveState.length - 2, 2); // transform is the last property/value set in the state Array. Since the animation is controlling that, we should omit it. animation.render(0, true, true); initted || animation.invalidate(true); animation.parent || animation.totalTime(animation.totalTime()); // if, for example, a toggleAction called play() and then refresh() happens and when we render(1) above, it would cause the animation to complete and get removed from its parent, so this makes sure it gets put back in. _suppressOverwrites(0); } else { pinChange = change; } forcedOverflow && (forcedOverflow.value ? forcedOverflow.style["overflow" + direction.a.toUpperCase()] = forcedOverflow.value : forcedOverflow.style.removeProperty("overflow-" + direction.a)); } else if (trigger && scrollFunc() && !containerAnimation) { // it may be INSIDE a pinned element, so walk up the tree and look for any elements with _pinOffset to compensate because anything with pinSpacing that's already scrolled would throw off the measurements in getBoundingClientRect() bounds = trigger.parentNode; while (bounds && bounds !== _body) { if (bounds._pinOffset) { start -= bounds._pinOffset; end -= bounds._pinOffset; } bounds = bounds.parentNode; } } revertedPins && revertedPins.forEach(function (t) { return t.revert(false, true); }); self.start = start; self.end = end; scroll1 = scroll2 = _refreshingAll ? prevScroll : scrollFunc(); // reset velocity if (!containerAnimation && !_refreshingAll) { scroll1 < prevScroll && scrollFunc(prevScroll); self.scroll.rec = 0; } self.revert(false, true); lastRefresh = _getTime(); if (snapDelayedCall) { lastSnap = -1; // just so snapping gets re-enabled, clear out any recorded last value // self.isActive && scrollFunc(start + change * prevProgress); // previously this line was here to ensure that when snapping kicks in, it's from the previous progress but in some cases that's not desirable, like an all-page ScrollTrigger when new content gets added to the page, that'd totally change the progress. snapDelayedCall.restart(true); } _refreshing = 0; animation && isToggle && (animation._initted || prevAnimProgress) && animation.progress() !== prevAnimProgress && animation.progress(prevAnimProgress || 0, true).render(animation.time(), true, true); // must force a re-render because if saveStyles() was used on the target(s), the styles could have been wiped out during the refresh(). if (isFirstRefresh || prevProgress !== self.progress || containerAnimation) { // ensures that the direction is set properly (when refreshing, progress is set back to 0 initially, then back again to wherever it needs to be) and that callbacks are triggered. animation && !isToggle && animation.totalProgress(containerAnimation && start < -0.001 && !prevProgress ? gsap.utils.normalize(start, end, 0) : prevProgress, true); // to avoid issues where animation callbacks like onStart aren't triggered. self.progress = isFirstRefresh || (scroll1 - start) / change === prevProgress ? 0 : prevProgress; } pin && pinSpacing && (spacer._pinOffset = Math.round(self.progress * pinChange)); scrubTween && scrubTween.invalidate(); if (!isNaN(markerStartOffset)) { // numbers were passed in for the position which are absolute, so instead of just putting the markers at the very bottom of the viewport, we figure out how far they shifted down (it's safe to assume they were originally positioned in closer relation to the trigger element with values like "top", "center", a percentage or whatever, so we offset that much in the opposite direction to basically revert them to the relative position thy were at previously. markerStartOffset -= gsap.getProperty(markerStartTrigger, direction.p); markerEndOffset -= gsap.getProperty(markerEndTrigger, direction.p); _shiftMarker(markerStartTrigger, direction, markerStartOffset); _shiftMarker(markerStart, direction, markerStartOffset - (pinOffset || 0)); _shiftMarker(markerEndTrigger, direction, markerEndOffset); _shiftMarker(markerEnd, direction, markerEndOffset - (pinOffset || 0)); } isFirstRefresh && !_refreshingAll && self.update(); // edge case - when you reload a page when it's already scrolled down, some browsers fire a "scroll" event before DOMContentLoaded, triggering an updateAll(). If we don't update the self.progress as part of refresh(), then when it happens next, it may record prevProgress as 0 when it really shouldn't, potentially causing a callback in an animation to fire again. if (onRefresh && !_refreshingAll && !executingOnRefresh) { // when refreshing all, we do extra work to correct pinnedContainer sizes and ensure things don't exceed the maxScroll, so we should do all the refreshes at the end after all that work so that the start/end values are corrected. executingOnRefresh = true; onRefresh(self); executingOnRefresh = false; } }; self.getVelocity = function () { return (scrollFunc() - scroll2) / (_getTime() - _time2) * 1000 || 0; }; self.endAnimation = function () { _endAnimation(self.callbackAnimation); if (animation) { scrubTween ? scrubTween.progress(1) : !animation.paused() ? _endAnimation(animation, animation.reversed()) : isToggle || _endAnimation(animation, self.direction < 0, 1); } }; self.labelToScroll = function (label) { return animation && animation.labels && (start || self.refresh() || start) + animation.labels[label] / animation.duration() * change || 0; }; self.getTrailing = function (name) { var i = _triggers.indexOf(self), a = self.direction > 0 ? _triggers.slice(0, i).reverse() : _triggers.slice(i + 1); return (_isString(name) ? a.filter(function (t) { return t.vars.preventOverlaps === name; }) : a).filter(function (t) { return self.direction > 0 ? t.end <= start : t.start >= end; }); }; self.update = function (reset, recordVelocity, forceFake) { if (containerAnimation && !forceFake && !reset) { return; } var scroll = _refreshingAll === true ? prevScroll : self.scroll(), p = reset ? 0 : (scroll - start) / change, clipped = p < 0 ? 0 : p > 1 ? 1 : p || 0, prevProgress = self.progress, isActive, wasActive, toggleState, action, stateChanged, toggled, isAtMax, isTakingAction; if (recordVelocity) { scroll2 = scroll1; scroll1 = containerAnimation ? scrollFunc() : scroll; if (snap) { snap2 = snap1; snap1 = animation && !isToggle ? animation.totalProgress() : clipped; } } // anticipate the pinning a few ticks ahead of time based on velocity to avoid a visual glitch due to the fact that most browsers do scrolling on a separate thread (not synced with requestAnimationFrame). anticipatePin && !clipped && pin && !_refreshing && !_startup && _lastScrollTime && start < scroll + (scroll - scroll2) / (_getTime() - _time2) * anticipatePin && (clipped = 0.0001); if (clipped !== prevProgress && self.enabled) { isActive = self.isActive = !!clipped && clipped < 1; wasActive = !!prevProgress && prevProgress < 1; toggled = isActive !== wasActive; stateChanged = toggled || !!clipped !== !!prevProgress; // could go from start all the way to end, thus it didn't toggle but it did change state in a sense (may need to fire a callback) self.direction = clipped > prevProgress ? 1 : -1; self.progress = clipped; if (stateChanged && !_refreshing) { toggleState = clipped && !prevProgress ? 0 : clipped === 1 ? 1 : prevProgress === 1 ? 2 : 3; // 0 = enter, 1 = leave, 2 = enterBack, 3 = leaveBack (we prioritize the FIRST encounter, thus if you scroll really fast past the onEnter and onLeave in one tick, it'd prioritize onEnter. if (isToggle) { action = !toggled && toggleActions[toggleState + 1] !== "none" && toggleActions[toggleState + 1] || toggleActions[toggleState]; // if it didn't toggle, that means it shot right past and since we prioritize the "enter" action, we should switch to the "leave" in this case (but only if one is defined) isTakingAction = animation && (action === "complete" || action === "reset" || action in animation); } } preventOverlaps && (toggled || isTakingAction) && (isTakingAction || scrub || !animation) && (_isFunction(preventOverlaps) ? preventOverlaps(self) : self.getTrailing(preventOverlaps).forEach(function (t) { return t.endAnimation(); })); if (!isToggle) { if (scrubTween && !_refreshing && !_startup) { scrubTween._dp._time - scrubTween._start !== scrubTween._time && scrubTween.render(scrubTween._dp._time - scrubTween._start); // if there's a scrub on both the container animation and this one (or a ScrollSmoother), the update order would cause this one not to have rendered yet, so it wouldn't make any progress before we .restart() it heading toward the new progress so it'd appear stuck thus we force a render here. if (scrubTween.resetTo) { scrubTween.resetTo("totalProgress", clipped, animation._tTime / animation._tDur); } else { // legacy support (courtesy), before 3.10.0 scrubTween.vars.totalProgress = clipped; scrubTween.invalidate().restart(); } } else if (animation) { animation.totalProgress(clipped, !!(_refreshing && (lastRefresh || reset))); } } if (pin) { reset && pinSpacing && (spacer.style[pinSpacing + direction.os2] = spacingStart); if (!useFixedPosition) { pinSetter(_round(pinStart + pinChange * clipped)); } else if (stateChanged) { isAtMax = !reset && clipped > prevProgress && end + 1 > scroll && scroll + 1 >= _maxScroll(scroller, direction); // if it's at the VERY end of the page, don't switch away from position: fixed because it's pointless and it could cause a brief flash when the user scrolls back up (when it gets pinned again) if (pinReparent) { if (!reset && (isActive || isAtMax)) { var bounds = _getBounds(pin, true), _offset = scroll - start; _reparent(pin, _body, bounds.top + (direction === _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical ? _offset : 0) + _px, bounds.left + (direction === _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical ? 0 : _offset) + _px); } else { _reparent(pin, spacer); } } _setState(isActive || isAtMax ? pinActiveState : pinState); pinMoves && clipped < 1 && isActive || pinSetter(pinStart + (clipped === 1 && !isAtMax ? pinChange : 0)); } } snap && !tweenTo.tween && !_refreshing && !_startup && snapDelayedCall.restart(true); toggleClass && (toggled || once && clipped && (clipped < 1 || !_limitCallbacks)) && _toArray(toggleClass.targets).forEach(function (el) { return el.classList[isActive || once ? "add" : "remove"](toggleClass.className); }); // classes could affect positioning, so do it even if reset or refreshing is true. onUpdate && !isToggle && !reset && onUpdate(self); if (stateChanged && !_refreshing) { if (isToggle) { if (isTakingAction) { if (action === "complete") { animation.pause().totalProgress(1); } else if (action === "reset") { animation.restart(true).pause(); } else if (action === "restart") { animation.restart(true); } else { animation[action](); } } onUpdate && onUpdate(self); } if (toggled || !_limitCallbacks) { // on startup, the page could be scrolled and we don't want to fire callbacks that didn't toggle. For example onEnter shouldn't fire if the ScrollTrigger isn't actually entered. onToggle && toggled && _callback(self, onToggle); callbacks[toggleState] && _callback(self, callbacks[toggleState]); once && (clipped === 1 ? self.kill(false, 1) : callbacks[toggleState] = 0); // a callback shouldn't be called again if once is true. if (!toggled) { // it's possible to go completely past, like from before the start to after the end (or vice-versa) in which case BOTH callbacks should be fired in that order toggleState = clipped === 1 ? 1 : 3; callbacks[toggleState] && _callback(self, callbacks[toggleState]); } } if (fastScrollEnd && !isActive && Math.abs(self.getVelocity()) > (_isNumber(fastScrollEnd) ? fastScrollEnd : 2500)) { _endAnimation(self.callbackAnimation); scrubTween ? scrubTween.progress(1) : _endAnimation(animation, action === "reverse" ? 1 : !clipped, 1); } } else if (isToggle && onUpdate && !_refreshing) { onUpdate(self); } } // update absolutely-positioned markers (only if the scroller isn't the viewport) if (markerEndSetter) { var n = containerAnimation ? scroll / containerAnimation.duration() * (containerAnimation._caScrollDist || 0) : scroll; markerStartSetter(n + (markerStartTrigger._isFlipped ? 1 : 0)); markerEndSetter(n); } caMarkerSetter && caMarkerSetter(-scroll / containerAnimation.duration() * (containerAnimation._caScrollDist || 0)); }; self.enable = function (reset, refresh) { if (!self.enabled) { self.enabled = true; _addListener(scroller, "resize", _onResize); isViewport || _addListener(scroller, "scroll", _onScroll); onRefreshInit && _addListener(ScrollTrigger, "refreshInit", onRefreshInit); if (reset !== false) { self.progress = prevProgress = 0; scroll1 = scroll2 = lastSnap = scrollFunc(); } refresh !== false && self.refresh(); } }; self.getTween = function (snap) { return snap && tweenTo ? tweenTo.tween : scrubTween; }; self.setPositions = function (newStart, newEnd, keepClamp, pinOffset) { // doesn't persist after refresh()! Intended to be a way to override values that were set during refresh(), like you could set it in onRefresh() if (containerAnimation) { // convert ratios into scroll positions. Remember, start/end values on ScrollTriggers that have a containerAnimation refer to the time (in seconds), NOT scroll positions. var st = containerAnimation.scrollTrigger, duration = containerAnimation.duration(), _change = st.end - st.start; newStart = st.start + _change * newStart / duration; newEnd = st.start + _change * newEnd / duration; } self.refresh(false, false, { start: _keepClamp(newStart, keepClamp && !!self._startClamp), end: _keepClamp(newEnd, keepClamp && !!self._endClamp) }, pinOffset); self.update(); }; self.adjustPinSpacing = function (amount) { if (spacerState && amount) { var i = spacerState.indexOf(direction.d) + 1; spacerState[i] = parseFloat(spacerState[i]) + amount + _px; spacerState[1] = parseFloat(spacerState[1]) + amount + _px; _setState(spacerState); } }; self.disable = function (reset, allowAnimation) { if (self.enabled) { reset !== false && self.revert(true, true); self.enabled = self.isActive = false; allowAnimation || scrubTween && scrubTween.pause(); prevScroll = 0; pinCache && (pinCache.uncache = 1); onRefreshInit && _removeListener(ScrollTrigger, "refreshInit", onRefreshInit); if (snapDelayedCall) { snapDelayedCall.pause(); tweenTo.tween && tweenTo.tween.kill() && (tweenTo.tween = 0); } if (!isViewport) { var i = _triggers.length; while (i--) { if (_triggers[i].scroller === scroller && _triggers[i] !== self) { return; //don't remove the listeners if there are still other triggers referencing it. } } _removeListener(scroller, "resize", _onResize); isViewport || _removeListener(scroller, "scroll", _onScroll); } } }; self.kill = function (revert, allowAnimation) { self.disable(revert, allowAnimation); scrubTween && !allowAnimation && scrubTween.kill(); id && delete _ids[id]; var i = _triggers.indexOf(self); i >= 0 && _triggers.splice(i, 1); i === _i && _direction > 0 && _i--; // if we're in the middle of a refresh() or update(), splicing would cause skips in the index, so adjust... // if no other ScrollTrigger instances of the same scroller are found, wipe out any recorded scroll position. Otherwise, in a single page application, for example, it could maintain scroll position when it really shouldn't. i = 0; _triggers.forEach(function (t) { return t.scroller === self.scroller && (i = 1); }); i || _refreshingAll || (self.scroll.rec = 0); if (animation) { animation.scrollTrigger = null; revert && animation.revert({ kill: false }); allowAnimation || animation.kill(); } markerStart && [markerStart, markerEnd, markerStartTrigger, markerEndTrigger].forEach(function (m) { return m.parentNode && m.parentNode.removeChild(m); }); _primary === self && (_primary = 0); if (pin) { pinCache && (pinCache.uncache = 1); i = 0; _triggers.forEach(function (t) { return t.pin === pin && i++; }); i || (pinCache.spacer = 0); // if there aren't any more ScrollTriggers with the same pin, remove the spacer, otherwise it could be contaminated with old/stale values if the user re-creates a ScrollTrigger for the same element. } vars.onKill && vars.onKill(self); }; _triggers.push(self); self.enable(false, false); customRevertReturn && customRevertReturn(self); if (animation && animation.add && !change) { // if the animation is a timeline, it may not have been populated yet, so it wouldn't render at the proper place on the first refresh(), thus we should schedule one for the next tick. If "change" is defined, we know it must be re-enabling, thus we can refresh() right away. var updateFunc = self.update; // some browsers may fire a scroll event BEFORE a tick elapses and/or the DOMContentLoaded fires. So there's a chance update() will be called BEFORE a refresh() has happened on a Timeline-attached ScrollTrigger which means the start/end won't be calculated yet. We don't want to add conditional logic inside the update() method (like check to see if end is defined and if not, force a refresh()) because that's a function that gets hit a LOT (performance). So we swap out the real update() method for this one that'll re-attach it the first time it gets called and of course forces a refresh(). self.update = function () { self.update = updateFunc; start || end || self.refresh(); }; gsap.delayedCall(0.01, self.update); change = 0.01; start = end = 0; } else { self.refresh(); } pin && _queueRefreshAll(); // pinning could affect the positions of other things, so make sure we queue a full refresh() }; ScrollTrigger.register = function register(core) { if (!_coreInitted) { gsap = core || _getGSAP(); _windowExists() && window.document && ScrollTrigger.enable(); _coreInitted = _enabled; } return _coreInitted; }; ScrollTrigger.defaults = function defaults(config) { if (config) { for (var p in config) { _defaults[p] = config[p]; } } return _defaults; }; ScrollTrigger.disable = function disable(reset, kill) { _enabled = 0; _triggers.forEach(function (trigger) { return trigger[kill ? "kill" : "disable"](reset); }); _removeListener(_win, "wheel", _onScroll); _removeListener(_doc, "scroll", _onScroll); clearInterval(_syncInterval); _removeListener(_doc, "touchcancel", _passThrough); _removeListener(_body, "touchstart", _passThrough); _multiListener(_removeListener, _doc, "pointerdown,touchstart,mousedown", _pointerDownHandler); _multiListener(_removeListener, _doc, "pointerup,touchend,mouseup", _pointerUpHandler); _resizeDelay.kill(); _iterateAutoRefresh(_removeListener); for (var i = 0; i < _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.length; i += 3) { _wheelListener(_removeListener, _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers[i], _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers[i + 1]); _wheelListener(_removeListener, _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers[i], _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers[i + 2]); } }; ScrollTrigger.enable = function enable() { _win = window; _doc = document; _docEl = _doc.documentElement; _body = _doc.body; if (gsap) { _toArray = gsap.utils.toArray; _clamp = gsap.utils.clamp; _context = gsap.core.context || _passThrough; _suppressOverwrites = gsap.core.suppressOverwrites || _passThrough; _scrollRestoration = _win.history.scrollRestoration || "auto"; _lastScroll = _win.pageYOffset; gsap.core.globals("ScrollTrigger", ScrollTrigger); // must register the global manually because in Internet Explorer, functions (classes) don't have a "name" property. if (_body) { _enabled = 1; _div100vh = document.createElement("div"); // to solve mobile browser address bar show/hide resizing, we shouldn't rely on window.innerHeight. Instead, use a
with its height set to 100vh and measure that since that's what the scrolling is based on anyway and it's not affected by address bar showing/hiding. _div100vh.style.height = "100vh"; _div100vh.style.position = "absolute"; _refresh100vh(); _rafBugFix(); _Observer_js__WEBPACK_IMPORTED_MODULE_0__.Observer.register(gsap); // isTouch is 0 if no touch, 1 if ONLY touch, and 2 if it can accommodate touch but also other types like mouse/pointer. ScrollTrigger.isTouch = _Observer_js__WEBPACK_IMPORTED_MODULE_0__.Observer.isTouch; _fixIOSBug = _Observer_js__WEBPACK_IMPORTED_MODULE_0__.Observer.isTouch && /(iPad|iPhone|iPod|Mac)/g.test(navigator.userAgent); // since 2017, iOS has had a bug that causes event.clientX/Y to be inaccurate when a scroll occurs, thus we must alternate ignoring every other touchmove event to work around it. See https://bugs.webkit.org/show_bug.cgi?id=181954 and https://codepen.io/GreenSock/pen/ExbrPNa/087cef197dc35445a0951e8935c41503 _addListener(_win, "wheel", _onScroll); // mostly for 3rd party smooth scrolling libraries. _root = [_win, _doc, _docEl, _body]; if (gsap.matchMedia) { ScrollTrigger.matchMedia = function (vars) { var mm = gsap.matchMedia(), p; for (p in vars) { mm.add(p, vars[p]); } return mm; }; gsap.addEventListener("matchMediaInit", function () { return _revertAll(); }); gsap.addEventListener("matchMediaRevert", function () { return _revertRecorded(); }); gsap.addEventListener("matchMedia", function () { _refreshAll(0, 1); _dispatch("matchMedia"); }); gsap.matchMedia("(orientation: portrait)", function () { // when orientation changes, we should take new base measurements for the ignoreMobileResize feature. _setBaseDimensions(); return _setBaseDimensions; }); } else { console.warn("Requires GSAP 3.11.0 or later"); } _setBaseDimensions(); _addListener(_doc, "scroll", _onScroll); // some browsers (like Chrome), the window stops dispatching scroll events on the window if you scroll really fast, but it's consistent on the document! var bodyStyle = _body.style, border = bodyStyle.borderTopStyle, AnimationProto = gsap.core.Animation.prototype, bounds, i; AnimationProto.revert || Object.defineProperty(AnimationProto, "revert", { value: function value() { return this.time(-0.01, true); } }); // only for backwards compatibility (Animation.revert() was added after 3.10.4) bodyStyle.borderTopStyle = "solid"; // works around an issue where a margin of a child element could throw off the bounds of the _body, making it seem like there's a margin when there actually isn't. The border ensures that the bounds are accurate. bounds = _getBounds(_body); _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical.m = Math.round(bounds.top + _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical.sc()) || 0; // accommodate the offset of the caused by margins and/or padding _Observer_js__WEBPACK_IMPORTED_MODULE_0__._horizontal.m = Math.round(bounds.left + _Observer_js__WEBPACK_IMPORTED_MODULE_0__._horizontal.sc()) || 0; border ? bodyStyle.borderTopStyle = border : bodyStyle.removeProperty("border-top-style"); // TODO: (?) maybe move to leveraging the velocity mechanism in Observer and skip intervals. _syncInterval = setInterval(_sync, 250); gsap.delayedCall(0.5, function () { return _startup = 0; }); _addListener(_doc, "touchcancel", _passThrough); // some older Android devices intermittently stop dispatching "touchmove" events if we don't listen for "touchcancel" on the document. _addListener(_body, "touchstart", _passThrough); //works around Safari bug: https://greensock.com/forums/topic/21450-draggable-in-iframe-on-mobile-is-buggy/ _multiListener(_addListener, _doc, "pointerdown,touchstart,mousedown", _pointerDownHandler); _multiListener(_addListener, _doc, "pointerup,touchend,mouseup", _pointerUpHandler); _transformProp = gsap.utils.checkPrefix("transform"); _stateProps.push(_transformProp); _coreInitted = _getTime(); _resizeDelay = gsap.delayedCall(0.2, _refreshAll).pause(); _autoRefresh = [_doc, "visibilitychange", function () { var w = _win.innerWidth, h = _win.innerHeight; if (_doc.hidden) { _prevWidth = w; _prevHeight = h; } else if (_prevWidth !== w || _prevHeight !== h) { _onResize(); } }, _doc, "DOMContentLoaded", _refreshAll, _win, "load", _refreshAll, _win, "resize", _onResize]; _iterateAutoRefresh(_addListener); _triggers.forEach(function (trigger) { return trigger.enable(0, 1); }); for (i = 0; i < _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.length; i += 3) { _wheelListener(_removeListener, _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers[i], _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers[i + 1]); _wheelListener(_removeListener, _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers[i], _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers[i + 2]); } } } }; ScrollTrigger.config = function config(vars) { "limitCallbacks" in vars && (_limitCallbacks = !!vars.limitCallbacks); var ms = vars.syncInterval; ms && clearInterval(_syncInterval) || (_syncInterval = ms) && setInterval(_sync, ms); "ignoreMobileResize" in vars && (_ignoreMobileResize = ScrollTrigger.isTouch === 1 && vars.ignoreMobileResize); if ("autoRefreshEvents" in vars) { _iterateAutoRefresh(_removeListener) || _iterateAutoRefresh(_addListener, vars.autoRefreshEvents || "none"); _ignoreResize = (vars.autoRefreshEvents + "").indexOf("resize") === -1; } }; ScrollTrigger.scrollerProxy = function scrollerProxy(target, vars) { var t = (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getTarget)(target), i = _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.indexOf(t), isViewport = _isViewport(t); if (~i) { _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.splice(i, isViewport ? 6 : 2); } if (vars) { isViewport ? _Observer_js__WEBPACK_IMPORTED_MODULE_0__._proxies.unshift(_win, vars, _body, vars, _docEl, vars) : _Observer_js__WEBPACK_IMPORTED_MODULE_0__._proxies.unshift(t, vars); } }; ScrollTrigger.clearMatchMedia = function clearMatchMedia(query) { _triggers.forEach(function (t) { return t._ctx && t._ctx.query === query && t._ctx.kill(true, true); }); }; ScrollTrigger.isInViewport = function isInViewport(element, ratio, horizontal) { var bounds = (_isString(element) ? (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getTarget)(element) : element).getBoundingClientRect(), offset = bounds[horizontal ? _width : _height] * ratio || 0; return horizontal ? bounds.right - offset > 0 && bounds.left + offset < _win.innerWidth : bounds.bottom - offset > 0 && bounds.top + offset < _win.innerHeight; }; ScrollTrigger.positionInViewport = function positionInViewport(element, referencePoint, horizontal) { _isString(element) && (element = (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getTarget)(element)); var bounds = element.getBoundingClientRect(), size = bounds[horizontal ? _width : _height], offset = referencePoint == null ? size / 2 : referencePoint in _keywords ? _keywords[referencePoint] * size : ~referencePoint.indexOf("%") ? parseFloat(referencePoint) * size / 100 : parseFloat(referencePoint) || 0; return horizontal ? (bounds.left + offset) / _win.innerWidth : (bounds.top + offset) / _win.innerHeight; }; ScrollTrigger.killAll = function killAll(allowListeners) { _triggers.slice(0).forEach(function (t) { return t.vars.id !== "ScrollSmoother" && t.kill(); }); if (allowListeners !== true) { var listeners = _listeners.killAll || []; _listeners = {}; listeners.forEach(function (f) { return f(); }); } }; return ScrollTrigger; }(); ScrollTrigger.version = "3.12.2"; ScrollTrigger.saveStyles = function (targets) { return targets ? _toArray(targets).forEach(function (target) { // saved styles are recorded in a consecutive alternating Array, like [element, cssText, transform attribute, cache, matchMedia, ...] if (target && target.style) { var i = _savedStyles.indexOf(target); i >= 0 && _savedStyles.splice(i, 5); _savedStyles.push(target, target.style.cssText, target.getBBox && target.getAttribute("transform"), gsap.core.getCache(target), _context()); } }) : _savedStyles; }; ScrollTrigger.revert = function (soft, media) { return _revertAll(!soft, media); }; ScrollTrigger.create = function (vars, animation) { return new ScrollTrigger(vars, animation); }; ScrollTrigger.refresh = function (safe) { return safe ? _onResize() : (_coreInitted || ScrollTrigger.register()) && _refreshAll(true); }; ScrollTrigger.update = function (force) { return ++_Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.cache && _updateAll(force === true ? 2 : 0); }; ScrollTrigger.clearScrollMemory = _clearScrollMemory; ScrollTrigger.maxScroll = function (element, horizontal) { return _maxScroll(element, horizontal ? _Observer_js__WEBPACK_IMPORTED_MODULE_0__._horizontal : _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical); }; ScrollTrigger.getScrollFunc = function (element, horizontal) { return (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getScrollFunc)((0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getTarget)(element), horizontal ? _Observer_js__WEBPACK_IMPORTED_MODULE_0__._horizontal : _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical); }; ScrollTrigger.getById = function (id) { return _ids[id]; }; ScrollTrigger.getAll = function () { return _triggers.filter(function (t) { return t.vars.id !== "ScrollSmoother"; }); }; // it's common for people to ScrollTrigger.getAll(t => t.kill()) on page routes, for example, and we don't want it to ruin smooth scrolling by killing the main ScrollSmoother one. ScrollTrigger.isScrolling = function () { return !!_lastScrollTime; }; ScrollTrigger.snapDirectional = _snapDirectional; ScrollTrigger.addEventListener = function (type, callback) { var a = _listeners[type] || (_listeners[type] = []); ~a.indexOf(callback) || a.push(callback); }; ScrollTrigger.removeEventListener = function (type, callback) { var a = _listeners[type], i = a && a.indexOf(callback); i >= 0 && a.splice(i, 1); }; ScrollTrigger.batch = function (targets, vars) { var result = [], varsCopy = {}, interval = vars.interval || 0.016, batchMax = vars.batchMax || 1e9, proxyCallback = function proxyCallback(type, callback) { var elements = [], triggers = [], delay = gsap.delayedCall(interval, function () { callback(elements, triggers); elements = []; triggers = []; }).pause(); return function (self) { elements.length || delay.restart(true); elements.push(self.trigger); triggers.push(self); batchMax <= elements.length && delay.progress(1); }; }, p; for (p in vars) { varsCopy[p] = p.substr(0, 2) === "on" && _isFunction(vars[p]) && p !== "onRefreshInit" ? proxyCallback(p, vars[p]) : vars[p]; } if (_isFunction(batchMax)) { batchMax = batchMax(); _addListener(ScrollTrigger, "refresh", function () { return batchMax = vars.batchMax(); }); } _toArray(targets).forEach(function (target) { var config = {}; for (p in varsCopy) { config[p] = varsCopy[p]; } config.trigger = target; result.push(ScrollTrigger.create(config)); }); return result; }; // to reduce file size. clamps the scroll and also returns a duration multiplier so that if the scroll gets chopped shorter, the duration gets curtailed as well (otherwise if you're very close to the top of the page, for example, and swipe up really fast, it'll suddenly slow down and take a long time to reach the top). var _clampScrollAndGetDurationMultiplier = function _clampScrollAndGetDurationMultiplier(scrollFunc, current, end, max) { current > max ? scrollFunc(max) : current < 0 && scrollFunc(0); return end > max ? (max - current) / (end - current) : end < 0 ? current / (current - end) : 1; }, _allowNativePanning = function _allowNativePanning(target, direction) { if (direction === true) { target.style.removeProperty("touch-action"); } else { target.style.touchAction = direction === true ? "auto" : direction ? "pan-" + direction + (_Observer_js__WEBPACK_IMPORTED_MODULE_0__.Observer.isTouch ? " pinch-zoom" : "") : "none"; // note: Firefox doesn't support it pinch-zoom properly, at least in addition to a pan-x or pan-y. } target === _docEl && _allowNativePanning(_body, direction); }, _overflow = { auto: 1, scroll: 1 }, _nestedScroll = function _nestedScroll(_ref5) { var event = _ref5.event, target = _ref5.target, axis = _ref5.axis; var node = (event.changedTouches ? event.changedTouches[0] : event).target, cache = node._gsap || gsap.core.getCache(node), time = _getTime(), cs; if (!cache._isScrollT || time - cache._isScrollT > 2000) { // cache for 2 seconds to improve performance. while (node && node !== _body && (node.scrollHeight <= node.clientHeight && node.scrollWidth <= node.clientWidth || !(_overflow[(cs = _getComputedStyle(node)).overflowY] || _overflow[cs.overflowX]))) { node = node.parentNode; } cache._isScroll = node && node !== target && !_isViewport(node) && (_overflow[(cs = _getComputedStyle(node)).overflowY] || _overflow[cs.overflowX]); cache._isScrollT = time; } if (cache._isScroll || axis === "x") { event.stopPropagation(); event._gsapAllow = true; } }, // capture events on scrollable elements INSIDE the and allow those by calling stopPropagation() when we find a scrollable ancestor _inputObserver = function _inputObserver(target, type, inputs, nested) { return _Observer_js__WEBPACK_IMPORTED_MODULE_0__.Observer.create({ target: target, capture: true, debounce: false, lockAxis: true, type: type, onWheel: nested = nested && _nestedScroll, onPress: nested, onDrag: nested, onScroll: nested, onEnable: function onEnable() { return inputs && _addListener(_doc, _Observer_js__WEBPACK_IMPORTED_MODULE_0__.Observer.eventTypes[0], _captureInputs, false, true); }, onDisable: function onDisable() { return _removeListener(_doc, _Observer_js__WEBPACK_IMPORTED_MODULE_0__.Observer.eventTypes[0], _captureInputs, true); } }); }, _inputExp = /(input|label|select|textarea)/i, _inputIsFocused, _captureInputs = function _captureInputs(e) { var isInput = _inputExp.test(e.target.tagName); if (isInput || _inputIsFocused) { e._gsapAllow = true; _inputIsFocused = isInput; } }, _getScrollNormalizer = function _getScrollNormalizer(vars) { _isObject(vars) || (vars = {}); vars.preventDefault = vars.isNormalizer = vars.allowClicks = true; vars.type || (vars.type = "wheel,touch"); vars.debounce = !!vars.debounce; vars.id = vars.id || "normalizer"; var _vars2 = vars, normalizeScrollX = _vars2.normalizeScrollX, momentum = _vars2.momentum, allowNestedScroll = _vars2.allowNestedScroll, onRelease = _vars2.onRelease, self, maxY, target = (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getTarget)(vars.target) || _docEl, smoother = gsap.core.globals().ScrollSmoother, smootherInstance = smoother && smoother.get(), content = _fixIOSBug && (vars.content && (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getTarget)(vars.content) || smootherInstance && vars.content !== false && !smootherInstance.smooth() && smootherInstance.content()), scrollFuncY = (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getScrollFunc)(target, _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical), scrollFuncX = (0,_Observer_js__WEBPACK_IMPORTED_MODULE_0__._getScrollFunc)(target, _Observer_js__WEBPACK_IMPORTED_MODULE_0__._horizontal), scale = 1, initialScale = (_Observer_js__WEBPACK_IMPORTED_MODULE_0__.Observer.isTouch && _win.visualViewport ? _win.visualViewport.scale * _win.visualViewport.width : _win.outerWidth) / _win.innerWidth, wheelRefresh = 0, resolveMomentumDuration = _isFunction(momentum) ? function () { return momentum(self); } : function () { return momentum || 2.8; }, lastRefreshID, skipTouchMove, inputObserver = _inputObserver(target, vars.type, true, allowNestedScroll), resumeTouchMove = function resumeTouchMove() { return skipTouchMove = false; }, scrollClampX = _passThrough, scrollClampY = _passThrough, updateClamps = function updateClamps() { maxY = _maxScroll(target, _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical); scrollClampY = _clamp(_fixIOSBug ? 1 : 0, maxY); normalizeScrollX && (scrollClampX = _clamp(0, _maxScroll(target, _Observer_js__WEBPACK_IMPORTED_MODULE_0__._horizontal))); lastRefreshID = _refreshID; }, removeContentOffset = function removeContentOffset() { content._gsap.y = _round(parseFloat(content._gsap.y) + scrollFuncY.offset) + "px"; content.style.transform = "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, " + parseFloat(content._gsap.y) + ", 0, 1)"; scrollFuncY.offset = scrollFuncY.cacheID = 0; }, ignoreDrag = function ignoreDrag() { if (skipTouchMove) { requestAnimationFrame(resumeTouchMove); var offset = _round(self.deltaY / 2), scroll = scrollClampY(scrollFuncY.v - offset); if (content && scroll !== scrollFuncY.v + scrollFuncY.offset) { scrollFuncY.offset = scroll - scrollFuncY.v; var y = _round((parseFloat(content && content._gsap.y) || 0) - scrollFuncY.offset); content.style.transform = "matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, " + y + ", 0, 1)"; content._gsap.y = y + "px"; scrollFuncY.cacheID = _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.cache; _updateAll(); } return true; } scrollFuncY.offset && removeContentOffset(); skipTouchMove = true; }, tween, startScrollX, startScrollY, onStopDelayedCall, onResize = function onResize() { // if the window resizes, like on an iPhone which Apple FORCES the address bar to show/hide even if we event.preventDefault(), it may be scrolling too far now that the address bar is showing, so we must dynamically adjust the momentum tween. updateClamps(); if (tween.isActive() && tween.vars.scrollY > maxY) { scrollFuncY() > maxY ? tween.progress(1) && scrollFuncY(maxY) : tween.resetTo("scrollY", maxY); } }; content && gsap.set(content, { y: "+=0" }); // to ensure there's a cache (element._gsap) vars.ignoreCheck = function (e) { return _fixIOSBug && e.type === "touchmove" && ignoreDrag(e) || scale > 1.05 && e.type !== "touchstart" || self.isGesturing || e.touches && e.touches.length > 1; }; vars.onPress = function () { skipTouchMove = false; var prevScale = scale; scale = _round((_win.visualViewport && _win.visualViewport.scale || 1) / initialScale); tween.pause(); prevScale !== scale && _allowNativePanning(target, scale > 1.01 ? true : normalizeScrollX ? false : "x"); startScrollX = scrollFuncX(); startScrollY = scrollFuncY(); updateClamps(); lastRefreshID = _refreshID; }; vars.onRelease = vars.onGestureStart = function (self, wasDragging) { scrollFuncY.offset && removeContentOffset(); if (!wasDragging) { onStopDelayedCall.restart(true); } else { _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers.cache++; // make sure we're pulling the non-cached value // alternate algorithm: durX = Math.min(6, Math.abs(self.velocityX / 800)), dur = Math.max(durX, Math.min(6, Math.abs(self.velocityY / 800))); dur = dur * (0.4 + (1 - _power4In(dur / 6)) * 0.6)) * (momentumSpeed || 1) var dur = resolveMomentumDuration(), currentScroll, endScroll; if (normalizeScrollX) { currentScroll = scrollFuncX(); endScroll = currentScroll + dur * 0.05 * -self.velocityX / 0.227; // the constant .227 is from power4(0.05). velocity is inverted because scrolling goes in the opposite direction. dur *= _clampScrollAndGetDurationMultiplier(scrollFuncX, currentScroll, endScroll, _maxScroll(target, _Observer_js__WEBPACK_IMPORTED_MODULE_0__._horizontal)); tween.vars.scrollX = scrollClampX(endScroll); } currentScroll = scrollFuncY(); endScroll = currentScroll + dur * 0.05 * -self.velocityY / 0.227; // the constant .227 is from power4(0.05) dur *= _clampScrollAndGetDurationMultiplier(scrollFuncY, currentScroll, endScroll, _maxScroll(target, _Observer_js__WEBPACK_IMPORTED_MODULE_0__._vertical)); tween.vars.scrollY = scrollClampY(endScroll); tween.invalidate().duration(dur).play(0.01); if (_fixIOSBug && tween.vars.scrollY >= maxY || currentScroll >= maxY - 1) { // iOS bug: it'll show the address bar but NOT fire the window "resize" event until the animation is done but we must protect against overshoot so we leverage an onUpdate to do so. gsap.to({}, { onUpdate: onResize, duration: dur }); } } onRelease && onRelease(self); }; vars.onWheel = function () { tween._ts && tween.pause(); if (_getTime() - wheelRefresh > 1000) { // after 1 second, refresh the clamps otherwise that'll only happen when ScrollTrigger.refresh() is called or for touch-scrolling. lastRefreshID = 0; wheelRefresh = _getTime(); } }; vars.onChange = function (self, dx, dy, xArray, yArray) { _refreshID !== lastRefreshID && updateClamps(); dx && normalizeScrollX && scrollFuncX(scrollClampX(xArray[2] === dx ? startScrollX + (self.startX - self.x) : scrollFuncX() + dx - xArray[1])); // for more precision, we track pointer/touch movement from the start, otherwise it'll drift. if (dy) { scrollFuncY.offset && removeContentOffset(); var isTouch = yArray[2] === dy, y = isTouch ? startScrollY + self.startY - self.y : scrollFuncY() + dy - yArray[1], yClamped = scrollClampY(y); isTouch && y !== yClamped && (startScrollY += yClamped - y); scrollFuncY(yClamped); } (dy || dx) && _updateAll(); }; vars.onEnable = function () { _allowNativePanning(target, normalizeScrollX ? false : "x"); ScrollTrigger.addEventListener("refresh", onResize); _addListener(_win, "resize", onResize); if (scrollFuncY.smooth) { scrollFuncY.target.style.scrollBehavior = "auto"; scrollFuncY.smooth = scrollFuncX.smooth = false; } inputObserver.enable(); }; vars.onDisable = function () { _allowNativePanning(target, true); _removeListener(_win, "resize", onResize); ScrollTrigger.removeEventListener("refresh", onResize); inputObserver.kill(); }; vars.lockAxis = vars.lockAxis !== false; self = new _Observer_js__WEBPACK_IMPORTED_MODULE_0__.Observer(vars); self.iOS = _fixIOSBug; // used in the Observer getCachedScroll() function to work around an iOS bug that wreaks havoc with TouchEvent.clientY if we allow scroll to go all the way back to 0. _fixIOSBug && !scrollFuncY() && scrollFuncY(1); // iOS bug causes event.clientY values to freak out (wildly inaccurate) if the scroll position is exactly 0. _fixIOSBug && gsap.ticker.add(_passThrough); // prevent the ticker from sleeping onStopDelayedCall = self._dc; tween = gsap.to(self, { ease: "power4", paused: true, scrollX: normalizeScrollX ? "+=0.1" : "+=0", scrollY: "+=0.1", modifiers: { scrollY: _interruptionTracker(scrollFuncY, scrollFuncY(), function () { return tween.pause(); }) }, onUpdate: _updateAll, onComplete: onStopDelayedCall.vars.onComplete }); // we need the modifier to sense if the scroll position is altered outside of the momentum tween (like with a scrollTo tween) so we can pause() it to prevent conflicts. return self; }; ScrollTrigger.sort = function (func) { return _triggers.sort(func || function (a, b) { return (a.vars.refreshPriority || 0) * -1e6 + a.start - (b.start + (b.vars.refreshPriority || 0) * -1e6); }); }; ScrollTrigger.observe = function (vars) { return new _Observer_js__WEBPACK_IMPORTED_MODULE_0__.Observer(vars); }; ScrollTrigger.normalizeScroll = function (vars) { if (typeof vars === "undefined") { return _normalizer; } if (vars === true && _normalizer) { return _normalizer.enable(); } if (vars === false) { return _normalizer && _normalizer.kill(); } var normalizer = vars instanceof _Observer_js__WEBPACK_IMPORTED_MODULE_0__.Observer ? vars : _getScrollNormalizer(vars); _normalizer && _normalizer.target === normalizer.target && _normalizer.kill(); _isViewport(normalizer.target) && (_normalizer = normalizer); return normalizer; }; ScrollTrigger.core = { // smaller file size way to leverage in ScrollSmoother and Observer _getVelocityProp: _Observer_js__WEBPACK_IMPORTED_MODULE_0__._getVelocityProp, _inputObserver: _inputObserver, _scrollers: _Observer_js__WEBPACK_IMPORTED_MODULE_0__._scrollers, _proxies: _Observer_js__WEBPACK_IMPORTED_MODULE_0__._proxies, bridge: { // when normalizeScroll sets the scroll position (ss = setScroll) ss: function ss() { _lastScrollTime || _dispatch("scrollStart"); _lastScrollTime = _getTime(); }, // a way to get the _refreshing value in Observer ref: function ref() { return _refreshing; } } }; _getGSAP() && gsap.registerPlugin(ScrollTrigger); /***/ }), /***/ "../../node_modules/gsap/gsap-core.js": /*!********************************************!*\ !*** ../../node_modules/gsap/gsap-core.js ***! \********************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Animation: function() { return /* binding */ Animation; }, /* harmony export */ Back: function() { return /* binding */ Back; }, /* harmony export */ Bounce: function() { return /* binding */ Bounce; }, /* harmony export */ Circ: function() { return /* binding */ Circ; }, /* harmony export */ Cubic: function() { return /* binding */ Cubic; }, /* harmony export */ Elastic: function() { return /* binding */ Elastic; }, /* harmony export */ Expo: function() { return /* binding */ Expo; }, /* harmony export */ GSCache: function() { return /* binding */ GSCache; }, /* harmony export */ Linear: function() { return /* binding */ Linear; }, /* harmony export */ Power0: function() { return /* binding */ Power0; }, /* harmony export */ Power1: function() { return /* binding */ Power1; }, /* harmony export */ Power2: function() { return /* binding */ Power2; }, /* harmony export */ Power3: function() { return /* binding */ Power3; }, /* harmony export */ Power4: function() { return /* binding */ Power4; }, /* harmony export */ PropTween: function() { return /* binding */ PropTween; }, /* harmony export */ Quad: function() { return /* binding */ Quad; }, /* harmony export */ Quart: function() { return /* binding */ Quart; }, /* harmony export */ Quint: function() { return /* binding */ Quint; }, /* harmony export */ Sine: function() { return /* binding */ Sine; }, /* harmony export */ SteppedEase: function() { return /* binding */ SteppedEase; }, /* harmony export */ Strong: function() { return /* binding */ Strong; }, /* harmony export */ Timeline: function() { return /* binding */ Timeline; }, /* harmony export */ TimelineLite: function() { return /* binding */ Timeline; }, /* harmony export */ TimelineMax: function() { return /* binding */ Timeline; }, /* harmony export */ Tween: function() { return /* binding */ Tween; }, /* harmony export */ TweenLite: function() { return /* binding */ Tween; }, /* harmony export */ TweenMax: function() { return /* binding */ Tween; }, /* harmony export */ _checkPlugin: function() { return /* binding */ _checkPlugin; }, /* harmony export */ _colorExp: function() { return /* binding */ _colorExp; }, /* harmony export */ _colorStringFilter: function() { return /* binding */ _colorStringFilter; }, /* harmony export */ _config: function() { return /* binding */ _config; }, /* harmony export */ _forEachName: function() { return /* binding */ _forEachName; }, /* harmony export */ _getCache: function() { return /* binding */ _getCache; }, /* harmony export */ _getProperty: function() { return /* binding */ _getProperty; }, /* harmony export */ _getSetter: function() { return /* binding */ _getSetter; }, /* harmony export */ _isString: function() { return /* binding */ _isString; }, /* harmony export */ _isUndefined: function() { return /* binding */ _isUndefined; }, /* harmony export */ _missingPlugin: function() { return /* binding */ _missingPlugin; }, /* harmony export */ _numExp: function() { return /* binding */ _numExp; }, /* harmony export */ _numWithUnitExp: function() { return /* binding */ _numWithUnitExp; }, /* harmony export */ _parseRelative: function() { return /* binding */ _parseRelative; }, /* harmony export */ _plugins: function() { return /* binding */ _plugins; }, /* harmony export */ _relExp: function() { return /* binding */ _relExp; }, /* harmony export */ _removeLinkedListItem: function() { return /* binding */ _removeLinkedListItem; }, /* harmony export */ _renderComplexString: function() { return /* binding */ _renderComplexString; }, /* harmony export */ _replaceRandom: function() { return /* binding */ _replaceRandom; }, /* harmony export */ _round: function() { return /* binding */ _round; }, /* harmony export */ _roundModifier: function() { return /* binding */ _roundModifier; }, /* harmony export */ _setDefaults: function() { return /* binding */ _setDefaults; }, /* harmony export */ _sortPropTweensByPriority: function() { return /* binding */ _sortPropTweensByPriority; }, /* harmony export */ _ticker: function() { return /* binding */ _ticker; }, /* harmony export */ clamp: function() { return /* binding */ clamp; }, /* harmony export */ "default": function() { return /* binding */ gsap; }, /* harmony export */ distribute: function() { return /* binding */ distribute; }, /* harmony export */ getUnit: function() { return /* binding */ getUnit; }, /* harmony export */ gsap: function() { return /* binding */ gsap; }, /* harmony export */ interpolate: function() { return /* binding */ interpolate; }, /* harmony export */ mapRange: function() { return /* binding */ mapRange; }, /* harmony export */ normalize: function() { return /* binding */ normalize; }, /* harmony export */ pipe: function() { return /* binding */ pipe; }, /* harmony export */ random: function() { return /* binding */ random; }, /* harmony export */ selector: function() { return /* binding */ selector; }, /* harmony export */ shuffle: function() { return /* binding */ shuffle; }, /* harmony export */ snap: function() { return /* binding */ snap; }, /* harmony export */ splitColor: function() { return /* binding */ splitColor; }, /* harmony export */ toArray: function() { return /* binding */ toArray; }, /* harmony export */ unitize: function() { return /* binding */ unitize; }, /* harmony export */ wrap: function() { return /* binding */ wrap; }, /* harmony export */ wrapYoyo: function() { return /* binding */ wrapYoyo; } /* harmony export */ }); function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } /*! * GSAP 3.12.2 * https://greensock.com * * @license Copyright 2008-2023, GreenSock. All rights reserved. * Subject to the terms at https://greensock.com/standard-license or for * Club GreenSock members, the agreement issued with that membership. * @author: Jack Doyle, jack@greensock.com */ /* eslint-disable */ var _config = { autoSleep: 120, force3D: "auto", nullTargetWarn: 1, units: { lineHeight: "" } }, _defaults = { duration: .5, overwrite: false, delay: 0 }, _suppressOverwrites, _reverting, _context, _bigNum = 1e8, _tinyNum = 1 / _bigNum, _2PI = Math.PI * 2, _HALF_PI = _2PI / 4, _gsID = 0, _sqrt = Math.sqrt, _cos = Math.cos, _sin = Math.sin, _isString = function _isString(value) { return typeof value === "string"; }, _isFunction = function _isFunction(value) { return typeof value === "function"; }, _isNumber = function _isNumber(value) { return typeof value === "number"; }, _isUndefined = function _isUndefined(value) { return typeof value === "undefined"; }, _isObject = function _isObject(value) { return typeof value === "object"; }, _isNotFalse = function _isNotFalse(value) { return value !== false; }, _windowExists = function _windowExists() { return typeof window !== "undefined"; }, _isFuncOrString = function _isFuncOrString(value) { return _isFunction(value) || _isString(value); }, _isTypedArray = typeof ArrayBuffer === "function" && ArrayBuffer.isView || function () {}, // note: IE10 has ArrayBuffer, but NOT ArrayBuffer.isView(). _isArray = Array.isArray, _strictNumExp = /(?:-?\.?\d|\.)+/gi, //only numbers (including negatives and decimals) but NOT relative values. _numExp = /[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g, //finds any numbers, including ones that start with += or -=, negative numbers, and ones in scientific notation like 1e-8. _numWithUnitExp = /[-+=.]*\d+[.e-]*\d*[a-z%]*/g, _complexStringNumExp = /[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi, //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. _relExp = /[+-]=-?[.\d]+/, _delimitedValueExp = /[^,'"\[\]\s]+/gi, // previously /[#\-+.]*\b[a-z\d\-=+%.]+/gi but didn't catch special characters. _unitExp = /^[+\-=e\s\d]*\d+[.\d]*([a-z]*|%)\s*$/i, _globalTimeline, _win, _coreInitted, _doc, _globals = {}, _installScope = {}, _coreReady, _install = function _install(scope) { return (_installScope = _merge(scope, _globals)) && gsap; }, _missingPlugin = function _missingPlugin(property, value) { return console.warn("Invalid property", property, "set to", value, "Missing plugin? gsap.registerPlugin()"); }, _warn = function _warn(message, suppress) { return !suppress && console.warn(message); }, _addGlobal = function _addGlobal(name, obj) { return name && (_globals[name] = obj) && _installScope && (_installScope[name] = obj) || _globals; }, _emptyFunc = function _emptyFunc() { return 0; }, _startAtRevertConfig = { suppressEvents: true, isStart: true, kill: false }, _revertConfigNoKill = { suppressEvents: true, kill: false }, _revertConfig = { suppressEvents: true }, _reservedProps = {}, _lazyTweens = [], _lazyLookup = {}, _lastRenderedFrame, _plugins = {}, _effects = {}, _nextGCFrame = 30, _harnessPlugins = [], _callbackNames = "", _harness = function _harness(targets) { var target = targets[0], harnessPlugin, i; _isObject(target) || _isFunction(target) || (targets = [targets]); if (!(harnessPlugin = (target._gsap || {}).harness)) { // 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) i = _harnessPlugins.length; while (i-- && !_harnessPlugins[i].targetTest(target)) {} harnessPlugin = _harnessPlugins[i]; } i = targets.length; while (i--) { targets[i] && (targets[i]._gsap || (targets[i]._gsap = new GSCache(targets[i], harnessPlugin))) || targets.splice(i, 1); } return targets; }, _getCache = function _getCache(target) { return target._gsap || _harness(toArray(target))[0]._gsap; }, _getProperty = function _getProperty(target, property, v) { return (v = target[property]) && _isFunction(v) ? target[property]() : _isUndefined(v) && target.getAttribute && target.getAttribute(property) || v; }, _forEachName = function _forEachName(names, func) { return (names = names.split(",")).forEach(func) || names; }, //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). _round = function _round(value) { return Math.round(value * 100000) / 100000 || 0; }, _roundPrecise = function _roundPrecise(value) { return Math.round(value * 10000000) / 10000000 || 0; }, // increased precision mostly for timing values. _parseRelative = function _parseRelative(start, value) { var operator = value.charAt(0), end = parseFloat(value.substr(2)); start = parseFloat(start); return operator === "+" ? start + end : operator === "-" ? start - end : operator === "*" ? start * end : start / end; }, _arrayContainsAny = function _arrayContainsAny(toSearch, toFind) { //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. var l = toFind.length, i = 0; for (; toSearch.indexOf(toFind[i]) < 0 && ++i < l;) {} return i < l; }, _lazyRender = function _lazyRender() { var l = _lazyTweens.length, a = _lazyTweens.slice(0), i, tween; _lazyLookup = {}; _lazyTweens.length = 0; for (i = 0; i < l; i++) { tween = a[i]; tween && tween._lazy && (tween.render(tween._lazy[0], tween._lazy[1], true)._lazy = 0); } }, _lazySafeRender = function _lazySafeRender(animation, time, suppressEvents, force) { _lazyTweens.length && !_reverting && _lazyRender(); animation.render(time, suppressEvents, force || _reverting && time < 0 && (animation._initted || animation._startAt)); _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. }, _numericIfPossible = function _numericIfPossible(value) { var n = parseFloat(value); return (n || n === 0) && (value + "").match(_delimitedValueExp).length < 2 ? n : _isString(value) ? value.trim() : value; }, _passThrough = function _passThrough(p) { return p; }, _setDefaults = function _setDefaults(obj, defaults) { for (var p in defaults) { p in obj || (obj[p] = defaults[p]); } return obj; }, _setKeyframeDefaults = function _setKeyframeDefaults(excludeDuration) { return function (obj, defaults) { for (var p in defaults) { p in obj || p === "duration" && excludeDuration || p === "ease" || (obj[p] = defaults[p]); } }; }, _merge = function _merge(base, toMerge) { for (var p in toMerge) { base[p] = toMerge[p]; } return base; }, _mergeDeep = function _mergeDeep(base, toMerge) { for (var p in toMerge) { p !== "__proto__" && p !== "constructor" && p !== "prototype" && (base[p] = _isObject(toMerge[p]) ? _mergeDeep(base[p] || (base[p] = {}), toMerge[p]) : toMerge[p]); } return base; }, _copyExcluding = function _copyExcluding(obj, excluding) { var copy = {}, p; for (p in obj) { p in excluding || (copy[p] = obj[p]); } return copy; }, _inheritDefaults = function _inheritDefaults(vars) { var parent = vars.parent || _globalTimeline, func = vars.keyframes ? _setKeyframeDefaults(_isArray(vars.keyframes)) : _setDefaults; if (_isNotFalse(vars.inherit)) { while (parent) { func(vars, parent.vars.defaults); parent = parent.parent || parent._dp; } } return vars; }, _arraysMatch = function _arraysMatch(a1, a2) { var i = a1.length, match = i === a2.length; while (match && i-- && a1[i] === a2[i]) {} return i < 0; }, _addLinkedListItem = function _addLinkedListItem(parent, child, firstProp, lastProp, sortBy) { if (firstProp === void 0) { firstProp = "_first"; } if (lastProp === void 0) { lastProp = "_last"; } var prev = parent[lastProp], t; if (sortBy) { t = child[sortBy]; while (prev && prev[sortBy] > t) { prev = prev._prev; } } if (prev) { child._next = prev._next; prev._next = child; } else { child._next = parent[firstProp]; parent[firstProp] = child; } if (child._next) { child._next._prev = child; } else { parent[lastProp] = child; } child._prev = prev; child.parent = child._dp = parent; return child; }, _removeLinkedListItem = function _removeLinkedListItem(parent, child, firstProp, lastProp) { if (firstProp === void 0) { firstProp = "_first"; } if (lastProp === void 0) { lastProp = "_last"; } var prev = child._prev, next = child._next; if (prev) { prev._next = next; } else if (parent[firstProp] === child) { parent[firstProp] = next; } if (next) { next._prev = prev; } else if (parent[lastProp] === child) { parent[lastProp] = prev; } 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. }, _removeFromParent = function _removeFromParent(child, onlyIfParentHasAutoRemove) { child.parent && (!onlyIfParentHasAutoRemove || child.parent.autoRemoveChildren) && child.parent.remove && child.parent.remove(child); child._act = 0; }, _uncache = function _uncache(animation, child) { if (animation && (!child || child._end > animation._dur || child._start < 0)) { // 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) var a = animation; while (a) { a._dirty = 1; a = a.parent; } } return animation; }, _recacheAncestors = function _recacheAncestors(animation) { var parent = animation.parent; while (parent && parent.parent) { //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. parent._dirty = 1; parent.totalDuration(); parent = parent.parent; } return animation; }, _rewindStartAt = function _rewindStartAt(tween, totalTime, suppressEvents, force) { return tween._startAt && (_reverting ? tween._startAt.revert(_revertConfigNoKill) : tween.vars.immediateRender && !tween.vars.autoRevert || tween._startAt.render(totalTime, true, force)); }, _hasNoPausedAncestors = function _hasNoPausedAncestors(animation) { return !animation || animation._ts && _hasNoPausedAncestors(animation.parent); }, _elapsedCycleDuration = function _elapsedCycleDuration(animation) { return animation._repeat ? _animationCycle(animation._tTime, animation = animation.duration() + animation._rDelay) * animation : 0; }, // 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. _animationCycle = function _animationCycle(tTime, cycleDuration) { var whole = Math.floor(tTime /= cycleDuration); return tTime && whole === tTime ? whole - 1 : whole; }, _parentToChildTotalTime = function _parentToChildTotalTime(parentTime, child) { return (parentTime - child._start) * child._ts + (child._ts >= 0 ? 0 : child._dirty ? child.totalDuration() : child._tDur); }, _setEnd = function _setEnd(animation) { return animation._end = _roundPrecise(animation._start + (animation._tDur / Math.abs(animation._ts || animation._rts || _tinyNum) || 0)); }, _alignPlayhead = function _alignPlayhead(animation, totalTime) { // 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. var parent = animation._dp; if (parent && parent.smoothChildTiming && animation._ts) { animation._start = _roundPrecise(parent._time - (animation._ts > 0 ? totalTime / animation._ts : ((animation._dirty ? animation.totalDuration() : animation._tDur) - totalTime) / -animation._ts)); _setEnd(animation); 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. } return animation; }, /* _totalTimeToTime = (clampedTotalTime, duration, repeat, repeatDelay, yoyo) => { let cycleDuration = duration + repeatDelay, time = _round(clampedTotalTime % cycleDuration); if (time > duration) { time = duration; } return (yoyo && (~~(clampedTotalTime / cycleDuration) & 1)) ? duration - time : time; }, */ _postAddChecks = function _postAddChecks(timeline, child) { var t; if (child._time || !child._dur && child._initted || child._start < timeline._time && (child._dur || !child.add)) { // 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). t = _parentToChildTotalTime(timeline.rawTime(), child); if (!child._dur || _clamp(0, child.totalDuration(), t) - child._tTime > _tinyNum) { child.render(t, true); } } //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. if (_uncache(timeline, child)._dp && timeline._initted && timeline._time >= timeline._dur && timeline._ts) { //in case any of the ancestors had completed but should now be enabled... if (timeline._dur < timeline.duration()) { t = timeline; while (t._dp) { 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. t = t._dp; } } 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. } }, _addToTimeline = function _addToTimeline(timeline, child, position, skipChecks) { child.parent && _removeFromParent(child); child._start = _roundPrecise((_isNumber(position) ? position : position || timeline !== _globalTimeline ? _parsePosition(timeline, position, child) : timeline._time) + child._delay); child._end = _roundPrecise(child._start + (child.totalDuration() / Math.abs(child.timeScale()) || 0)); _addLinkedListItem(timeline, child, "_first", "_last", timeline._sort ? "_start" : 0); _isFromOrFromStart(child) || (timeline._recent = child); skipChecks || _postAddChecks(timeline, child); 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) return timeline; }, _scrollTrigger = function _scrollTrigger(animation, trigger) { return (_globals.ScrollTrigger || _missingPlugin("scrollTrigger", trigger)) && _globals.ScrollTrigger.create(trigger, animation); }, _attemptInitTween = function _attemptInitTween(tween, time, force, suppressEvents, tTime) { _initTween(tween, time, tTime); if (!tween._initted) { return 1; } if (!force && tween._pt && !_reverting && (tween._dur && tween.vars.lazy !== false || !tween._dur && tween.vars.lazy) && _lastRenderedFrame !== _ticker.frame) { _lazyTweens.push(tween); tween._lazy = [tTime, suppressEvents]; return 1; } }, _parentPlayheadIsBeforeStart = function _parentPlayheadIsBeforeStart(_ref) { var parent = _ref.parent; return parent && parent._ts && parent._initted && !parent._lock && (parent.rawTime() < 0 || _parentPlayheadIsBeforeStart(parent)); }, // check parent's _lock because when a timeline repeats/yoyos and does its artificial wrapping, we shouldn't force the ratio back to 0 _isFromOrFromStart = function _isFromOrFromStart(_ref2) { var data = _ref2.data; return data === "isFromStart" || data === "isStart"; }, _renderZeroDurationTween = function _renderZeroDurationTween(tween, totalTime, suppressEvents, force) { var prevRatio = tween.ratio, ratio = totalTime < 0 || !totalTime && (!tween._start && _parentPlayheadIsBeforeStart(tween) && !(!tween._initted && _isFromOrFromStart(tween)) || (tween._ts < 0 || tween._dp._ts < 0) && !_isFromOrFromStart(tween)) ? 0 : 1, // 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. repeatDelay = tween._rDelay, tTime = 0, pt, iteration, prevIteration; if (repeatDelay && tween._repeat) { // in case there's a zero-duration tween that has a repeat with a repeatDelay tTime = _clamp(0, tween._tDur, totalTime); iteration = _animationCycle(tTime, repeatDelay); tween._yoyo && iteration & 1 && (ratio = 1 - ratio); if (iteration !== _animationCycle(tween._tTime, repeatDelay)) { // if iteration changed prevRatio = 1 - ratio; tween.vars.repeatRefresh && tween._initted && tween.invalidate(); } } if (ratio !== prevRatio || _reverting || force || tween._zTime === _tinyNum || !totalTime && tween._zTime) { if (!tween._initted && _attemptInitTween(tween, totalTime, force, suppressEvents, tTime)) { // 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. return; } prevIteration = tween._zTime; 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. 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. tween.ratio = ratio; tween._from && (ratio = 1 - ratio); tween._time = 0; tween._tTime = tTime; pt = tween._pt; while (pt) { pt.r(ratio, pt.d); pt = pt._next; } totalTime < 0 && _rewindStartAt(tween, totalTime, suppressEvents, true); tween._onUpdate && !suppressEvents && _callback(tween, "onUpdate"); tTime && tween._repeat && !suppressEvents && tween.parent && _callback(tween, "onRepeat"); if ((totalTime >= tween._tDur || totalTime < 0) && tween.ratio === ratio) { ratio && _removeFromParent(tween, 1); if (!suppressEvents && !_reverting) { _callback(tween, ratio ? "onComplete" : "onReverseComplete", true); tween._prom && tween._prom(); } } } else if (!tween._zTime) { tween._zTime = totalTime; } }, _findNextPauseTween = function _findNextPauseTween(animation, prevTime, time) { var child; if (time > prevTime) { child = animation._first; while (child && child._start <= time) { if (child.data === "isPause" && child._start > prevTime) { return child; } child = child._next; } } else { child = animation._last; while (child && child._start >= time) { if (child.data === "isPause" && child._start < prevTime) { return child; } child = child._prev; } } }, _setDuration = function _setDuration(animation, duration, skipUncache, leavePlayhead) { var repeat = animation._repeat, dur = _roundPrecise(duration) || 0, totalProgress = animation._tTime / animation._tDur; totalProgress && !leavePlayhead && (animation._time *= dur / animation._dur); animation._dur = dur; animation._tDur = !repeat ? dur : repeat < 0 ? 1e10 : _roundPrecise(dur * (repeat + 1) + animation._rDelay * repeat); totalProgress > 0 && !leavePlayhead && _alignPlayhead(animation, animation._tTime = animation._tDur * totalProgress); animation.parent && _setEnd(animation); skipUncache || _uncache(animation.parent, animation); return animation; }, _onUpdateTotalDuration = function _onUpdateTotalDuration(animation) { return animation instanceof Timeline ? _uncache(animation) : _setDuration(animation, animation._dur); }, _zeroPosition = { _start: 0, endTime: _emptyFunc, totalDuration: _emptyFunc }, _parsePosition = function _parsePosition(animation, position, percentAnimation) { var labels = animation.labels, recent = animation._recent || _zeroPosition, clippedDuration = animation.duration() >= _bigNum ? recent.endTime(false) : animation._dur, //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. i, offset, isPercent; if (_isString(position) && (isNaN(position) || position in labels)) { //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). offset = position.charAt(0); isPercent = position.substr(-1) === "%"; i = position.indexOf("="); if (offset === "<" || offset === ">") { i >= 0 && (position = position.replace(/=/, "")); return (offset === "<" ? recent._start : recent.endTime(recent._repeat >= 0)) + (parseFloat(position.substr(1)) || 0) * (isPercent ? (i < 0 ? recent : percentAnimation).totalDuration() / 100 : 1); } if (i < 0) { position in labels || (labels[position] = clippedDuration); return labels[position]; } offset = parseFloat(position.charAt(i - 1) + position.substr(i + 1)); if (isPercent && percentAnimation) { offset = offset / 100 * (_isArray(percentAnimation) ? percentAnimation[0] : percentAnimation).totalDuration(); } return i > 1 ? _parsePosition(animation, position.substr(0, i - 1), percentAnimation) + offset : clippedDuration + offset; } return position == null ? clippedDuration : +position; }, _createTweenType = function _createTweenType(type, params, timeline) { var isLegacy = _isNumber(params[1]), varsIndex = (isLegacy ? 2 : 1) + (type < 2 ? 0 : 1), vars = params[varsIndex], irVars, parent; isLegacy && (vars.duration = params[1]); vars.parent = timeline; if (type) { irVars = vars; parent = timeline; while (parent && !("immediateRender" in irVars)) { // 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. irVars = parent.vars.defaults || {}; parent = _isNotFalse(parent.vars.inherit) && parent.parent; } vars.immediateRender = _isNotFalse(irVars.immediateRender); type < 2 ? vars.runBackwards = 1 : vars.startAt = params[varsIndex - 1]; // "from" vars } return new Tween(params[0], vars, params[varsIndex + 1]); }, _conditionalReturn = function _conditionalReturn(value, func) { return value || value === 0 ? func(value) : func; }, _clamp = function _clamp(min, max, value) { return value < min ? min : value > max ? max : value; }, getUnit = function getUnit(value, v) { return !_isString(value) || !(v = _unitExp.exec(value)) ? "" : v[1]; }, // 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. clamp = function clamp(min, max, value) { return _conditionalReturn(value, function (v) { return _clamp(min, max, v); }); }, _slice = [].slice, _isArrayLike = function _isArrayLike(value, nonEmpty) { return value && _isObject(value) && "length" in value && (!nonEmpty && !value.length || value.length - 1 in value && _isObject(value[0])) && !value.nodeType && value !== _win; }, _flatten = function _flatten(ar, leaveStrings, accumulator) { if (accumulator === void 0) { accumulator = []; } return ar.forEach(function (value) { var _accumulator; return _isString(value) && !leaveStrings || _isArrayLike(value, 1) ? (_accumulator = accumulator).push.apply(_accumulator, toArray(value)) : accumulator.push(value); }) || accumulator; }, //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. toArray = function toArray(value, scope, leaveStrings) { 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] : []; }, selector = function selector(value) { value = toArray(value)[0] || _warn("Invalid scope") || {}; return function (v) { var el = value.current || value.nativeElement || value; return toArray(v, el.querySelectorAll ? el : el === value ? _warn("Invalid scope") || _doc.createElement("div") : value); }; }, shuffle = function shuffle(a) { return a.sort(function () { return .5 - Math.random(); }); }, // alternative that's a bit faster and more reliably diverse but bigger: for (let j, v, i = a.length; i; j = Math.floor(Math.random() * i), v = a[--i], a[i] = a[j], a[j] = v); return a; //for distributing values across an array. Can accept a number, a function or (most commonly) a function which can contain the following properties: {base, amount, from, ease, grid, axis, length, each}. Returns a function that expects the following parameters: index, target, array. Recognizes the following distribute = function distribute(v) { if (_isFunction(v)) { return v; } var vars = _isObject(v) ? v : { each: v }, //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. ease = _parseEase(vars.ease), from = vars.from || 0, base = parseFloat(vars.base) || 0, cache = {}, isDecimal = from > 0 && from < 1, ratios = isNaN(from) || isDecimal, axis = vars.axis, ratioX = from, ratioY = from; if (_isString(from)) { ratioX = ratioY = { center: .5, edges: .5, end: 1 }[from] || 0; } else if (!isDecimal && ratios) { ratioX = from[0]; ratioY = from[1]; } return function (i, target, a) { var l = (a || vars).length, distances = cache[l], originX, originY, x, y, d, j, max, min, wrapAt; if (!distances) { wrapAt = vars.grid === "auto" ? 0 : (vars.grid || [1, _bigNum])[1]; if (!wrapAt) { max = -_bigNum; while (max < (max = a[wrapAt++].getBoundingClientRect().left) && wrapAt < l) {} wrapAt--; } distances = cache[l] = []; originX = ratios ? Math.min(wrapAt, l) * ratioX - .5 : from % wrapAt; originY = wrapAt === _bigNum ? 0 : ratios ? l * ratioY / wrapAt - .5 : from / wrapAt | 0; max = 0; min = _bigNum; for (j = 0; j < l; j++) { x = j % wrapAt - originX; y = originY - (j / wrapAt | 0); distances[j] = d = !axis ? _sqrt(x * x + y * y) : Math.abs(axis === "y" ? y : x); d > max && (max = d); d < min && (min = d); } from === "random" && shuffle(distances); distances.max = max - min; distances.min = min; 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); distances.b = l < 0 ? base - l : base; distances.u = getUnit(vars.amount || vars.each) || 0; //unit ease = ease && l < 0 ? _invertEase(ease) : ease; } l = (distances[i] - distances.min) / distances.max || 0; return _roundPrecise(distances.b + (ease ? ease(l) : l) * distances.v) + distances.u; //round in order to work around floating point errors }; }, _roundModifier = function _roundModifier(v) { //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. 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()) return function (raw) { var n = _roundPrecise(Math.round(parseFloat(raw) / v) * v * p); 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! }; }, snap = function snap(snapTo, value) { var isArray = _isArray(snapTo), radius, is2D; if (!isArray && _isObject(snapTo)) { radius = isArray = snapTo.radius || _bigNum; if (snapTo.values) { snapTo = toArray(snapTo.values); if (is2D = !_isNumber(snapTo[0])) { radius *= radius; //performance optimization so we don't have to Math.sqrt() in the loop. } } else { snapTo = _roundModifier(snapTo.increment); } } return _conditionalReturn(value, !isArray ? _roundModifier(snapTo) : _isFunction(snapTo) ? function (raw) { is2D = snapTo(raw); return Math.abs(is2D - raw) <= radius ? is2D : raw; } : function (raw) { var x = parseFloat(is2D ? raw.x : raw), y = parseFloat(is2D ? raw.y : 0), min = _bigNum, closest = 0, i = snapTo.length, dx, dy; while (i--) { if (is2D) { dx = snapTo[i].x - x; dy = snapTo[i].y - y; dx = dx * dx + dy * dy; } else { dx = Math.abs(snapTo[i] - x); } if (dx < min) { min = dx; closest = i; } } closest = !radius || min <= radius ? snapTo[closest] : raw; return is2D || closest === raw || _isNumber(raw) ? closest : closest + getUnit(raw); }); }, random = function random(min, max, roundingIncrement, returnFunction) { return _conditionalReturn(_isArray(min) ? !max : roundingIncrement === true ? !!(roundingIncrement = 0) : !returnFunction, function () { 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; }); }, pipe = function pipe() { for (var _len = arguments.length, functions = new Array(_len), _key = 0; _key < _len; _key++) { functions[_key] = arguments[_key]; } return function (value) { return functions.reduce(function (v, f) { return f(v); }, value); }; }, unitize = function unitize(func, unit) { return function (value) { return func(parseFloat(value)) + (unit || getUnit(value)); }; }, normalize = function normalize(min, max, value) { return mapRange(min, max, 0, 1, value); }, _wrapArray = function _wrapArray(a, wrapper, value) { return _conditionalReturn(value, function (index) { return a[~~wrapper(index)]; }); }, wrap = function wrap(min, max, value) { // NOTE: wrap() CANNOT be an arrow function! A very odd compiling bug causes problems (unrelated to GSAP). var range = max - min; return _isArray(min) ? _wrapArray(min, wrap(0, min.length), max) : _conditionalReturn(value, function (value) { return (range + (value - min) % range) % range + min; }); }, wrapYoyo = function wrapYoyo(min, max, value) { var range = max - min, total = range * 2; return _isArray(min) ? _wrapArray(min, wrapYoyo(0, min.length - 1), max) : _conditionalReturn(value, function (value) { value = (total + (value - min) % total) % total || 0; return min + (value > range ? total - value : value); }); }, _replaceRandom = function _replaceRandom(value) { //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]) var prev = 0, s = "", i, nums, end, isArray; while (~(i = value.indexOf("random(", prev))) { end = value.indexOf(")", i); isArray = value.charAt(i + 7) === "["; nums = value.substr(i + 7, end - i - 7).match(isArray ? _delimitedValueExp : _strictNumExp); s += value.substr(prev, i - prev) + random(isArray ? nums : +nums[0], isArray ? 0 : +nums[1], +nums[2] || 1e-5); prev = end + 1; } return s + value.substr(prev, value.length - prev); }, mapRange = function mapRange(inMin, inMax, outMin, outMax, value) { var inRange = inMax - inMin, outRange = outMax - outMin; return _conditionalReturn(value, function (value) { return outMin + ((value - inMin) / inRange * outRange || 0); }); }, interpolate = function interpolate(start, end, progress, mutate) { var func = isNaN(start + end) ? 0 : function (p) { return (1 - p) * start + p * end; }; if (!func) { var isString = _isString(start), master = {}, p, i, interpolators, l, il; progress === true && (mutate = 1) && (progress = null); if (isString) { start = { p: start }; end = { p: end }; } else if (_isArray(start) && !_isArray(end)) { interpolators = []; l = start.length; il = l - 2; for (i = 1; i < l; i++) { 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. } l--; func = function func(p) { p *= l; var i = Math.min(il, ~~p); return interpolators[i](p - i); }; progress = end; } else if (!mutate) { start = _merge(_isArray(start) ? [] : {}, start); } if (!interpolators) { for (p in end) { _addPropTween.call(master, start, p, "get", end[p]); } func = function func(p) { return _renderPropTweens(p, master) || (isString ? start.p : start); }; } } return _conditionalReturn(progress, func); }, _getLabelInDirection = function _getLabelInDirection(timeline, fromTime, backward) { //used for nextLabel() and previousLabel() var labels = timeline.labels, min = _bigNum, p, distance, label; for (p in labels) { distance = labels[p] - fromTime; if (distance < 0 === !!backward && distance && min > (distance = Math.abs(distance))) { label = p; min = distance; } } return label; }, _callback = function _callback(animation, type, executeLazyFirst) { var v = animation.vars, callback = v[type], prevContext = _context, context = animation._ctx, params, scope, result; if (!callback) { return; } params = v[type + "Params"]; scope = v.callbackScope || animation; 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. context && (_context = context); result = params ? callback.apply(scope, params) : callback.call(scope); _context = prevContext; return result; }, _interrupt = function _interrupt(animation) { _removeFromParent(animation); animation.scrollTrigger && animation.scrollTrigger.kill(!!_reverting); animation.progress() < 1 && _callback(animation, "onInterrupt"); return animation; }, _quickTween, _registerPluginQueue = [], _createPlugin = function _createPlugin(config) { if (_windowExists() && config) { // edge case: some build tools may pass in a null/undefined value config = !config.name && config["default"] || config; //UMD packaging wraps things oddly, so for example MotionPathHelper becomes {MotionPathHelper:MotionPathHelper, default:MotionPathHelper}. var name = config.name, isFunc = _isFunction(config), Plugin = name && !isFunc && config.init ? function () { this._props = []; } : config, //in case someone passes in an object that's not a plugin, like CustomEase instanceDefaults = { init: _emptyFunc, render: _renderPropTweens, add: _addPropTween, kill: _killPropTweensOf, modifier: _addPluginModifier, rawVars: 0 }, statics = { targetTest: 0, get: 0, getSetter: _getSetter, aliases: {}, register: 0 }; _wake(); if (config !== Plugin) { if (_plugins[name]) { return; } _setDefaults(Plugin, _setDefaults(_copyExcluding(config, instanceDefaults), statics)); //static methods _merge(Plugin.prototype, _merge(instanceDefaults, _copyExcluding(config, statics))); //instance methods _plugins[Plugin.prop = name] = Plugin; if (config.targetTest) { _harnessPlugins.push(Plugin); _reservedProps[name] = 1; } name = (name === "css" ? "CSS" : name.charAt(0).toUpperCase() + name.substr(1)) + "Plugin"; //for the global name. "motionPath" should become MotionPathPlugin } _addGlobal(name, Plugin); config.register && config.register(gsap, Plugin, PropTween); } else { config && _registerPluginQueue.push(config); } }, /* * -------------------------------------------------------------------------------------- * COLORS * -------------------------------------------------------------------------------------- */ _255 = 255, _colorLookup = { aqua: [0, _255, _255], lime: [0, _255, 0], silver: [192, 192, 192], black: [0, 0, 0], maroon: [128, 0, 0], teal: [0, 128, 128], blue: [0, 0, _255], navy: [0, 0, 128], white: [_255, _255, _255], olive: [128, 128, 0], yellow: [_255, _255, 0], orange: [_255, 165, 0], gray: [128, 128, 128], purple: [128, 0, 128], green: [0, 128, 0], red: [_255, 0, 0], pink: [_255, 192, 203], cyan: [0, _255, _255], transparent: [_255, _255, _255, 0] }, // possible future idea to replace the hard-coded color name values - put this in the ticker.wake() where we set the _doc: // let ctx = _doc.createElement("canvas").getContext("2d"); // _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)}); _hue = function _hue(h, m1, m2) { h += h < 0 ? 1 : h > 1 ? -1 : 0; 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; }, splitColor = function splitColor(v, toHSL, forceAlpha) { var a = !v ? _colorLookup.black : _isNumber(v) ? [v >> 16, v >> 8 & _255, v & _255] : 0, r, g, b, h, s, l, max, min, d, wasHSL; if (!a) { if (v.substr(-1) === ",") { //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. v = v.substr(0, v.length - 1); } if (_colorLookup[v]) { a = _colorLookup[v]; } else if (v.charAt(0) === "#") { if (v.length < 6) { //for shorthand like #9F0 or #9F0F (could have alpha) r = v.charAt(1); g = v.charAt(2); b = v.charAt(3); v = "#" + r + r + g + g + b + b + (v.length === 5 ? v.charAt(4) + v.charAt(4) : ""); } if (v.length === 9) { // hex with alpha, like #fd5e53ff a = parseInt(v.substr(1, 6), 16); return [a >> 16, a >> 8 & _255, a & _255, parseInt(v.substr(7), 16) / 255]; } v = parseInt(v.substr(1), 16); a = [v >> 16, v >> 8 & _255, v & _255]; } else if (v.substr(0, 3) === "hsl") { a = wasHSL = v.match(_strictNumExp); if (!toHSL) { h = +a[0] % 360 / 360; s = +a[1] / 100; l = +a[2] / 100; g = l <= .5 ? l * (s + 1) : l + s - l * s; r = l * 2 - g; a.length > 3 && (a[3] *= 1); //cast as number a[0] = _hue(h + 1 / 3, r, g); a[1] = _hue(h, r, g); a[2] = _hue(h - 1 / 3, r, g); } else if (~v.indexOf("=")) { //if relative values are found, just return the raw strings with the relative prefixes in place. a = v.match(_numExp); forceAlpha && a.length < 4 && (a[3] = 1); return a; } } else { a = v.match(_strictNumExp) || _colorLookup.transparent; } a = a.map(Number); } if (toHSL && !wasHSL) { r = a[0] / _255; g = a[1] / _255; b = a[2] / _255; max = Math.max(r, g, b); min = Math.min(r, g, b); l = (max + min) / 2; if (max === min) { h = s = 0; } else { d = max - min; s = l > 0.5 ? d / (2 - max - min) : d / (max + min); h = max === r ? (g - b) / d + (g < b ? 6 : 0) : max === g ? (b - r) / d + 2 : (r - g) / d + 4; h *= 60; } a[0] = ~~(h + .5); a[1] = ~~(s * 100 + .5); a[2] = ~~(l * 100 + .5); } forceAlpha && a.length < 4 && (a[3] = 1); return a; }, _colorOrderData = function _colorOrderData(v) { // 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() var values = [], c = [], i = -1; v.split(_colorExp).forEach(function (v) { var a = v.match(_numWithUnitExp) || []; values.push.apply(values, a); c.push(i += a.length + 1); }); values.c = c; return values; }, _formatColors = function _formatColors(s, toHSL, orderMatchData) { var result = "", colors = (s + result).match(_colorExp), type = toHSL ? "hsla(" : "rgba(", i = 0, c, shell, d, l; if (!colors) { return s; } colors = colors.map(function (color) { return (color = splitColor(color, toHSL, 1)) && type + (toHSL ? color[0] + "," + color[1] + "%," + color[2] + "%," + color[3] : color.join(",")) + ")"; }); if (orderMatchData) { d = _colorOrderData(s); c = orderMatchData.c; if (c.join(result) !== d.c.join(result)) { shell = s.replace(_colorExp, "1").split(_numWithUnitExp); l = shell.length - 1; for (; i < l; i++) { result += shell[i] + (~c.indexOf(i) ? colors.shift() || type + "0,0,0,0)" : (d.length ? d : colors.length ? colors : orderMatchData).shift()); } } } if (!shell) { shell = s.split(_colorExp); l = shell.length - 1; for (; i < l; i++) { result += shell[i] + colors[i]; } } return result + shell[l]; }, _colorExp = function () { var s = "(?:\\b(?:(?:rgb|rgba|hsl|hsla)\\(.+?\\))|\\B#(?:[0-9a-f]{3,4}){1,2}\\b", //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., p; for (p in _colorLookup) { s += "|" + p + "\\b"; } return new RegExp(s + ")", "gi"); }(), _hslExp = /hsl[a]?\(/, _colorStringFilter = function _colorStringFilter(a) { var combined = a.join(" "), toHSL; _colorExp.lastIndex = 0; if (_colorExp.test(combined)) { toHSL = _hslExp.test(combined); a[1] = _formatColors(a[1], toHSL); a[0] = _formatColors(a[0], toHSL, _colorOrderData(a[1])); // make sure the order of numbers/colors match with the END value. return true; } }, /* * -------------------------------------------------------------------------------------- * TICKER * -------------------------------------------------------------------------------------- */ _tickerActive, _ticker = function () { var _getTime = Date.now, _lagThreshold = 500, _adjustedLag = 33, _startTime = _getTime(), _lastUpdate = _startTime, _gap = 1000 / 240, _nextTime = _gap, _listeners = [], _id, _req, _raf, _self, _delta, _i, _tick = function _tick(v) { var elapsed = _getTime() - _lastUpdate, manual = v === true, overlap, dispatch, time, frame; elapsed > _lagThreshold && (_startTime += elapsed - _adjustedLag); _lastUpdate += elapsed; time = _lastUpdate - _startTime; overlap = time - _nextTime; if (overlap > 0 || manual) { frame = ++_self.frame; _delta = time - _self.time * 1000; _self.time = time = time / 1000; _nextTime += overlap + (overlap >= _gap ? 4 : _gap - overlap); dispatch = 1; } 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. if (dispatch) { for (_i = 0; _i < _listeners.length; _i++) { // 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. _listeners[_i](time, _delta, frame, v); } } }; _self = { time: 0, frame: 0, tick: function tick() { _tick(true); }, deltaRatio: function deltaRatio(fps) { return _delta / (1000 / (fps || 60)); }, wake: function wake() { if (_coreReady) { if (!_coreInitted && _windowExists()) { _win = _coreInitted = window; _doc = _win.document || {}; _globals.gsap = gsap; (_win.gsapVersions || (_win.gsapVersions = [])).push(gsap.version); _install(_installScope || _win.GreenSockGlobals || !_win.gsap && _win || {}); _raf = _win.requestAnimationFrame; _registerPluginQueue.forEach(_createPlugin); } _id && _self.sleep(); _req = _raf || function (f) { return setTimeout(f, _nextTime - _self.time * 1000 + 1 | 0); }; _tickerActive = 1; _tick(2); } }, sleep: function sleep() { (_raf ? _win.cancelAnimationFrame : clearTimeout)(_id); _tickerActive = 0; _req = _emptyFunc; }, lagSmoothing: function lagSmoothing(threshold, adjustedLag) { _lagThreshold = threshold || Infinity; // zero should be interpreted as basically unlimited _adjustedLag = Math.min(adjustedLag || 33, _lagThreshold); }, fps: function fps(_fps) { _gap = 1000 / (_fps || 240); _nextTime = _self.time * 1000 + _gap; }, add: function add(callback, once, prioritize) { var func = once ? function (t, d, f, v) { callback(t, d, f, v); _self.remove(func); } : callback; _self.remove(callback); _listeners[prioritize ? "unshift" : "push"](func); _wake(); return func; }, remove: function remove(callback, i) { ~(i = _listeners.indexOf(callback)) && _listeners.splice(i, 1) && _i >= i && _i--; }, _listeners: _listeners }; return _self; }(), _wake = function _wake() { return !_tickerActive && _ticker.wake(); }, //also ensures the core classes are initialized. /* * ------------------------------------------------- * EASING * ------------------------------------------------- */ _easeMap = {}, _customEaseExp = /^[\d.\-M][\d.\-,\s]/, _quotesExp = /["']/g, _parseObjectInString = function _parseObjectInString(value) { //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. var obj = {}, split = value.substr(1, value.length - 3).split(":"), key = split[0], i = 1, l = split.length, index, val, parsedVal; for (; i < l; i++) { val = split[i]; index = i !== l - 1 ? val.lastIndexOf(",") : val.length; parsedVal = val.substr(0, index); obj[key] = isNaN(parsedVal) ? parsedVal.replace(_quotesExp, "").trim() : +parsedVal; key = val.substr(index + 1).trim(); } return obj; }, _valueInParentheses = function _valueInParentheses(value) { var open = value.indexOf("(") + 1, close = value.indexOf(")"), nested = value.indexOf("(", open); return value.substring(open, ~nested && nested < close ? value.indexOf(")", close + 1) : close); }, _configEaseFromString = function _configEaseFromString(name) { //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). var split = (name + "").split("("), ease = _easeMap[split[0]]; 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; }, _invertEase = function _invertEase(ease) { return function (p) { return 1 - ease(1 - p); }; }, // allow yoyoEase to be set in children and have those affected when the parent/ancestor timeline yoyos. _propagateYoyoEase = function _propagateYoyoEase(timeline, isYoyo) { var child = timeline._first, ease; while (child) { if (child instanceof Timeline) { _propagateYoyoEase(child, isYoyo); } else if (child.vars.yoyoEase && (!child._yoyo || !child._repeat) && child._yoyo !== isYoyo) { if (child.timeline) { _propagateYoyoEase(child.timeline, isYoyo); } else { ease = child._ease; child._ease = child._yEase; child._yEase = ease; child._yoyo = isYoyo; } } child = child._next; } }, _parseEase = function _parseEase(ease, defaultEase) { return !ease ? defaultEase : (_isFunction(ease) ? ease : _easeMap[ease] || _configEaseFromString(ease)) || defaultEase; }, _insertEase = function _insertEase(names, easeIn, easeOut, easeInOut) { if (easeOut === void 0) { easeOut = function easeOut(p) { return 1 - easeIn(1 - p); }; } if (easeInOut === void 0) { easeInOut = function easeInOut(p) { return p < .5 ? easeIn(p * 2) / 2 : 1 - easeIn((1 - p) * 2) / 2; }; } var ease = { easeIn: easeIn, easeOut: easeOut, easeInOut: easeInOut }, lowercaseName; _forEachName(names, function (name) { _easeMap[name] = _globals[name] = ease; _easeMap[lowercaseName = name.toLowerCase()] = easeOut; for (var p in ease) { _easeMap[lowercaseName + (p === "easeIn" ? ".in" : p === "easeOut" ? ".out" : ".inOut")] = _easeMap[name + "." + p] = ease[p]; } }); return ease; }, _easeInOutFromOut = function _easeInOutFromOut(easeOut) { return function (p) { return p < .5 ? (1 - easeOut(1 - p * 2)) / 2 : .5 + easeOut((p - .5) * 2) / 2; }; }, _configElastic = function _configElastic(type, amplitude, period) { var p1 = amplitude >= 1 ? amplitude : 1, //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. p2 = (period || (type ? .3 : .45)) / (amplitude < 1 ? amplitude : 1), p3 = p2 / _2PI * (Math.asin(1 / p1) || 0), easeOut = function easeOut(p) { return p === 1 ? 1 : p1 * Math.pow(2, -10 * p) * _sin((p - p3) * p2) + 1; }, ease = type === "out" ? easeOut : type === "in" ? function (p) { return 1 - easeOut(1 - p); } : _easeInOutFromOut(easeOut); p2 = _2PI / p2; //precalculate to optimize ease.config = function (amplitude, period) { return _configElastic(type, amplitude, period); }; return ease; }, _configBack = function _configBack(type, overshoot) { if (overshoot === void 0) { overshoot = 1.70158; } var easeOut = function easeOut(p) { return p ? --p * p * ((overshoot + 1) * p + overshoot) + 1 : 0; }, ease = type === "out" ? easeOut : type === "in" ? function (p) { return 1 - easeOut(1 - p); } : _easeInOutFromOut(easeOut); ease.config = function (overshoot) { return _configBack(type, overshoot); }; return ease; }; // 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. // _weightedEase = ratio => { // let y = 0.5 + ratio / 2; // return p => (2 * (1 - p) * p * y + p * p); // }, // 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. // _weightedEaseStrong = ratio => { // ratio = .5 + ratio / 2; // let o = 1 / 3 * (ratio < .5 ? ratio : 1 - ratio), // b = ratio - o, // c = ratio + o; // return p => p === 1 ? p : 3 * b * (1 - p) * (1 - p) * p + 3 * c * (1 - p) * p * p + p * p * p; // }; _forEachName("Linear,Quad,Cubic,Quart,Quint,Strong", function (name, i) { var power = i < 5 ? i + 1 : i; _insertEase(name + ",Power" + (power - 1), i ? function (p) { return Math.pow(p, power); } : function (p) { return p; }, function (p) { return 1 - Math.pow(1 - p, power); }, function (p) { return p < .5 ? Math.pow(p * 2, power) / 2 : 1 - Math.pow((1 - p) * 2, power) / 2; }); }); _easeMap.Linear.easeNone = _easeMap.none = _easeMap.Linear.easeIn; _insertEase("Elastic", _configElastic("in"), _configElastic("out"), _configElastic()); (function (n, c) { var n1 = 1 / c, n2 = 2 * n1, n3 = 2.5 * n1, easeOut = function easeOut(p) { 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; }; _insertEase("Bounce", function (p) { return 1 - easeOut(1 - p); }, easeOut); })(7.5625, 2.75); _insertEase("Expo", function (p) { return p ? Math.pow(2, 10 * (p - 1)) : 0; }); _insertEase("Circ", function (p) { return -(_sqrt(1 - p * p) - 1); }); _insertEase("Sine", function (p) { return p === 1 ? 1 : -_cos(p * _HALF_PI) + 1; }); _insertEase("Back", _configBack("in"), _configBack("out"), _configBack()); _easeMap.SteppedEase = _easeMap.steps = _globals.SteppedEase = { config: function config(steps, immediateStart) { if (steps === void 0) { steps = 1; } var p1 = 1 / steps, p2 = steps + (immediateStart ? 0 : 1), p3 = immediateStart ? 1 : 0, max = 1 - _tinyNum; return function (p) { return ((p2 * _clamp(0, max, p) | 0) + p3) * p1; }; } }; _defaults.ease = _easeMap["quad.out"]; _forEachName("onComplete,onUpdate,onStart,onRepeat,onReverseComplete,onInterrupt", function (name) { return _callbackNames += name + "," + name + "Params,"; }); /* * -------------------------------------------------------------------------------------- * CACHE * -------------------------------------------------------------------------------------- */ var GSCache = function GSCache(target, harness) { this.id = _gsID++; target._gsap = this; this.target = target; this.harness = harness; this.get = harness ? harness.get : _getProperty; this.set = harness ? harness.getSetter : _getSetter; }; /* * -------------------------------------------------------------------------------------- * ANIMATION * -------------------------------------------------------------------------------------- */ var Animation = /*#__PURE__*/function () { function Animation(vars) { this.vars = vars; this._delay = +vars.delay || 0; if (this._repeat = vars.repeat === Infinity ? -2 : vars.repeat || 0) { // 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. this._rDelay = vars.repeatDelay || 0; this._yoyo = !!vars.yoyo || !!vars.yoyoEase; } this._ts = 1; _setDuration(this, +vars.duration, 1, 1); this.data = vars.data; if (_context) { this._ctx = _context; _context.data.push(this); } _tickerActive || _ticker.wake(); } var _proto = Animation.prototype; _proto.delay = function delay(value) { if (value || value === 0) { this.parent && this.parent.smoothChildTiming && this.startTime(this._start + value - this._delay); this._delay = value; return this; } return this._delay; }; _proto.duration = function duration(value) { return arguments.length ? this.totalDuration(this._repeat > 0 ? value + (value + this._rDelay) * this._repeat : value) : this.totalDuration() && this._dur; }; _proto.totalDuration = function totalDuration(value) { if (!arguments.length) { return this._tDur; } this._dirty = 0; return _setDuration(this, this._repeat < 0 ? value : (value - this._repeat * this._rDelay) / (this._repeat + 1)); }; _proto.totalTime = function totalTime(_totalTime, suppressEvents) { _wake(); if (!arguments.length) { return this._tTime; } var parent = this._dp; if (parent && parent.smoothChildTiming && this._ts) { _alignPlayhead(this, _totalTime); !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. //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. while (parent && parent.parent) { if (parent.parent._time !== parent._start + (parent._ts >= 0 ? parent._tTime / parent._ts : (parent.totalDuration() - parent._tTime) / -parent._ts)) { parent.totalTime(parent._tTime, true); } parent = parent.parent; } if (!this.parent && this._dp.autoRemoveChildren && (this._ts > 0 && _totalTime < this._tDur || this._ts < 0 && _totalTime > 0 || !this._tDur && !_totalTime)) { //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. _addToTimeline(this._dp, this, this._start - this._delay); } } if (this._tTime !== _totalTime || !this._dur && !suppressEvents || this._initted && Math.abs(this._zTime) === _tinyNum || !_totalTime && !this._initted && (this.add || this._ptLookup)) { // 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) 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 //if (!this._lock) { // avoid endless recursion (not sure we need this yet or if it's worth the performance hit) // this._lock = 1; _lazySafeRender(this, _totalTime, suppressEvents); // this._lock = 0; //} } return this; }; _proto.time = function time(value, suppressEvents) { 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! }; _proto.totalProgress = function totalProgress(value, suppressEvents) { return arguments.length ? this.totalTime(this.totalDuration() * value, suppressEvents) : this.totalDuration() ? Math.min(1, this._tTime / this._tDur) : this.ratio; }; _proto.progress = function progress(value, suppressEvents) { 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.ratio; }; _proto.iteration = function iteration(value, suppressEvents) { var cycleDuration = this.duration() + this._rDelay; return arguments.length ? this.totalTime(this._time + (value - 1) * cycleDuration, suppressEvents) : this._repeat ? _animationCycle(this._tTime, cycleDuration) + 1 : 1; } // potential future addition: // isPlayingBackwards() { // let animation = this, // orientation = 1; // 1 = forward, -1 = backward // while (animation) { // orientation *= animation.reversed() || (animation.repeat() && !(animation.iteration() & 1)) ? -1 : 1; // animation = animation.parent; // } // return orientation < 0; // } ; _proto.timeScale = function timeScale(value) { if (!arguments.length) { 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. } if (this._rts === value) { return this; } 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. // 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. //(+value < 0 && this._rts >= 0) && _callback(this, "onReverse", true); // 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. this._rts = +value || 0; this._ts = this._ps || value === -_tinyNum ? 0 : this._rts; // _ts is the functional timeScale which would be 0 if the animation is paused. this.totalTime(_clamp(-Math.abs(this._delay), this._tDur, tTime), true); _setEnd(this); // if parent.smoothChildTiming was false, the end time didn't get updated in the _alignPlayhead() method, so do it here. return _recacheAncestors(this); }; _proto.paused = function paused(value) { if (!arguments.length) { return this._ps; } if (this._ps !== value) { this._ps = value; if (value) { 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. 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) } else { _wake(); 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. 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. } } return this; }; _proto.startTime = function startTime(value) { if (arguments.length) { this._start = value; var parent = this.parent || this._dp; parent && (parent._sort || !this.parent) && _addToTimeline(parent, this, value - this._delay); return this; } return this._start; }; _proto.endTime = function endTime(includeRepeats) { return this._start + (_isNotFalse(includeRepeats) ? this.totalDuration() : this.duration()) / Math.abs(this._ts || 1); }; _proto.rawTime = function rawTime(wrapRepeats) { var parent = this.parent || this._dp; // _dp = detached parent 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); }; _proto.revert = function revert(config) { if (config === void 0) { config = _revertConfig; } var prevIsReverting = _reverting; _reverting = config; if (this._initted || this._startAt) { this.timeline && this.timeline.revert(config); this.totalTime(-0.01, config.suppressEvents); } this.data !== "nested" && config.kill !== false && this.kill(); _reverting = prevIsReverting; return this; }; _proto.globalTime = function globalTime(rawTime) { var animation = this, time = arguments.length ? rawTime : animation.rawTime(); while (animation) { time = animation._start + time / (animation._ts || 1); animation = animation._dp; } return !this.parent && this._sat ? this._sat.vars.immediateRender ? -Infinity : 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(). }; _proto.repeat = function repeat(value) { if (arguments.length) { this._repeat = value === Infinity ? -2 : value; return _onUpdateTotalDuration(this); } return this._repeat === -2 ? Infinity : this._repeat; }; _proto.repeatDelay = function repeatDelay(value) { if (arguments.length) { var time = this._time; this._rDelay = value; _onUpdateTotalDuration(this); return time ? this.time(time) : this; } return this._rDelay; }; _proto.yoyo = function yoyo(value) { if (arguments.length) { this._yoyo = value; return this; } return this._yoyo; }; _proto.seek = function seek(position, suppressEvents) { return this.totalTime(_parsePosition(this, position), _isNotFalse(suppressEvents)); }; _proto.restart = function restart(includeDelay, suppressEvents) { return this.play().totalTime(includeDelay ? -this._delay : 0, _isNotFalse(suppressEvents)); }; _proto.play = function play(from, suppressEvents) { from != null && this.seek(from, suppressEvents); return this.reversed(false).paused(false); }; _proto.reverse = function reverse(from, suppressEvents) { from != null && this.seek(from || this.totalDuration(), suppressEvents); return this.reversed(true).paused(false); }; _proto.pause = function pause(atTime, suppressEvents) { atTime != null && this.seek(atTime, suppressEvents); return this.paused(true); }; _proto.resume = function resume() { return this.paused(false); }; _proto.reversed = function reversed(value) { if (arguments.length) { !!value !== this.reversed() && this.timeScale(-this._rts || (value ? -_tinyNum : 0)); // in case timeScale is zero, reversing would have no effect so we use _tinyNum. return this; } return this._rts < 0; }; _proto.invalidate = function invalidate() { this._initted = this._act = 0; this._zTime = -_tinyNum; return this; }; _proto.isActive = function isActive() { var parent = this.parent || this._dp, start = this._start, rawTime; return !!(!parent || this._ts && this._initted && parent.isActive() && (rawTime = parent.rawTime(true)) >= start && rawTime < this.endTime(true) - _tinyNum); }; _proto.eventCallback = function eventCallback(type, callback, params) { var vars = this.vars; if (arguments.length > 1) { if (!callback) { delete vars[type]; } else { vars[type] = callback; params && (vars[type + "Params"] = params); type === "onUpdate" && (this._onUpdate = callback); } return this; } return vars[type]; }; _proto.then = function then(onFulfilled) { var self = this; return new Promise(function (resolve) { var f = _isFunction(onFulfilled) ? onFulfilled : _passThrough, _resolve = function _resolve() { var _then = self.then; self.then = null; // temporarily null the then() method to avoid an infinite loop (see https://github.com/greensock/GSAP/issues/322) _isFunction(f) && (f = f(self)) && (f.then || f === self) && (self.then = _then); resolve(f); self.then = _then; }; if (self._initted && self.totalProgress() === 1 && self._ts >= 0 || !self._tTime && self._ts < 0) { _resolve(); } else { self._prom = _resolve; } }); }; _proto.kill = function kill() { _interrupt(this); }; return Animation; }(); _setDefaults(Animation.prototype, { _time: 0, _start: 0, _end: 0, _tTime: 0, _tDur: 0, _dirty: 0, _repeat: 0, _yoyo: false, parent: null, _initted: false, _rDelay: 0, _ts: 1, _dp: 0, ratio: 0, _zTime: -_tinyNum, _prom: 0, _ps: false, _rts: 1 }); /* * ------------------------------------------------- * TIMELINE * ------------------------------------------------- */ var Timeline = /*#__PURE__*/function (_Animation) { _inheritsLoose(Timeline, _Animation); function Timeline(vars, position) { var _this; if (vars === void 0) { vars = {}; } _this = _Animation.call(this, vars) || this; _this.labels = {}; _this.smoothChildTiming = !!vars.smoothChildTiming; _this.autoRemoveChildren = !!vars.autoRemoveChildren; _this._sort = _isNotFalse(vars.sortChildren); _globalTimeline && _addToTimeline(vars.parent || _globalTimeline, _assertThisInitialized(_this), position); vars.reversed && _this.reverse(); vars.paused && _this.paused(true); vars.scrollTrigger && _scrollTrigger(_assertThisInitialized(_this), vars.scrollTrigger); return _this; } var _proto2 = Timeline.prototype; _proto2.to = function to(targets, vars, position) { _createTweenType(0, arguments, this); return this; }; _proto2.from = function from(targets, vars, position) { _createTweenType(1, arguments, this); return this; }; _proto2.fromTo = function fromTo(targets, fromVars, toVars, position) { _createTweenType(2, arguments, this); return this; }; _proto2.set = function set(targets, vars, position) { vars.duration = 0; vars.parent = this; _inheritDefaults(vars).repeatDelay || (vars.repeat = 0); vars.immediateRender = !!vars.immediateRender; new Tween(targets, vars, _parsePosition(this, position), 1); return this; }; _proto2.call = function call(callback, params, position) { return _addToTimeline(this, Tween.delayedCall(0, callback, params), position); } //ONLY for backward compatibility! Maybe delete? ; _proto2.staggerTo = function staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) { vars.duration = duration; vars.stagger = vars.stagger || stagger; vars.onComplete = onCompleteAll; vars.onCompleteParams = onCompleteAllParams; vars.parent = this; new Tween(targets, vars, _parsePosition(this, position)); return this; }; _proto2.staggerFrom = function staggerFrom(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams) { vars.runBackwards = 1; _inheritDefaults(vars).immediateRender = _isNotFalse(vars.immediateRender); return this.staggerTo(targets, duration, vars, stagger, position, onCompleteAll, onCompleteAllParams); }; _proto2.staggerFromTo = function staggerFromTo(targets, duration, fromVars, toVars, stagger, position, onCompleteAll, onCompleteAllParams) { toVars.startAt = fromVars; _inheritDefaults(toVars).immediateRender = _isNotFalse(toVars.immediateRender); return this.staggerTo(targets, duration, toVars, stagger, position, onCompleteAll, onCompleteAllParams); }; _proto2.render = function render(totalTime, suppressEvents, force) { var prevTime = this._time, tDur = this._dirty ? this.totalDuration() : this._tDur, dur = this._dur, tTime = totalTime <= 0 ? 0 : _roundPrecise(totalTime), // 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. crossingStart = this._zTime < 0 !== totalTime < 0 && (this._initted || !dur), time, child, next, iteration, cycleDuration, prevPaused, pauseTween, timeScale, prevStart, prevIteration, yoyo, isYoyo; this !== _globalTimeline && tTime > tDur && totalTime >= 0 && (tTime = tDur); if (tTime !== this._tTime || force || crossingStart) { if (prevTime !== this._time && dur) { //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). tTime += this._time - prevTime; totalTime += this._time - prevTime; } time = tTime; prevStart = this._start; timeScale = this._ts; prevPaused = !timeScale; if (crossingStart) { 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. (totalTime || !suppressEvents) && (this._zTime = totalTime); } if (this._repeat) { //adjust the time for repeats and yoyos yoyo = this._yoyo; cycleDuration = dur + this._rDelay; if (this._repeat < -1 && totalTime < 0) { return this.totalTime(cycleDuration * 100 + totalTime, suppressEvents, force); } time = _roundPrecise(tTime % cycleDuration); //round to avoid floating point errors. (4 % 0.8 should be 0 but some browsers report it as 0.79999999!) if (tTime === tDur) { // 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) iteration = this._repeat; time = dur; } else { iteration = ~~(tTime / cycleDuration); if (iteration && iteration === tTime / cycleDuration) { time = dur; iteration--; } time > dur && (time = dur); } prevIteration = _animationCycle(this._tTime, cycleDuration); !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://greensock.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 if (yoyo && iteration & 1) { time = dur - time; isYoyo = 1; } /* make sure children at the end/beginning of the timeline are rendered properly. If, for example, a 3-second long timeline rendered at 2.9 seconds previously, and now renders at 3.2 seconds (which would get translated to 2.8 seconds if the timeline yoyos or 0.2 seconds if it just repeats), there could be a callback or a short tween that's at 2.95 or 3 seconds in which wouldn't render. So we need to push the timeline to the end (and/or beginning depending on its yoyo value). Also we must ensure that zero-duration tweens at the very beginning or end of the Timeline work. */ if (iteration !== prevIteration && !this._lock) { var rewinding = yoyo && prevIteration & 1, doesWrap = rewinding === (yoyo && iteration & 1); iteration < prevIteration && (rewinding = !rewinding); 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. this._lock = 1; this.render(prevTime || (isYoyo ? 0 : _roundPrecise(iteration * cycleDuration)), suppressEvents, !dur)._lock = 0; this._tTime = tTime; // if a user gets the iteration() inside the onRepeat, for example, it should be accurate. !suppressEvents && this.parent && _callback(this, "onRepeat"); this.vars.repeatRefresh && !isYoyo && (this.invalidate()._lock = 1); if (prevTime && prevTime !== this._time || prevPaused !== !this._ts || this.vars.onRepeat && !this.parent && !this._act) { // 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. return this; } dur = this._dur; // in case the duration changed in the onRepeat tDur = this._tDur; if (doesWrap) { this._lock = 2; prevTime = rewinding ? dur : -0.0001; this.render(prevTime, true); this.vars.repeatRefresh && !isYoyo && this.invalidate(); } this._lock = 0; if (!this._ts && !prevPaused) { return this; } //in order for yoyoEase to work properly when there's a stagger, we must swap out the ease in each sub-tween. _propagateYoyoEase(this, isYoyo); } } if (this._hasPause && !this._forcing && this._lock < 2) { pauseTween = _findNextPauseTween(this, _roundPrecise(prevTime), _roundPrecise(time)); if (pauseTween) { tTime -= time - (time = pauseTween._start); } } this._tTime = tTime; this._time = time; 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. if (!this._initted) { this._onUpdate = this.vars.onUpdate; this._initted = 1; this._zTime = totalTime; 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}). } if (!prevTime && time && !suppressEvents && !iteration) { _callback(this, "onStart"); if (this._tTime !== tTime) { // 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. return this; } } if (time >= prevTime && totalTime >= 0) { child = this._first; while (child) { next = child._next; if ((child._act || time >= child._start) && child._ts && pauseTween !== child) { if (child.parent !== this) { // 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. return this.render(totalTime, suppressEvents, force); } child.render(child._ts > 0 ? (time - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (time - child._start) * child._ts, suppressEvents, force); if (time !== this._time || !this._ts && !prevPaused) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete pauseTween = 0; next && (tTime += this._zTime = -_tinyNum); // it didn't finish rendering, so flag zTime as negative so that so that the next time render() is called it'll be forced (to render any remaining children) break; } } child = next; } } else { child = this._last; 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. while (child) { next = child._prev; if ((child._act || adjustedTime <= child._end) && child._ts && pauseTween !== child) { if (child.parent !== this) { // 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. return this.render(totalTime, suppressEvents, force); } child.render(child._ts > 0 ? (adjustedTime - child._start) * child._ts : (child._dirty ? child.totalDuration() : child._tDur) + (adjustedTime - child._start) * child._ts, suppressEvents, force || _reverting && (child._initted || child._startAt)); // if reverting, we should always force renders of initted tweens (but remember that .fromTo() or .from() may have a _startAt but not _initted yet). If, for example, a .fromTo() tween with a stagger (which creates an internal timeline) gets reverted BEFORE some of its child tweens render for the first time, it may not properly trigger them to revert. if (time !== this._time || !this._ts && !prevPaused) { //in case a tween pauses or seeks the timeline when rendering, like inside of an onUpdate/onComplete pauseTween = 0; 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) break; } } child = next; } } if (pauseTween && !suppressEvents) { this.pause(); pauseTween.render(time >= prevTime ? 0 : -_tinyNum)._zTime = time >= prevTime ? 1 : -1; if (this._ts) { //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). 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. _setEnd(this); return this.render(totalTime, suppressEvents, force); } } this._onUpdate && !suppressEvents && _callback(this, "onUpdate", true); if (tTime === tDur && this._tTime >= this.totalDuration() || !tTime && prevTime) if (prevStart === this._start || Math.abs(timeScale) !== Math.abs(this._ts)) if (!this._lock) { // remember, a child's callback may alter this timeline's playhead or timeScale which is why we need to add some of these checks. (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. if (!suppressEvents && !(totalTime < 0 && !prevTime) && (tTime || prevTime || !tDur)) { _callback(this, tTime === tDur && totalTime >= 0 ? "onComplete" : "onReverseComplete", true); this._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom(); } } } return this; }; _proto2.add = function add(child, position) { var _this2 = this; _isNumber(position) || (position = _parsePosition(this, position, child)); if (!(child instanceof Animation)) { if (_isArray(child)) { child.forEach(function (obj) { return _this2.add(obj, position); }); return this; } if (_isString(child)) { return this.addLabel(child, position); } if (_isFunction(child)) { child = Tween.delayedCall(0, child); } else { return this; } } return this !== child ? _addToTimeline(this, child, position) : this; //don't allow a timeline to be added to itself as a child! }; _proto2.getChildren = function getChildren(nested, tweens, timelines, ignoreBeforeTime) { if (nested === void 0) { nested = true; } if (tweens === void 0) { tweens = true; } if (timelines === void 0) { timelines = true; } if (ignoreBeforeTime === void 0) { ignoreBeforeTime = -_bigNum; } var a = [], child = this._first; while (child) { if (child._start >= ignoreBeforeTime) { if (child instanceof Tween) { tweens && a.push(child); } else { timelines && a.push(child); nested && a.push.apply(a, child.getChildren(true, tweens, timelines)); } } child = child._next; } return a; }; _proto2.getById = function getById(id) { var animations = this.getChildren(1, 1, 1), i = animations.length; while (i--) { if (animations[i].vars.id === id) { return animations[i]; } } }; _proto2.remove = function remove(child) { if (_isString(child)) { return this.removeLabel(child); } if (_isFunction(child)) { return this.killTweensOf(child); } _removeLinkedListItem(this, child); if (child === this._recent) { this._recent = this._last; } return _uncache(this); }; _proto2.totalTime = function totalTime(_totalTime2, suppressEvents) { if (!arguments.length) { return this._tTime; } this._forcing = 1; if (!this._dp && this._ts) { //special case for the global timeline (or any other that has no parent or detached parent). this._start = _roundPrecise(_ticker.time - (this._ts > 0 ? _totalTime2 / this._ts : (this.totalDuration() - _totalTime2) / -this._ts)); } _Animation.prototype.totalTime.call(this, _totalTime2, suppressEvents); this._forcing = 0; return this; }; _proto2.addLabel = function addLabel(label, position) { this.labels[label] = _parsePosition(this, position); return this; }; _proto2.removeLabel = function removeLabel(label) { delete this.labels[label]; return this; }; _proto2.addPause = function addPause(position, callback, params) { var t = Tween.delayedCall(0, callback || _emptyFunc, params); t.data = "isPause"; this._hasPause = 1; return _addToTimeline(this, t, _parsePosition(this, position)); }; _proto2.removePause = function removePause(position) { var child = this._first; position = _parsePosition(this, position); while (child) { if (child._start === position && child.data === "isPause") { _removeFromParent(child); } child = child._next; } }; _proto2.killTweensOf = function killTweensOf(targets, props, onlyActive) { var tweens = this.getTweensOf(targets, onlyActive), i = tweens.length; while (i--) { _overwritingTween !== tweens[i] && tweens[i].kill(targets, props); } return this; }; _proto2.getTweensOf = function getTweensOf(targets, onlyActive) { var a = [], parsedTargets = toArray(targets), child = this._first, isGlobalTime = _isNumber(onlyActive), // a number is interpreted as a global time. If the animation spans children; while (child) { if (child instanceof Tween) { if (_arrayContainsAny(child._targets, parsedTargets) && (isGlobalTime ? (!_overwritingTween || child._initted && child._ts) && child.globalTime(0) <= onlyActive && child.globalTime(child.totalDuration()) > onlyActive : !onlyActive || child.isActive())) { // note: if this is for overwriting, it should only be for tweens that aren't paused and are initted. a.push(child); } } else if ((children = child.getTweensOf(parsedTargets, onlyActive)).length) { a.push.apply(a, children); } child = child._next; } return a; } // potential future feature - targets() on timelines // targets() { // let result = []; // this.getChildren(true, true, false).forEach(t => result.push(...t.targets())); // return result.filter((v, i) => result.indexOf(v) === i); // } ; _proto2.tweenTo = function tweenTo(position, vars) { vars = vars || {}; var tl = this, endTime = _parsePosition(tl, position), _vars = vars, startAt = _vars.startAt, _onStart = _vars.onStart, onStartParams = _vars.onStartParams, immediateRender = _vars.immediateRender, initted, tween = Tween.to(tl, _setDefaults({ ease: vars.ease || "none", lazy: false, immediateRender: false, time: endTime, overwrite: "auto", duration: vars.duration || Math.abs((endTime - (startAt && "time" in startAt ? startAt.time : tl._time)) / tl.timeScale()) || _tinyNum, onStart: function onStart() { tl.pause(); if (!initted) { var duration = vars.duration || Math.abs((endTime - (startAt && "time" in startAt ? startAt.time : tl._time)) / tl.timeScale()); tween._dur !== duration && _setDuration(tween, duration, 0, 1).render(tween._time, true, true); initted = 1; } _onStart && _onStart.apply(tween, onStartParams || []); //in case the user had an onStart in the vars - we don't want to overwrite it. } }, vars)); return immediateRender ? tween.render(0) : tween; }; _proto2.tweenFromTo = function tweenFromTo(fromPosition, toPosition, vars) { return this.tweenTo(toPosition, _setDefaults({ startAt: { time: _parsePosition(this, fromPosition) } }, vars)); }; _proto2.recent = function recent() { return this._recent; }; _proto2.nextLabel = function nextLabel(afterTime) { if (afterTime === void 0) { afterTime = this._time; } return _getLabelInDirection(this, _parsePosition(this, afterTime)); }; _proto2.previousLabel = function previousLabel(beforeTime) { if (beforeTime === void 0) { beforeTime = this._time; } return _getLabelInDirection(this, _parsePosition(this, beforeTime), 1); }; _proto2.currentLabel = function currentLabel(value) { return arguments.length ? this.seek(value, true) : this.previousLabel(this._time + _tinyNum); }; _proto2.shiftChildren = function shiftChildren(amount, adjustLabels, ignoreBeforeTime) { if (ignoreBeforeTime === void 0) { ignoreBeforeTime = 0; } var child = this._first, labels = this.labels, p; while (child) { if (child._start >= ignoreBeforeTime) { child._start += amount; child._end += amount; } child = child._next; } if (adjustLabels) { for (p in labels) { if (labels[p] >= ignoreBeforeTime) { labels[p] += amount; } } } return _uncache(this); }; _proto2.invalidate = function invalidate(soft) { var child = this._first; this._lock = 0; while (child) { child.invalidate(soft); child = child._next; } return _Animation.prototype.invalidate.call(this, soft); }; _proto2.clear = function clear(includeLabels) { if (includeLabels === void 0) { includeLabels = true; } var child = this._first, next; while (child) { next = child._next; this.remove(child); child = next; } this._dp && (this._time = this._tTime = this._pTime = 0); includeLabels && (this.labels = {}); return _uncache(this); }; _proto2.totalDuration = function totalDuration(value) { var max = 0, self = this, child = self._last, prevStart = _bigNum, prev, start, parent; if (arguments.length) { return self.timeScale((self._repeat < 0 ? self.duration() : self.totalDuration()) / (self.reversed() ? -value : value)); } if (self._dirty) { parent = self.parent; while (child) { prev = child._prev; //record it here in case the tween changes position in the sequence... child._dirty && child.totalDuration(); //could change the tween._startTime, so make sure the animation's cache is clean before analyzing it. start = child._start; if (start > prevStart && self._sort && child._ts && !self._lock) { //in case one of the tweens shifted out of order, it needs to be re-inserted into the correct position in the sequence self._lock = 1; //prevent endless recursive calls - there are methods that get triggered that check duration/totalDuration when we add(). _addToTimeline(self, child, start - child._delay, 1)._lock = 0; } else { prevStart = start; } if (start < 0 && child._ts) { //children aren't allowed to have negative startTimes unless smoothChildTiming is true, so adjust here if one is found. max -= start; if (!parent && !self._dp || parent && parent.smoothChildTiming) { self._start += start / self._ts; self._time -= start; self._tTime -= start; } self.shiftChildren(-start, false, -1e999); prevStart = 0; } child._end > max && child._ts && (max = child._end); child = prev; } _setDuration(self, self === _globalTimeline && self._time > max ? self._time : max, 1, 1); self._dirty = 0; } return self._tDur; }; Timeline.updateRoot = function updateRoot(time) { if (_globalTimeline._ts) { _lazySafeRender(_globalTimeline, _parentToChildTotalTime(time, _globalTimeline)); _lastRenderedFrame = _ticker.frame; } if (_ticker.frame >= _nextGCFrame) { _nextGCFrame += _config.autoSleep || 120; var child = _globalTimeline._first; if (!child || !child._ts) if (_config.autoSleep && _ticker._listeners.length < 2) { while (child && !child._ts) { child = child._next; } child || _ticker.sleep(); } } }; return Timeline; }(Animation); _setDefaults(Timeline.prototype, { _lock: 0, _hasPause: 0, _forcing: 0 }); var _addComplexStringPropTween = function _addComplexStringPropTween(target, prop, start, end, setter, stringFilter, funcParam) { //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. var pt = new PropTween(this._pt, target, prop, 0, 1, _renderComplexString, null, setter), index = 0, matchIndex = 0, result, startNums, color, endNum, chunk, startNum, hasRandom, a; pt.b = start; pt.e = end; start += ""; //ensure values are strings end += ""; if (hasRandom = ~end.indexOf("random(")) { end = _replaceRandom(end); } if (stringFilter) { a = [start, end]; stringFilter(a, target, prop); //pass an array with the starting and ending values and let the filter do whatever it needs to the values. start = a[0]; end = a[1]; } startNums = start.match(_complexStringNumExp) || []; while (result = _complexStringNumExp.exec(end)) { endNum = result[0]; chunk = end.substring(index, result.index); if (color) { color = (color + 1) % 5; } else if (chunk.substr(-5) === "rgba(") { color = 1; } if (endNum !== startNums[matchIndex++]) { 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. pt._pt = { _next: pt._pt, p: chunk || matchIndex === 1 ? chunk : ",", //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. s: startNum, c: endNum.charAt(1) === "=" ? _parseRelative(startNum, endNum) - startNum : parseFloat(endNum) - startNum, m: color && color < 4 ? Math.round : 0 }; index = _complexStringNumExp.lastIndex; } } 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) pt.fp = funcParam; if (_relExp.test(end) || hasRandom) { 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). } 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. return pt; }, _addPropTween = function _addPropTween(target, prop, start, end, index, targets, modifier, stringFilter, funcParam, optional) { _isFunction(end) && (end = end(index || 0, target, targets)); var currentValue = target[prop], 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](), setter = !_isFunction(currentValue) ? _setterPlain : funcParam ? _setterFuncWithParam : _setterFunc, pt; if (_isString(end)) { if (~end.indexOf("random(")) { end = _replaceRandom(end); } if (end.charAt(1) === "=") { pt = _parseRelative(parsedStart, end) + (getUnit(parsedStart) || 0); if (pt || pt === 0) { // to avoid isNaN, like if someone passes in a value like "!= whatever" end = pt; } } } if (!optional || parsedStart !== end || _forceAllPropTweens) { if (!isNaN(parsedStart * end) && end !== "") { // fun fact: any number multiplied by "" is evaluated as the number 0! pt = new PropTween(this._pt, target, prop, +parsedStart || 0, end - (parsedStart || 0), typeof currentValue === "boolean" ? _renderBoolean : _renderPlain, 0, setter); funcParam && (pt.fp = funcParam); modifier && pt.modifier(modifier, this, target); return this._pt = pt; } !currentValue && !(prop in target) && _missingPlugin(prop, end); return _addComplexStringPropTween.call(this, target, prop, parsedStart, end, setter, stringFilter || _config.stringFilter, funcParam); } }, //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. _processVars = function _processVars(vars, index, target, targets, tween) { _isFunction(vars) && (vars = _parseFuncOrString(vars, tween, index, target, targets)); if (!_isObject(vars) || vars.style && vars.nodeType || _isArray(vars) || _isTypedArray(vars)) { return _isString(vars) ? _parseFuncOrString(vars, tween, index, target, targets) : vars; } var copy = {}, p; for (p in vars) { copy[p] = _parseFuncOrString(vars[p], tween, index, target, targets); } return copy; }, _checkPlugin = function _checkPlugin(property, vars, tween, index, target, targets) { var plugin, pt, ptLookup, i; if (_plugins[property] && (plugin = new _plugins[property]()).init(target, plugin.rawVars ? vars[property] : _processVars(vars[property], index, target, targets, tween), tween, index, targets) !== false) { tween._pt = pt = new PropTween(tween._pt, target, property, 0, 1, plugin.render, plugin, 0, plugin.priority); if (tween !== _quickTween) { 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. i = plugin._props.length; while (i--) { ptLookup[plugin._props[i]] = pt; } } } return plugin; }, _overwritingTween, //store a reference temporarily so we can avoid overwriting itself. _forceAllPropTweens, _initTween = function _initTween(tween, time, tTime) { var vars = tween.vars, ease = vars.ease, startAt = vars.startAt, immediateRender = vars.immediateRender, lazy = vars.lazy, onUpdate = vars.onUpdate, onUpdateParams = vars.onUpdateParams, callbackScope = vars.callbackScope, runBackwards = vars.runBackwards, yoyoEase = vars.yoyoEase, keyframes = vars.keyframes, autoRevert = vars.autoRevert, dur = tween._dur, prevStartAt = tween._startAt, targets = tween._targets, parent = tween.parent, fullTargets = parent && parent.data === "nested" ? parent.vars.targets : targets, autoOverwrite = tween._overwrite === "auto" && !_suppressOverwrites, tl = tween.timeline, cleanVars, i, p, pt, target, hasPriority, gsData, harness, plugin, ptLookup, index, harnessVars, overwritten; tl && (!keyframes || !ease) && (ease = "none"); tween._ease = _parseEase(ease, _defaults.ease); tween._yEase = yoyoEase ? _invertEase(_parseEase(yoyoEase === true ? ease : yoyoEase, _defaults.ease)) : 0; if (yoyoEase && tween._yoyo && !tween._repeat) { //there must have been a parent timeline with yoyo:true that is currently in its yoyo phase, so flip the eases. yoyoEase = tween._yEase; tween._yEase = tween._ease; tween._ease = yoyoEase; } tween._from = !tl && !!vars.runBackwards; //nested timelines should never run backwards - the backwards-ness is in the child tweens. if (!tl || keyframes && !vars.stagger) { //if there's an internal timeline, skip all the parsing because we passed that task down the chain. harness = targets[0] ? _getCache(targets[0]).harness : 0; 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. cleanVars = _copyExcluding(vars, _reservedProps); if (prevStartAt) { prevStartAt._zTime < 0 && prevStartAt.progress(1); // in case it's a lazy startAt that hasn't rendered yet. 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) // 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. prevStartAt._lazy = 0; } if (startAt) { _removeFromParent(tween._startAt = Tween.set(targets, _setDefaults({ data: "isStart", overwrite: false, parent: parent, immediateRender: true, lazy: !prevStartAt && _isNotFalse(lazy), startAt: null, delay: 0, onUpdate: onUpdate, onUpdateParams: onUpdateParams, callbackScope: callbackScope, stagger: 0 }, 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); tween._startAt._dp = 0; // don't allow it to get put back into root timeline! Like when revert() is called and totalTime() gets set. tween._startAt._sat = tween; // used in globalTime(). _sat stands for _startAtTween 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. if (immediateRender) { if (dur && time <= 0 && tTime <= 0) { // 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. time && (tween._zTime = time); 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. } } } else if (runBackwards && dur) { //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) if (!prevStartAt) { 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 p = _setDefaults({ overwrite: false, data: "isFromStart", //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. lazy: immediateRender && !prevStartAt && _isNotFalse(lazy), immediateRender: immediateRender, //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) stagger: 0, 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}) }, cleanVars); harnessVars && (p[harness.prop] = harnessVars); // in case someone does something like .from(..., {css:{}}) _removeFromParent(tween._startAt = Tween.set(targets, p)); tween._startAt._dp = 0; // don't allow it to get put back into root timeline! tween._startAt._sat = tween; // used in globalTime() time < 0 && (_reverting ? tween._startAt.revert(_revertConfigNoKill) : tween._startAt.render(-1, true)); tween._zTime = time; if (!immediateRender) { _initTween(tween._startAt, _tinyNum, _tinyNum); //ensures that the initial values are recorded } else if (!time) { return; } } } tween._pt = tween._ptCache = 0; lazy = dur && _isNotFalse(lazy) || lazy && !dur; for (i = 0; i < targets.length; i++) { target = targets[i]; gsData = target._gsap || _harness(targets)[i]._gsap; tween._ptLookup[i] = ptLookup = {}; _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) index = fullTargets === targets ? i : fullTargets.indexOf(target); if (harness && (plugin = new harness()).init(target, harnessVars || cleanVars, tween, index, fullTargets) !== false) { tween._pt = pt = new PropTween(tween._pt, target, plugin.name, 0, 1, plugin.render, plugin, 0, plugin.priority); plugin._props.forEach(function (name) { ptLookup[name] = pt; }); plugin.priority && (hasPriority = 1); } if (!harness || harnessVars) { for (p in cleanVars) { if (_plugins[p] && (plugin = _checkPlugin(p, cleanVars, tween, index, target, fullTargets))) { plugin.priority && (hasPriority = 1); } else { ptLookup[p] = pt = _addPropTween.call(tween, target, p, "get", cleanVars[p], index, fullTargets, 0, vars.stringFilter); } } } tween._op && tween._op[i] && tween.kill(target, tween._op[i]); if (autoOverwrite && tween._pt) { _overwritingTween = tween; _globalTimeline.killTweensOf(target, ptLookup, tween.globalTime(time)); // make sure the overwriting doesn't overwrite THIS tween!!! overwritten = !tween.parent; _overwritingTween = 0; } tween._pt && lazy && (_lazyLookup[gsData.id] = 1); } hasPriority && _sortPropTweensByPriority(tween); 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. } tween._onUpdate = onUpdate; 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. 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. }, _updatePropTweens = function _updatePropTweens(tween, property, value, start, startIsRelative, ratio, time) { var ptCache = (tween._pt && tween._ptCache || (tween._ptCache = {}))[property], pt, rootPT, lookup, i; if (!ptCache) { ptCache = tween._ptCache[property] = []; lookup = tween._ptLookup; i = tween._targets.length; while (i--) { pt = lookup[i][property]; if (pt && pt.d && pt.d._pt) { // it's a plugin, so find the nested PropTween pt = pt.d._pt; while (pt && pt.p !== property && pt.fp !== property) { // "fp" is functionParam for things like setting CSS variables which require .setProperty("--var-name", value) pt = pt._next; } } if (!pt) { // there is no PropTween associated with that property, so we must FORCE one to be created and ditch out of this // 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. _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. tween.vars[property] = "+=0"; _initTween(tween, time); _forceAllPropTweens = 0; return 1; } ptCache.push(pt); } } i = ptCache.length; while (i--) { rootPT = ptCache[i]; pt = rootPT._pt || rootPT; // complex values may have nested PropTweens. We only accommodate the FIRST value. pt.s = (start || start === 0) && !startIsRelative ? start : pt.s + (start || 0) + ratio * pt.c; pt.c = value - pt.s; rootPT.e && (rootPT.e = _round(value) + getUnit(rootPT.e)); // mainly for CSSPlugin (end value) rootPT.b && (rootPT.b = pt.s + getUnit(rootPT.b)); // (beginning value) } }, _addAliasesToVars = function _addAliasesToVars(targets, vars) { var harness = targets[0] ? _getCache(targets[0]).harness : 0, propertyAliases = harness && harness.aliases, copy, p, i, aliases; if (!propertyAliases) { return vars; } copy = _merge({}, vars); for (p in propertyAliases) { if (p in copy) { aliases = propertyAliases[p].split(","); i = aliases.length; while (i--) { copy[aliases[i]] = copy[p]; } } } return copy; }, // 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. _parseKeyframe = function _parseKeyframe(prop, obj, allProps, easeEach) { var ease = obj.ease || easeEach || "power1.inOut", p, a; if (_isArray(obj)) { a = allProps[prop] || (allProps[prop] = []); // t = time (out of 100), v = value, e = ease obj.forEach(function (value, i) { return a.push({ t: i / (obj.length - 1) * 100, v: value, e: ease }); }); } else { for (p in obj) { a = allProps[p] || (allProps[p] = []); p === "ease" || a.push({ t: parseFloat(prop), v: obj[p], e: ease }); } } }, _parseFuncOrString = function _parseFuncOrString(value, tween, i, target, targets) { return _isFunction(value) ? value.call(tween, i, target, targets) : _isString(value) && ~value.indexOf("random(") ? _replaceRandom(value) : value; }, _staggerTweenProps = _callbackNames + "repeat,repeatDelay,yoyo,repeatRefresh,yoyoEase,autoRevert", _staggerPropsToSkip = {}; _forEachName(_staggerTweenProps + ",id,stagger,delay,duration,paused,scrollTrigger", function (name) { return _staggerPropsToSkip[name] = 1; }); /* * -------------------------------------------------------------------------------------- * TWEEN * -------------------------------------------------------------------------------------- */ var Tween = /*#__PURE__*/function (_Animation2) { _inheritsLoose(Tween, _Animation2); function Tween(targets, vars, position, skipInherit) { var _this3; if (typeof vars === "number") { position.duration = vars; vars = position; position = null; } _this3 = _Animation2.call(this, skipInherit ? vars : _inheritDefaults(vars)) || this; var _this3$vars = _this3.vars, duration = _this3$vars.duration, delay = _this3$vars.delay, immediateRender = _this3$vars.immediateRender, stagger = _this3$vars.stagger, overwrite = _this3$vars.overwrite, keyframes = _this3$vars.keyframes, defaults = _this3$vars.defaults, scrollTrigger = _this3$vars.scrollTrigger, yoyoEase = _this3$vars.yoyoEase, parent = vars.parent || _globalTimeline, parsedTargets = (_isArray(targets) || _isTypedArray(targets) ? _isNumber(targets[0]) : "length" in vars) ? [targets] : toArray(targets), tl, i, copy, l, p, curTarget, staggerFunc, staggerVarsToMerge; _this3._targets = parsedTargets.length ? _harness(parsedTargets) : _warn("GSAP target " + targets + " not found. https://greensock.com", !_config.nullTargetWarn) || []; _this3._ptLookup = []; //PropTween lookup. An array containing an object for each target, having keys for each tweening property _this3._overwrite = overwrite; if (keyframes || stagger || _isFuncOrString(duration) || _isFuncOrString(delay)) { vars = _this3.vars; tl = _this3.timeline = new Timeline({ data: "nested", defaults: defaults || {}, targets: parent && parent.data === "nested" ? parent.vars.targets : parsedTargets }); // 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. tl.kill(); tl.parent = tl._dp = _assertThisInitialized(_this3); tl._start = 0; if (stagger || _isFuncOrString(duration) || _isFuncOrString(delay)) { l = parsedTargets.length; staggerFunc = stagger && distribute(stagger); if (_isObject(stagger)) { //users can pass in callbacks like onStart/onComplete in the stagger object. These should fire with each individual tween. for (p in stagger) { if (~_staggerTweenProps.indexOf(p)) { staggerVarsToMerge || (staggerVarsToMerge = {}); staggerVarsToMerge[p] = stagger[p]; } } } for (i = 0; i < l; i++) { copy = _copyExcluding(vars, _staggerPropsToSkip); copy.stagger = 0; yoyoEase && (copy.yoyoEase = yoyoEase); staggerVarsToMerge && _merge(copy, staggerVarsToMerge); 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. copy.duration = +_parseFuncOrString(duration, _assertThisInitialized(_this3), i, curTarget, parsedTargets); copy.delay = (+_parseFuncOrString(delay, _assertThisInitialized(_this3), i, curTarget, parsedTargets) || 0) - _this3._delay; if (!stagger && l === 1 && copy.delay) { // if someone does delay:"random(1, 5)", repeat:-1, for example, the delay shouldn't be inside the repeat. _this3._delay = delay = copy.delay; _this3._start += delay; copy.delay = 0; } tl.to(curTarget, copy, staggerFunc ? staggerFunc(i, curTarget, parsedTargets) : 0); tl._ease = _easeMap.none; } tl.duration() ? duration = delay = 0 : _this3.timeline = 0; // if the timeline's duration is 0, we don't need a timeline internally! } else if (keyframes) { _inheritDefaults(_setDefaults(tl.vars.defaults, { ease: "none" })); tl._ease = _parseEase(keyframes.ease || vars.ease || "none"); var time = 0, a, kf, v; if (_isArray(keyframes)) { keyframes.forEach(function (frame) { return tl.to(parsedTargets, frame, ">"); }); tl.duration(); // to ensure tl._dur is cached because we tap into it for performance purposes in the render() method. } else { copy = {}; for (p in keyframes) { p === "ease" || p === "easeEach" || _parseKeyframe(p, keyframes[p], copy, keyframes.easeEach); } for (p in copy) { a = copy[p].sort(function (a, b) { return a.t - b.t; }); time = 0; for (i = 0; i < a.length; i++) { kf = a[i]; v = { ease: kf.e, duration: (kf.t - (i ? a[i - 1].t : 0)) / 100 * duration }; v[p] = kf.v; tl.to(parsedTargets, v, time); time += v.duration; } } tl.duration() < duration && tl.to({}, { duration: duration - tl.duration() }); // in case keyframes didn't go to 100% } } duration || _this3.duration(duration = tl.duration()); } else { _this3.timeline = 0; //speed optimization, faster lookups (no going up the prototype chain) } if (overwrite === true && !_suppressOverwrites) { _overwritingTween = _assertThisInitialized(_this3); _globalTimeline.killTweensOf(parsedTargets); _overwritingTween = 0; } _addToTimeline(parent, _assertThisInitialized(_this3), position); vars.reversed && _this3.reverse(); vars.paused && _this3.paused(true); if (immediateRender || !duration && !keyframes && _this3._start === _roundPrecise(parent._time) && _isNotFalse(immediateRender) && _hasNoPausedAncestors(_assertThisInitialized(_this3)) && parent.data !== "nested") { _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) _this3.render(Math.max(0, -delay) || 0); //in case delay is negative } scrollTrigger && _scrollTrigger(_assertThisInitialized(_this3), scrollTrigger); return _this3; } var _proto3 = Tween.prototype; _proto3.render = function render(totalTime, suppressEvents, force) { var prevTime = this._time, tDur = this._tDur, dur = this._dur, isNegative = totalTime < 0, tTime = totalTime > tDur - _tinyNum && !isNegative ? tDur : totalTime < _tinyNum ? 0 : totalTime, time, pt, iteration, cycleDuration, prevIteration, isYoyo, ratio, timeline, yoyoEase; if (!dur) { _renderZeroDurationTween(this, totalTime, suppressEvents, force); } else if (tTime !== this._tTime || !totalTime || force || !this._initted && this._tTime || this._startAt && this._zTime < 0 !== isNegative) { //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) time = tTime; timeline = this.timeline; if (this._repeat) { //adjust the time for repeats and yoyos cycleDuration = dur + this._rDelay; if (this._repeat < -1 && isNegative) { return this.totalTime(cycleDuration * 100 + totalTime, suppressEvents, force); } time = _roundPrecise(tTime % cycleDuration); //round to avoid floating point errors. (4 % 0.8 should be 0 but some browsers report it as 0.79999999!) if (tTime === tDur) { // 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) iteration = this._repeat; time = dur; } else { iteration = ~~(tTime / cycleDuration); if (iteration && iteration === tTime / cycleDuration) { time = dur; iteration--; } time > dur && (time = dur); } isYoyo = this._yoyo && iteration & 1; if (isYoyo) { yoyoEase = this._yEase; time = dur - time; } prevIteration = _animationCycle(this._tTime, cycleDuration); if (time === prevTime && !force && this._initted) { //could be during the repeatDelay part. No need to render and fire callbacks. this._tTime = tTime; return this; } if (iteration !== prevIteration) { timeline && this._yEase && _propagateYoyoEase(timeline, isYoyo); //repeatRefresh functionality if (this.vars.repeatRefresh && !isYoyo && !this._lock) { 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. this.render(_roundPrecise(cycleDuration * iteration), true).invalidate()._lock = 0; } } } if (!this._initted) { if (_attemptInitTween(this, isNegative ? totalTime : time, force, suppressEvents, tTime)) { 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. return this; } if (prevTime !== this._time) { // 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. return this; } if (dur !== this._dur) { // while initting, a plugin like InertiaPlugin might alter the duration, so rerun from the start to ensure everything renders as it should. return this.render(totalTime, suppressEvents, force); } } this._tTime = tTime; this._time = time; if (!this._act && this._ts) { 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. this._lazy = 0; } this.ratio = ratio = (yoyoEase || this._ease)(time / dur); if (this._from) { this.ratio = ratio = 1 - ratio; } if (time && !prevTime && !suppressEvents && !iteration) { _callback(this, "onStart"); if (this._tTime !== tTime) { // 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. return this; } } pt = this._pt; while (pt) { pt.r(ratio, pt.d); pt = pt._next; } timeline && timeline.render(totalTime < 0 ? totalTime : !time && isYoyo ? -_tinyNum : timeline._dur * timeline._ease(time / this._dur), suppressEvents, force) || this._startAt && (this._zTime = totalTime); if (this._onUpdate && !suppressEvents) { 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. _callback(this, "onUpdate"); } this._repeat && iteration !== prevIteration && this.vars.onRepeat && !suppressEvents && this.parent && _callback(this, "onRepeat"); if ((tTime === this._tDur || !tTime) && this._tTime === tTime) { isNegative && !this._onUpdate && _rewindStartAt(this, totalTime, true, true); (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. if (!suppressEvents && !(isNegative && !prevTime) && (tTime || prevTime || isYoyo)) { // if prevTime and tTime are zero, we shouldn't fire the onReverseComplete. This could happen if you gsap.to(... {paused:true}).play(); _callback(this, tTime === tDur ? "onComplete" : "onReverseComplete", true); this._prom && !(tTime < tDur && this.timeScale() > 0) && this._prom(); } } } return this; }; _proto3.targets = function targets() { return this._targets; }; _proto3.invalidate = function invalidate(soft) { // "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. (!soft || !this.vars.runBackwards) && (this._startAt = 0); this._pt = this._op = this._onUpdate = this._lazy = this.ratio = 0; this._ptLookup = []; this.timeline && this.timeline.invalidate(soft); return _Animation2.prototype.invalidate.call(this, soft); }; _proto3.resetTo = function resetTo(property, value, start, startIsRelative) { _tickerActive || _ticker.wake(); this._ts || this.play(); var time = Math.min(this._dur, (this._dp._time - this._start) * this._ts), ratio; this._initted || _initTween(this, time); ratio = this._ease(time / this._dur); // don't just get tween.ratio because it may not have rendered yet. // 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. // if (_isObject(property)) { // performance optimization // for (p in property) { // if (_updatePropTweens(this, p, property[p], value ? value[p] : null, start, ratio, time)) { // 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. // } // } // } else { if (_updatePropTweens(this, property, value, start, startIsRelative, ratio, time)) { 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. } //} _alignPlayhead(this, 0); this.parent || _addLinkedListItem(this._dp, this, "_first", "_last", this._dp._sort ? "_start" : 0); return this.render(0); }; _proto3.kill = function kill(targets, vars) { if (vars === void 0) { vars = "all"; } if (!targets && (!vars || vars === "all")) { this._lazy = this._pt = 0; return this.parent ? _interrupt(this) : this; } if (this.timeline) { var tDur = this.timeline.totalDuration(); this.timeline.killTweensOf(targets, vars, _overwritingTween && _overwritingTween.vars.overwrite !== true)._first || _interrupt(this); // if nothing is left tweening, interrupt. 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. return this; } var parsedTargets = this._targets, killingTargets = targets ? toArray(targets) : parsedTargets, propTweenLookup = this._ptLookup, firstPT = this._pt, overwrittenProps, curLookup, curOverwriteProps, props, p, pt, i; if ((!vars || vars === "all") && _arraysMatch(parsedTargets, killingTargets)) { vars === "all" && (this._pt = 0); return _interrupt(this); } overwrittenProps = this._op = this._op || []; if (vars !== "all") { //so people can pass in a comma-delimited list of property names if (_isString(vars)) { p = {}; _forEachName(vars, function (name) { return p[name] = 1; }); vars = p; } vars = _addAliasesToVars(parsedTargets, vars); } i = parsedTargets.length; while (i--) { if (~killingTargets.indexOf(parsedTargets[i])) { curLookup = propTweenLookup[i]; if (vars === "all") { overwrittenProps[i] = vars; props = curLookup; curOverwriteProps = {}; } else { curOverwriteProps = overwrittenProps[i] = overwrittenProps[i] || {}; props = vars; } for (p in props) { pt = curLookup && curLookup[p]; if (pt) { if (!("kill" in pt.d) || pt.d.kill(p) === true) { _removeLinkedListItem(this, pt, "_pt"); } delete curLookup[p]; } if (curOverwriteProps !== "all") { curOverwriteProps[p] = 1; } } } } 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. return this; }; Tween.to = function to(targets, vars) { return new Tween(targets, vars, arguments[2]); }; Tween.from = function from(targets, vars) { return _createTweenType(1, arguments); }; Tween.delayedCall = function delayedCall(delay, callback, params, scope) { return new Tween(callback, 0, { immediateRender: false, lazy: false, overwrite: false, delay: delay, onComplete: callback, onReverseComplete: callback, onCompleteParams: params, onReverseCompleteParams: params, callbackScope: scope }); // we must use onReverseComplete too for things like timeline.add(() => {...}) which should be triggered in BOTH directions (forward and reverse) }; Tween.fromTo = function fromTo(targets, fromVars, toVars) { return _createTweenType(2, arguments); }; Tween.set = function set(targets, vars) { vars.duration = 0; vars.repeatDelay || (vars.repeat = 0); return new Tween(targets, vars); }; Tween.killTweensOf = function killTweensOf(targets, props, onlyActive) { return _globalTimeline.killTweensOf(targets, props, onlyActive); }; return Tween; }(Animation); _setDefaults(Tween.prototype, { _targets: [], _lazy: 0, _startAt: 0, _op: 0, _onInit: 0 }); //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) // _forEachName("to,from,fromTo,set,call,add,addLabel,addPause", name => { // Tween.prototype[name] = function() { // let tl = new Timeline(); // return _addToTimeline(tl, this)[name].apply(tl, toArray(arguments)); // } // }); //for backward compatibility. Leverage the timeline calls. _forEachName("staggerTo,staggerFrom,staggerFromTo", function (name) { Tween[name] = function () { var tl = new Timeline(), params = _slice.call(arguments, 0); params.splice(name === "staggerFromTo" ? 5 : 4, 0, 0); return tl[name].apply(tl, params); }; }); /* * -------------------------------------------------------------------------------------- * PROPTWEEN * -------------------------------------------------------------------------------------- */ var _setterPlain = function _setterPlain(target, property, value) { return target[property] = value; }, _setterFunc = function _setterFunc(target, property, value) { return target[property](value); }, _setterFuncWithParam = function _setterFuncWithParam(target, property, value, data) { return target[property](data.fp, value); }, _setterAttribute = function _setterAttribute(target, property, value) { return target.setAttribute(property, value); }, _getSetter = function _getSetter(target, property) { return _isFunction(target[property]) ? _setterFunc : _isUndefined(target[property]) && target.setAttribute ? _setterAttribute : _setterPlain; }, _renderPlain = function _renderPlain(ratio, data) { return data.set(data.t, data.p, Math.round((data.s + data.c * ratio) * 1000000) / 1000000, data); }, _renderBoolean = function _renderBoolean(ratio, data) { return data.set(data.t, data.p, !!(data.s + data.c * ratio), data); }, _renderComplexString = function _renderComplexString(ratio, data) { var pt = data._pt, s = ""; if (!ratio && data.b) { //b = beginning string s = data.b; } else if (ratio === 1 && data.e) { //e = ending string s = data.e; } else { while (pt) { 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. pt = pt._next; } s += data.c; //we use the "c" of the PropTween to store the final chunk of non-numeric text. } data.set(data.t, data.p, s, data); }, _renderPropTweens = function _renderPropTweens(ratio, data) { var pt = data._pt; while (pt) { pt.r(ratio, pt.d); pt = pt._next; } }, _addPluginModifier = function _addPluginModifier(modifier, tween, target, property) { var pt = this._pt, next; while (pt) { next = pt._next; pt.p === property && pt.modifier(modifier, tween, target); pt = next; } }, _killPropTweensOf = function _killPropTweensOf(property) { var pt = this._pt, hasNonDependentRemaining, next; while (pt) { next = pt._next; if (pt.p === property && !pt.op || pt.op === property) { _removeLinkedListItem(this, pt, "_pt"); } else if (!pt.dep) { hasNonDependentRemaining = 1; } pt = next; } return !hasNonDependentRemaining; }, _setterWithModifier = function _setterWithModifier(target, property, value, data) { data.mSet(target, property, data.m.call(data.tween, value, data.mt), data); }, _sortPropTweensByPriority = function _sortPropTweensByPriority(parent) { var pt = parent._pt, next, pt2, first, 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) while (pt) { next = pt._next; pt2 = first; while (pt2 && pt2.pr > pt.pr) { pt2 = pt2._next; } if (pt._prev = pt2 ? pt2._prev : last) { pt._prev._next = pt; } else { first = pt; } if (pt._next = pt2) { pt2._prev = pt; } else { last = pt; } pt = next; } parent._pt = first; }; //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) var PropTween = /*#__PURE__*/function () { function PropTween(next, target, prop, start, change, renderer, data, setter, priority) { this.t = target; this.s = start; this.c = change; this.p = prop; this.r = renderer || _renderPlain; this.d = data || this; this.set = setter || _setterPlain; this.pr = priority || 0; this._next = next; if (next) { next._prev = this; } } var _proto4 = PropTween.prototype; _proto4.modifier = function modifier(func, tween, target) { this.mSet = this.mSet || this.set; //in case it was already set (a PropTween can only have one modifier) this.set = _setterWithModifier; this.m = func; this.mt = target; //modifier target this.tween = tween; }; return PropTween; }(); //Initialization tasks _forEachName(_callbackNames + "parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger", function (name) { return _reservedProps[name] = 1; }); _globals.TweenMax = _globals.TweenLite = Tween; _globals.TimelineLite = _globals.TimelineMax = Timeline; _globalTimeline = new Timeline({ sortChildren: false, defaults: _defaults, autoRemoveChildren: true, id: "root", smoothChildTiming: true }); _config.stringFilter = _colorStringFilter; var _media = [], _listeners = {}, _emptyArray = [], _lastMediaTime = 0, _contextID = 0, _dispatch = function _dispatch(type) { return (_listeners[type] || _emptyArray).map(function (f) { return f(); }); }, _onMediaChange = function _onMediaChange() { var time = Date.now(), matches = []; if (time - _lastMediaTime > 2) { _dispatch("matchMediaInit"); _media.forEach(function (c) { var queries = c.queries, conditions = c.conditions, match, p, anyMatch, toggled; for (p in queries) { 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. match && (anyMatch = 1); if (match !== conditions[p]) { conditions[p] = match; toggled = 1; } } if (toggled) { c.revert(); anyMatch && matches.push(c); } }); _dispatch("matchMediaRevert"); matches.forEach(function (c) { return c.onMatch(c); }); _lastMediaTime = time; _dispatch("matchMedia"); } }; var Context = /*#__PURE__*/function () { function Context(func, scope) { this.selector = scope && selector(scope); this.data = []; this._r = []; // returned/cleanup functions this.isReverted = false; 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 func && this.add(func); } var _proto5 = Context.prototype; _proto5.add = function add(name, func, scope) { // 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. // if (name && _isFunction(name.revert)) { // this.data.push(name); // return (name._ctx = this); // } if (_isFunction(name)) { scope = func; func = name; name = _isFunction; } var self = this, f = function f() { var prev = _context, prevSelector = self.selector, result; prev && prev !== self && prev.data.push(self); scope && (self.selector = selector(scope)); _context = self; result = func.apply(self, arguments); _isFunction(result) && self._r.push(result); _context = prev; self.selector = prevSelector; self.isReverted = false; return result; }; self.last = f; return name === _isFunction ? f(self) : name ? self[name] = f : f; }; _proto5.ignore = function ignore(func) { var prev = _context; _context = null; func(this); _context = prev; }; _proto5.getTweens = function getTweens() { var a = []; this.data.forEach(function (e) { return e instanceof Context ? a.push.apply(a, e.getTweens()) : e instanceof Tween && !(e.parent && e.parent.data === "nested") && a.push(e); }); return a; }; _proto5.clear = function clear() { this._r.length = this.data.length = 0; }; _proto5.kill = function kill(revert, matchMedia) { var _this4 = this; if (revert) { var tweens = this.getTweens(); this.data.forEach(function (t) { // 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. if (t.data === "isFlip") { t.revert(); t.getChildren(true, true, false).forEach(function (tween) { return tweens.splice(tweens.indexOf(tween), 1); }); } }); // save as an object so that we can cache the globalTime for each tween to optimize performance during the sort tweens.map(function (t) { return { g: t.globalTime(0), t: t }; }).sort(function (a, b) { return b.g - a.g || -Infinity; }).forEach(function (o) { return o.t.revert(revert); }); // 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. this.data.forEach(function (e) { return !(e instanceof Tween) && e.revert && e.revert(revert); }); this._r.forEach(function (f) { return f(revert, _this4); }); this.isReverted = true; } else { this.data.forEach(function (e) { return e.kill && e.kill(); }); } this.clear(); if (matchMedia) { var i = _media.length; while (i--) { // 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. _media[i].id === this.id && _media.splice(i, 1); } } }; _proto5.revert = function revert(config) { this.kill(config || {}); }; return Context; }(); var MatchMedia = /*#__PURE__*/function () { function MatchMedia(scope) { this.contexts = []; this.scope = scope; } var _proto6 = MatchMedia.prototype; _proto6.add = function add(conditions, func, scope) { _isObject(conditions) || (conditions = { matches: conditions }); var context = new Context(0, scope || this.scope), cond = context.conditions = {}, mq, p, active; _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() this.contexts.push(context); func = context.add("onMatch", func); context.queries = conditions; for (p in conditions) { if (p === "all") { active = 1; } else { mq = _win.matchMedia(conditions[p]); if (mq) { _media.indexOf(context) < 0 && _media.push(context); (cond[p] = mq.matches) && (active = 1); mq.addListener ? mq.addListener(_onMediaChange) : mq.addEventListener("change", _onMediaChange); } } } active && func(context); return this; } // refresh() { // let time = _lastMediaTime, // media = _media; // _lastMediaTime = -1; // _media = this.contexts; // _onMediaChange(); // _lastMediaTime = time; // _media = media; // } ; _proto6.revert = function revert(config) { this.kill(config || {}); }; _proto6.kill = function kill(revert) { this.contexts.forEach(function (c) { return c.kill(revert, true); }); }; return MatchMedia; }(); /* * -------------------------------------------------------------------------------------- * GSAP * -------------------------------------------------------------------------------------- */ var _gsap = { registerPlugin: function registerPlugin() { for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } args.forEach(function (config) { return _createPlugin(config); }); }, timeline: function timeline(vars) { return new Timeline(vars); }, getTweensOf: function getTweensOf(targets, onlyActive) { return _globalTimeline.getTweensOf(targets, onlyActive); }, getProperty: function getProperty(target, property, unit, uncache) { _isString(target) && (target = toArray(target)[0]); //in case selector text or an array is passed in var getter = _getCache(target || {}).get, format = unit ? _passThrough : _numericIfPossible; unit === "native" && (unit = ""); return !target ? target : !property ? function (property, unit, uncache) { return format((_plugins[property] && _plugins[property].get || getter)(target, property, unit, uncache)); } : format((_plugins[property] && _plugins[property].get || getter)(target, property, unit, uncache)); }, quickSetter: function quickSetter(target, property, unit) { target = toArray(target); if (target.length > 1) { var setters = target.map(function (t) { return gsap.quickSetter(t, property, unit); }), l = setters.length; return function (value) { var i = l; while (i--) { setters[i](value); } }; } target = target[0] || {}; var Plugin = _plugins[property], cache = _getCache(target), p = cache.harness && (cache.harness.aliases || {})[property] || property, // in case it's an alias, like "rotate" for "rotation". setter = Plugin ? function (value) { var p = new Plugin(); _quickTween._pt = 0; p.init(target, unit ? value + unit : value, _quickTween, 0, [target]); p.render(1, p); _quickTween._pt && _renderPropTweens(1, _quickTween); } : cache.set(target, p); return Plugin ? setter : function (value) { return setter(target, p, unit ? value + unit : value, cache, 1); }; }, quickTo: function quickTo(target, property, vars) { var _merge2; var tween = gsap.to(target, _merge((_merge2 = {}, _merge2[property] = "+=0.1", _merge2.paused = true, _merge2), vars || {})), func = function func(value, start, startIsRelative) { return tween.resetTo(property, value, start, startIsRelative); }; func.tween = tween; return func; }, isTweening: function isTweening(targets) { return _globalTimeline.getTweensOf(targets, true).length > 0; }, defaults: function defaults(value) { value && value.ease && (value.ease = _parseEase(value.ease, _defaults.ease)); return _mergeDeep(_defaults, value || {}); }, config: function config(value) { return _mergeDeep(_config, value || {}); }, registerEffect: function registerEffect(_ref3) { var name = _ref3.name, effect = _ref3.effect, plugins = _ref3.plugins, defaults = _ref3.defaults, extendTimeline = _ref3.extendTimeline; (plugins || "").split(",").forEach(function (pluginName) { return pluginName && !_plugins[pluginName] && !_globals[pluginName] && _warn(name + " effect requires " + pluginName + " plugin."); }); _effects[name] = function (targets, vars, tl) { return effect(toArray(targets), _setDefaults(vars || {}, defaults), tl); }; if (extendTimeline) { Timeline.prototype[name] = function (targets, vars, position) { return this.add(_effects[name](targets, _isObject(vars) ? vars : (position = vars) && {}, this), position); }; } }, registerEase: function registerEase(name, ease) { _easeMap[name] = _parseEase(ease); }, parseEase: function parseEase(ease, defaultEase) { return arguments.length ? _parseEase(ease, defaultEase) : _easeMap; }, getById: function getById(id) { return _globalTimeline.getById(id); }, exportRoot: function exportRoot(vars, includeDelayedCalls) { if (vars === void 0) { vars = {}; } var tl = new Timeline(vars), child, next; tl.smoothChildTiming = _isNotFalse(vars.smoothChildTiming); _globalTimeline.remove(tl); 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). tl._time = tl._tTime = _globalTimeline._time; child = _globalTimeline._first; while (child) { next = child._next; if (includeDelayedCalls || !(!child._dur && child instanceof Tween && child.vars.onComplete === child._targets[0])) { _addToTimeline(tl, child, child._start - child._delay); } child = next; } _addToTimeline(_globalTimeline, tl, 0); return tl; }, context: function context(func, scope) { return func ? new Context(func, scope) : _context; }, matchMedia: function matchMedia(scope) { return new MatchMedia(scope); }, matchMediaRefresh: function matchMediaRefresh() { return _media.forEach(function (c) { var cond = c.conditions, found, p; for (p in cond) { if (cond[p]) { cond[p] = false; found = 1; } } found && c.revert(); }) || _onMediaChange(); }, addEventListener: function addEventListener(type, callback) { var a = _listeners[type] || (_listeners[type] = []); ~a.indexOf(callback) || a.push(callback); }, removeEventListener: function removeEventListener(type, callback) { var a = _listeners[type], i = a && a.indexOf(callback); i >= 0 && a.splice(i, 1); }, utils: { wrap: wrap, wrapYoyo: wrapYoyo, distribute: distribute, random: random, snap: snap, normalize: normalize, getUnit: getUnit, clamp: clamp, splitColor: splitColor, toArray: toArray, selector: selector, mapRange: mapRange, pipe: pipe, unitize: unitize, interpolate: interpolate, shuffle: shuffle }, install: _install, effects: _effects, ticker: _ticker, updateRoot: Timeline.updateRoot, plugins: _plugins, globalTimeline: _globalTimeline, core: { PropTween: PropTween, globals: _addGlobal, Tween: Tween, Timeline: Timeline, Animation: Animation, getCache: _getCache, _removeLinkedListItem: _removeLinkedListItem, reverting: function reverting() { return _reverting; }, context: function context(toAdd) { if (toAdd && _context) { _context.data.push(toAdd); toAdd._ctx = _context; } return _context; }, suppressOverwrites: function suppressOverwrites(value) { return _suppressOverwrites = value; } } }; _forEachName("to,from,fromTo,delayedCall,set,killTweensOf", function (name) { return _gsap[name] = Tween[name]; }); _ticker.add(Timeline.updateRoot); _quickTween = _gsap.to({}, { duration: 0 }); // ---- EXTRA PLUGINS -------------------------------------------------------- var _getPluginPropTween = function _getPluginPropTween(plugin, prop) { var pt = plugin._pt; while (pt && pt.p !== prop && pt.op !== prop && pt.fp !== prop) { pt = pt._next; } return pt; }, _addModifiers = function _addModifiers(tween, modifiers) { var targets = tween._targets, p, i, pt; for (p in modifiers) { i = targets.length; while (i--) { pt = tween._ptLookup[i][p]; if (pt && (pt = pt.d)) { if (pt._pt) { // is a plugin pt = _getPluginPropTween(pt, p); } pt && pt.modifier && pt.modifier(modifiers[p], tween, targets[i], p); } } } }, _buildModifierPlugin = function _buildModifierPlugin(name, modifier) { return { name: name, rawVars: 1, //don't pre-process function-based values or "random()" strings. init: function init(target, vars, tween) { tween._onInit = function (tween) { var temp, p; if (_isString(vars)) { temp = {}; _forEachName(vars, function (name) { return temp[name] = 1; }); //if the user passes in a comma-delimited list of property names to roundProps, like "x,y", we round to whole numbers. vars = temp; } if (modifier) { temp = {}; for (p in vars) { temp[p] = modifier(vars[p]); } vars = temp; } _addModifiers(tween, vars); }; } }; }; //register core plugins var gsap = _gsap.registerPlugin({ name: "attr", init: function init(target, vars, tween, index, targets) { var p, pt, v; this.tween = tween; for (p in vars) { v = target.getAttribute(p) || ""; pt = this.add(target, "setAttribute", (v || 0) + "", vars[p], index, targets, 0, 0, p); pt.op = p; pt.b = v; // record the beginning value so we can revert() this._props.push(p); } }, render: function render(ratio, data) { var pt = data._pt; while (pt) { _reverting ? pt.set(pt.t, pt.p, pt.b, pt) : pt.r(ratio, pt.d); // if reverting, go back to the original (pt.b) pt = pt._next; } } }, { name: "endArray", init: function init(target, value) { var i = value.length; while (i--) { this.add(target, i, target[i] || 0, value[i], 0, 0, 0, 0, 0, 1); } } }, _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. Tween.version = Timeline.version = gsap.version = "3.12.2"; _coreReady = 1; _windowExists() && _wake(); var Power0 = _easeMap.Power0, Power1 = _easeMap.Power1, Power2 = _easeMap.Power2, Power3 = _easeMap.Power3, Power4 = _easeMap.Power4, Linear = _easeMap.Linear, Quad = _easeMap.Quad, Cubic = _easeMap.Cubic, Quart = _easeMap.Quart, Quint = _easeMap.Quint, Strong = _easeMap.Strong, Elastic = _easeMap.Elastic, Back = _easeMap.Back, SteppedEase = _easeMap.SteppedEase, Bounce = _easeMap.Bounce, Sine = _easeMap.Sine, Expo = _easeMap.Expo, Circ = _easeMap.Circ; //export some internal methods/orojects for use in CSSPlugin so that we can externalize that file and allow custom builds that exclude it. /***/ }), /***/ "../../node_modules/gsap/index.js": /*!****************************************!*\ !*** ../../node_modules/gsap/index.js ***! \****************************************/ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ Back: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Back; }, /* harmony export */ Bounce: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Bounce; }, /* harmony export */ CSSPlugin: function() { return /* reexport safe */ _CSSPlugin_js__WEBPACK_IMPORTED_MODULE_1__.CSSPlugin; }, /* harmony export */ Circ: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Circ; }, /* harmony export */ Cubic: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Cubic; }, /* harmony export */ Elastic: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Elastic; }, /* harmony export */ Expo: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Expo; }, /* harmony export */ Linear: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Linear; }, /* harmony export */ Power0: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Power0; }, /* harmony export */ Power1: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Power1; }, /* harmony export */ Power2: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Power2; }, /* harmony export */ Power3: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Power3; }, /* harmony export */ Power4: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Power4; }, /* harmony export */ Quad: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Quad; }, /* harmony export */ Quart: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Quart; }, /* harmony export */ Quint: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Quint; }, /* harmony export */ Sine: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Sine; }, /* harmony export */ SteppedEase: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.SteppedEase; }, /* harmony export */ Strong: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.Strong; }, /* harmony export */ TimelineLite: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.TimelineLite; }, /* harmony export */ TimelineMax: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.TimelineMax; }, /* harmony export */ TweenLite: function() { return /* reexport safe */ _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.TweenLite; }, /* harmony export */ TweenMax: function() { return /* binding */ TweenMaxWithCSS; }, /* harmony export */ "default": function() { return /* binding */ gsapWithCSS; }, /* harmony export */ gsap: function() { return /* binding */ gsapWithCSS; } /* harmony export */ }); /* harmony import */ var _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./gsap-core.js */ "../../node_modules/gsap/gsap-core.js"); /* harmony import */ var _CSSPlugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CSSPlugin.js */ "../../node_modules/gsap/CSSPlugin.js"); var gsapWithCSS = _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.gsap.registerPlugin(_CSSPlugin_js__WEBPACK_IMPORTED_MODULE_1__.CSSPlugin) || _gsap_core_js__WEBPACK_IMPORTED_MODULE_0__.gsap, // to protect from tree shaking TweenMaxWithCSS = gsapWithCSS.core.Tween; /***/ }), /***/ "../../node_modules/leaflet-search/dist/leaflet-search.src.js": /*!********************************************************************!*\ !*** ../../node_modules/leaflet-search/dist/leaflet-search.src.js ***! \********************************************************************/ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* * Leaflet Control Search v3.0.5 - 2022-11-24 * * Copyright 2022 Stefano Cudini * stefano.cudini@gmail.com * https://opengeo.tech/ * * Licensed under the MIT license. * * Demo: * https://opengeo.tech/maps/leaflet-search/ * * Source: * git@github.com:stefanocudini/leaflet-search.git * */ /* Name Data passed Description Managed Events: search:locationfound {latlng, title, layer} fired after moved and show markerLocation search:expanded {} fired after control was expanded search:collapsed {} fired after control was collapsed search:cancel {} fired after cancel button clicked Public methods: setLayer() L.LayerGroup() set layer search at runtime showAlert() 'Text message' show alert message searchText() 'Text searched' search text by external code */ //TODO implement can do research on multiple sources layers and remote //TODO history: false, //show latest searches in tooltip //FIXME option condition problem {autoCollapse: true, markerLocation: true} not show location //FIXME option condition problem {autoCollapse: false } // //TODO here insert function search inputText FIRST in _recordsCache keys and if not find results.. // run one of callbacks search(sourceData,jsonpUrl or options.layer) and run this.showTooltip // //TODO change structure of _recordsCache // like this: _recordsCache = {"text-key1": {loc:[lat,lng], ..other attributes.. }, {"text-key2": {loc:[lat,lng]}...}, ...} // in this mode every record can have a free structure of attributes, only 'loc' is required //TODO important optimization!!! always append data in this._recordsCache // now _recordsCache content is emptied and replaced with new data founded // always appending data on _recordsCache give the possibility of caching ajax, jsonp and layersearch! // //TODO here insert function search inputText FIRST in _recordsCache keys and if not find results.. // run one of callbacks search(sourceData,jsonpUrl or options.layer) and run this.showTooltip // //TODO change structure of _recordsCache // like this: _recordsCache = {"text-key1": {loc:[lat,lng], ..other attributes.. }, {"text-key2": {loc:[lat,lng]}...}, ...} // in this way every record can have a free structure of attributes, only 'loc' is required (function (factory) { if(true) { //AMD !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! leaflet */ "../../node_modules/leaflet/dist/leaflet-src.js")], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else {} })(function (L) { L.Control.Search = L.Control.extend({ includes: L.version[0]==='1' ? L.Evented.prototype : L.Mixin.Events, options: { url: '', //url for search by ajax request, ex: "search.php?q={s}". Can be function to returns string for dynamic parameter setting layer: null, //layer where search markers(is a L.LayerGroup) sourceData: null, //function to fill _recordsCache, passed searching text by first param and callback in second //TODO implements uniq option 'sourceData' to recognizes source type: url,array,callback or layer jsonpParam: null, //jsonp param name for search by jsonp service, ex: "callback" propertyLoc: 'loc', //field for remapping location, using array: ['latname','lonname'] for select double fields(ex. ['lat','lon'] ) support dotted format: 'prop.subprop.title' propertyName: 'title', //property in marker.options(or feature.properties for vector layer) trough filter elements in layer, formatData: null, //callback for reformat all data from source to indexed data object filterData: null, //callback for filtering data from text searched, params: textSearch, allRecords moveToLocation: null, //callback run on location found, params: latlng, title, map buildTip: null, //function to return row tip html node(or html string), receive text tooltip in first param container: '', //container id to insert Search Control zoom: null, //default zoom level for move to location minLength: 1, //minimal text length for autocomplete initial: true, //search elements only by initial text casesensitive: false, //search elements in case sensitive text autoType: true, //complete input with first suggested result and select this filled-in text. delayType: 400, //delay while typing for show tooltip tooltipLimit: -1, //limit max results to show in tooltip. -1 for no limit, 0 for no results tipAutoSubmit: true, //auto map panTo when click on tooltip firstTipSubmit: false, //auto select first result con enter click autoResize: true, //autoresize on input change collapsed: true, //collapse search control at startup autoCollapse: false, //collapse search control after submit(on button or on tips if enabled tipAutoSubmit) autoCollapseTime: 1200, //delay for autoclosing alert and collapse after blur textErr: 'Location not found', //error message textCancel: 'Cancel', //title in cancel button textPlaceholder: 'Search...', //placeholder value hideMarkerOnCollapse: false, //remove circle and marker on search control collapsed position: 'topleft', marker: { //custom L.Marker or false for hide icon: false, //custom L.Icon for maker location or false for hide animate: true, //animate a circle over location found circle: { //draw a circle in location found radius: 10, weight: 3, color: '#e03', stroke: true, fill: false } } }, _getPath: function(obj, prop) { var parts = prop.split('.'), last = parts.pop(), len = parts.length, cur = parts[0], i = 1; if(len > 0) while((obj = obj[cur]) && i < len) cur = parts[i++]; if(obj) return obj[last]; }, _isObject: function(obj) { return Object.prototype.toString.call(obj) === "[object Object]"; }, initialize: function(options) { L.Util.setOptions(this, options || {}); this._inputMinSize = this.options.textPlaceholder ? this.options.textPlaceholder.length : 10; this._layer = this.options.layer || new L.LayerGroup(); this._filterData = this.options.filterData || this._defaultFilterData; this._formatData = this.options.formatData || this._defaultFormatData; this._moveToLocation = this.options.moveToLocation || this._defaultMoveToLocation; this._autoTypeTmp = this.options.autoType; //useful for disable autoType temporarily in delete/backspace keydown this._countertips = 0; //number of tips items this._recordsCache = {}; //key,value table! to store locations! format: key,latlng this._curReq = null; }, onAdd: function (map) { this._map = map; this._container = L.DomUtil.create('div', 'leaflet-control-search'); this._input = this._createInput(this.options.textPlaceholder, 'search-input'); this._tooltip = this._createTooltip('search-tooltip'); this._cancel = this._createCancel(this.options.textCancel, 'search-cancel'); this._button = this._createButton(this.options.textPlaceholder, 'search-button'); this._alert = this._createAlert('search-alert'); if(this.options.collapsed===false) this.expand(this.options.collapsed); if(this.options.marker) { if(this.options.marker instanceof L.Marker || this.options.marker instanceof L.CircleMarker) this._markerSearch = this.options.marker; else if(this._isObject(this.options.marker)) this._markerSearch = new L.Control.Search.Marker([0,0], this.options.marker); this._markerSearch._isMarkerSearch = true; } this.setLayer( this._layer ); map.on({ // 'layeradd': this._onLayerAddRemove, // 'layerremove': this._onLayerAddRemove 'resize': this._handleAutoresize }, this); return this._container; }, addTo: function (map) { if(this.options.container) { this._container = this.onAdd(map); this._wrapper = L.DomUtil.get(this.options.container); this._wrapper.style.position = 'relative'; this._wrapper.appendChild(this._container); } else L.Control.prototype.addTo.call(this, map); return this; }, onRemove: function(map) { this._recordsCache = {}; // map.off({ // 'layeradd': this._onLayerAddRemove, // 'layerremove': this._onLayerAddRemove // }, this); map.off({ // 'layeradd': this._onLayerAddRemove, // 'layerremove': this._onLayerAddRemove 'resize': this._handleAutoresize }, this); }, // _onLayerAddRemove: function(e) { // //without this, run setLayer also for each Markers!! to optimize! // if(e.layer instanceof L.LayerGroup) // if( L.stamp(e.layer) != L.stamp(this._layer) ) // this.setLayer(e.layer); // }, setLayer: function(layer) { //set search layer at runtime //this.options.layer = layer; //setting this, run only this._recordsFromLayer() this._layer = layer; this._layer.addTo(this._map); return this; }, showAlert: function(text) { var self = this; text = text || this.options.textErr; this._alert.style.display = 'block'; this._alert.innerHTML = text; clearTimeout(this.timerAlert); this.timerAlert = setTimeout(function() { self.hideAlert(); },this.options.autoCollapseTime); return this; }, hideAlert: function() { this._alert.style.display = 'none'; return this; }, cancel: function() { this._input.value = ''; this._handleKeypress({ keyCode: 8 });//simulate backspace keypress this._input.size = this._inputMinSize; this._input.focus(); this._cancel.style.display = 'none'; this._hideTooltip(); this.fire('search:cancel'); return this; }, expand: function(toggle) { toggle = typeof toggle === 'boolean' ? toggle : true; this._input.style.display = 'block'; L.DomUtil.addClass(this._container, 'search-exp'); if ( toggle !== false ) { this._input.focus(); this._map.on('dragstart click', this.collapse, this); } this.fire('search:expanded'); return this; }, collapse: function() { this._hideTooltip(); this.cancel(); this._alert.style.display = 'none'; this._input.blur(); if(this.options.collapsed) { this._input.style.display = 'none'; this._cancel.style.display = 'none'; L.DomUtil.removeClass(this._container, 'search-exp'); if (this.options.hideMarkerOnCollapse) { this._map.removeLayer(this._markerSearch); } this._map.off('dragstart click', this.collapse, this); } this.fire('search:collapsed'); return this; }, collapseDelayed: function() { //collapse after delay, used on_input blur var self = this; if (!this.options.autoCollapse) return this; clearTimeout(this.timerCollapse); this.timerCollapse = setTimeout(function() { self.collapse(); }, this.options.autoCollapseTime); return this; }, collapseDelayedStop: function() { clearTimeout(this.timerCollapse); return this; }, ////start DOM creations _createAlert: function(className) { var alert = L.DomUtil.create('div', className, this._container); alert.style.display = 'none'; L.DomEvent .on(alert, 'click', L.DomEvent.stop, this) .on(alert, 'click', this.hideAlert, this); return alert; }, _createInput: function (text, className) { var self = this; var label = L.DomUtil.create('label', className, this._container); var input = L.DomUtil.create('input', className, this._container); input.type = 'text'; input.size = this._inputMinSize; input.value = ''; input.autocomplete = 'off'; input.autocorrect = 'off'; input.autocapitalize = 'off'; input.placeholder = text; input.style.display = 'none'; input.role = 'search'; input.id = input.role + input.type + input.size; label.htmlFor = input.id; label.style.display = 'none'; label.value = text; L.DomEvent .disableClickPropagation(input) .on(input, 'keyup', this._handleKeypress, this) .on(input, 'paste', function(e) { setTimeout(function(e) { self._handleKeypress(e); },10,e); }, this) .on(input, 'blur', this.collapseDelayed, this) .on(input, 'focus', this.collapseDelayedStop, this); return input; }, _createCancel: function (title, className) { var cancel = L.DomUtil.create('a', className, this._container); cancel.href = '#'; cancel.title = title; cancel.style.display = 'none'; cancel.innerHTML = "";//imageless(see css) L.DomEvent .on(cancel, 'click', L.DomEvent.stop, this) .on(cancel, 'click', this.cancel, this); return cancel; }, _createButton: function (title, className) { var button = L.DomUtil.create('a', className, this._container); button.href = '#'; button.title = title; L.DomEvent .on(button, 'click', L.DomEvent.stop, this) .on(button, 'click', this._handleSubmit, this) .on(button, 'focus', this.collapseDelayedStop, this) .on(button, 'blur', this.collapseDelayed, this); return button; }, _createTooltip: function(className) { var self = this; var tool = L.DomUtil.create('ul', className, this._container); tool.style.display = 'none'; L.DomEvent .disableClickPropagation(tool) .on(tool, 'blur', this.collapseDelayed, this) .on(tool, 'wheel', function(e) { self.collapseDelayedStop(); L.DomEvent.stopPropagation(e);//disable zoom map }, this) .on(tool, 'mouseover', function(e) { self.collapseDelayedStop(); }, this); return tool; }, _createTip: function(text, val) {//val is object in recordCache, usually is Latlng var tip; if(this.options.buildTip) { tip = this.options.buildTip.call(this, text, val); //custom tip node or html string if(typeof tip === 'string') { var tmpNode = L.DomUtil.create('div'); tmpNode.innerHTML = tip; tip = tmpNode.firstChild; } } else { tip = L.DomUtil.create('li', ''); tip.innerHTML = text; } L.DomUtil.addClass(tip, 'search-tip'); tip._text = text; //value replaced in this._input and used by _autoType if(this.options.tipAutoSubmit) L.DomEvent .disableClickPropagation(tip) .on(tip, 'click', L.DomEvent.stop, this) .on(tip, 'click', function(e) { this._input.value = text; this._handleAutoresize(); this._input.focus(); this._hideTooltip(); this._handleSubmit(); }, this); return tip; }, //////end DOM creations _getUrl: function(text) { return (typeof this.options.url === 'function') ? this.options.url(text) : this.options.url; }, _defaultFilterData: function(text, records) { var init, icase, regSearch, frecords = {}; text = text.replace(/[.*+?^${}()|[\]\\]/g, ''); //sanitize remove all special characters if(text==='') { return []; } init = this.options.initial ? '^' : ''; icase = !this.options.casesensitive ? 'i' : undefined; regSearch = new RegExp(init + text, icase); for (let key in records) { if( regSearch.test(key) ) { frecords[key]= records[key]; } } return frecords; }, showTooltip: function(records) { this._countertips = 0; this._tooltip.innerHTML = ''; this._tooltip.currentSelection = -1; //inizialized for _handleArrowSelect() if(this.options.tooltipLimit) { for (let key in records) //fill tooltip { if(this._countertips === this.options.tooltipLimit) { break; } this._countertips++; this._tooltip.appendChild( this._createTip(key, records[key]) ); } } if(this._countertips > 0) { this._tooltip.style.display = 'block'; if(this._autoTypeTmp) { this._autoType(); } this._autoTypeTmp = this.options.autoType;//reset default value } else { this._hideTooltip(); } this._tooltip.scrollTop = 0; return this._countertips; }, _hideTooltip: function() { this._tooltip.style.display = 'none'; this._tooltip.innerHTML = ''; return 0; }, _defaultFormatData: function(json) { //default callback for format data to indexed data var self = this, propName = this.options.propertyName, propLoc = this.options.propertyLoc, jsonret = {}; if( L.Util.isArray(propLoc) ) { for (let i in json) { jsonret[ self._getPath(json[i],propName) ]= L.latLng( self._getPath(json[i], propLoc[0]), self._getPath(json[i], propLoc[1]) ); } } else { for (let i in json) { jsonret[ self._getPath(json[i],propName) ]= L.latLng( self._getPath(json[i],propLoc) ); } } //TODO throw new Error("propertyName '"+propName+"' not found in JSON data"); return jsonret; }, _recordsFromJsonp: function(text, callAfter) { //extract searched records from remote jsonp service L.Control.Search.callJsonp = callAfter; var script = L.DomUtil.create('script','leaflet-search-jsonp', document.getElementsByTagName('body')[0] ), url = L.Util.template(this._getUrl(text)+'&'+this.options.jsonpParam+'=L.Control.Search.callJsonp', {s: text}); //parsing url //rnd = '&_='+Math.floor(Math.random()*10000); //TODO add rnd param or randomize callback name! in recordsFromJsonp script.type = 'text/javascript'; script.src = url; return { abort: function() { script.parentNode.removeChild(script); } }; }, _recordsFromAjax: function(text, callAfter) { //Ajax request if (window.XMLHttpRequest === undefined) { window.XMLHttpRequest = function() { try { return new ActiveXObject("Microsoft.XMLHTTP.6.0"); } catch (e1) { try { return new ActiveXObject("Microsoft.XMLHTTP.3.0"); } catch (e2) { throw new Error("XMLHttpRequest is not supported"); } } }; } var IE8or9 = ( L.Browser.ie && !window.atob && document.querySelector ), request = IE8or9 ? new XDomainRequest() : new XMLHttpRequest(), url = L.Util.template(this._getUrl(text), {s: text}); //rnd = '&_='+Math.floor(Math.random()*10000); //TODO add rnd param or randomize callback name! in recordsFromAjax request.open("GET", url); request.onload = function() { callAfter( JSON.parse(request.responseText) ); }; request.onreadystatechange = function() { if(request.readyState === 4 && request.status === 200) { this.onload(); } }; request.send(); return request; }, _searchInLayer: function(layer, retRecords, propName) { var self = this, loc; if(layer instanceof L.Control.Search.Marker) return; if(layer instanceof L.Marker || layer instanceof L.CircleMarker) { if(self._getPath(layer.options,propName)) { loc = layer.getLatLng(); loc.layer = layer; retRecords[ self._getPath(layer.options,propName) ] = loc; } else if(self._getPath(layer.feature.properties,propName)) { loc = layer.getLatLng(); loc.layer = layer; retRecords[ self._getPath(layer.feature.properties,propName) ] = loc; } else { //throw new Error("propertyName '"+propName+"' not found in marker"); } } else if(layer instanceof L.Path || layer instanceof L.Polyline || layer instanceof L.Polygon) { if(self._getPath(layer.options,propName)) { loc = layer.getBounds().getCenter(); loc.layer = layer; retRecords[ self._getPath(layer.options,propName) ] = loc; } else if(self._getPath(layer.feature.properties,propName)) { loc = layer.getBounds().getCenter(); loc.layer = layer; retRecords[ self._getPath(layer.feature.properties,propName) ] = loc; } else { //throw new Error("propertyName '"+propName+"' not found in shape"); } } else if(layer.hasOwnProperty('feature'))//GeoJSON { if(layer.feature.properties.hasOwnProperty(propName)) { if(layer.getLatLng && typeof layer.getLatLng === 'function') { loc = layer.getLatLng(); loc.layer = layer; retRecords[ layer.feature.properties[propName] ] = loc; } else if(layer.getBounds && typeof layer.getBounds === 'function') { loc = layer.getBounds().getCenter(); loc.layer = layer; retRecords[ layer.feature.properties[propName] ] = loc; } else { } } else { //throw new Error("propertyName '"+propName+"' not found in feature"); } } else if(layer instanceof L.LayerGroup) { layer.eachLayer(function (layer) { self._searchInLayer(layer, retRecords, propName); }); } }, _recordsFromLayer: function() { //return table: key,value from layer var self = this, retRecords = {}, propName = this.options.propertyName; this._layer.eachLayer(function (layer) { self._searchInLayer(layer, retRecords, propName); }); return retRecords; }, _autoType: function() { //TODO implements autype without selection(useful for mobile device) var start = this._input.value.length, firstRecord = this._tooltip.firstChild ? this._tooltip.firstChild._text : '', end = firstRecord.length; if (firstRecord.indexOf(this._input.value) === 0) { // If prefix match this._input.value = firstRecord; this._handleAutoresize(); if (this._input.createTextRange) { var selRange = this._input.createTextRange(); selRange.collapse(true); selRange.moveStart('character', start); selRange.moveEnd('character', end); selRange.select(); } else if(this._input.setSelectionRange) { this._input.setSelectionRange(start, end); } else if(this._input.selectionStart) { this._input.selectionStart = start; this._input.selectionEnd = end; } } }, _hideAutoType: function() { // deselect text: var sel; if ((sel = this._input.selection) && sel.empty) { sel.empty(); } else if (this._input.createTextRange) { sel = this._input.createTextRange(); sel.collapse(true); var end = this._input.value.length; sel.moveStart('character', end); sel.moveEnd('character', end); sel.select(); } else { if (this._input.getSelection) { this._input.getSelection().removeAllRanges(); } this._input.selectionStart = this._input.selectionEnd; } }, _handleKeypress: function (e) { //run _input keyup event var self = this; switch(e.keyCode) { case 27://Esc this.collapse(); break; case 13://Enter if(this._countertips == 1 || (this.options.firstTipSubmit && this._countertips > 0)) { if(this._tooltip.currentSelection == -1) { this._handleArrowSelect(1); } } this._handleSubmit(); //do search break; case 38://Up this._handleArrowSelect(-1); break; case 40://Down this._handleArrowSelect(1); break; case 8://Backspace case 45://Insert case 46://Delete this._autoTypeTmp = false;//disable temporarily autoType break; case 37://Left case 39://Right case 16://Shift case 17://Ctrl case 35://End case 36://Home break; default://All keys if(this._input.value.length) this._cancel.style.display = 'block'; else this._cancel.style.display = 'none'; if(this._input.value.length >= this.options.minLength) { clearTimeout(this.timerKeypress); //cancel last search request while type in this.timerKeypress = setTimeout(function() { //delay before request, for limit jsonp/ajax request self._fillRecordsCache(); }, this.options.delayType); } else this._hideTooltip(); } this._handleAutoresize(); }, searchText: function(text) { var code = text.charCodeAt(text.length); this._input.value = text; this._input.style.display = 'block'; L.DomUtil.addClass(this._container, 'search-exp'); this._autoTypeTmp = false; this._handleKeypress({keyCode: code}); }, _fillRecordsCache: function() { var self = this, inputText = this._input.value, records; if(this._curReq && this._curReq.abort) this._curReq.abort(); //abort previous requests L.DomUtil.addClass(this._container, 'search-load'); if(this.options.layer) { //TODO _recordsFromLayer must return array of objects, formatted from _formatData this._recordsCache = this._recordsFromLayer(); records = this._filterData( this._input.value, this._recordsCache ); this.showTooltip( records ); L.DomUtil.removeClass(this._container, 'search-load'); } else { if(this.options.sourceData) this._retrieveData = this.options.sourceData; else if(this.options.url) //jsonp or ajax this._retrieveData = this.options.jsonpParam ? this._recordsFromJsonp : this._recordsFromAjax; this._curReq = this._retrieveData.call(this, inputText, function(data) { self._recordsCache = self._formatData.call(self, data); //TODO refact! if(self.options.sourceData) records = self._filterData( self._input.value, self._recordsCache ); else records = self._recordsCache; self.showTooltip( records ); L.DomUtil.removeClass(self._container, 'search-load'); }); } }, _handleAutoresize: function() { var maxWidth; if (this._input.style.maxWidth !== this._map._container.offsetWidth) { maxWidth = this._map._container.clientWidth; // other side margin + padding + width border + width search-button + width search-cancel maxWidth -= 10 + 20 + 1 + 30 + 22; this._input.style.maxWidth = maxWidth.toString() + 'px'; } if (this.options.autoResize && (this._container.offsetWidth + 20 < this._map._container.offsetWidth)) { this._input.size = this._input.value.length < this._inputMinSize ? this._inputMinSize : this._input.value.length; } }, _handleArrowSelect: function(velocity) { var searchTips = this._tooltip.hasChildNodes() ? this._tooltip.childNodes : []; for (let i=0; i= (searchTips.length - 1))) {// If at end of list. L.DomUtil.addClass(searchTips[this._tooltip.currentSelection], 'search-tip-select'); } else if ((velocity == -1 ) && (this._tooltip.currentSelection <= 0)) { // Going back up to the search box. this._tooltip.currentSelection = -1; } else if (this._tooltip.style.display != 'none') { this._tooltip.currentSelection += velocity; L.DomUtil.addClass(searchTips[this._tooltip.currentSelection], 'search-tip-select'); this._input.value = searchTips[this._tooltip.currentSelection]._text; // scroll: var tipOffsetTop = searchTips[this._tooltip.currentSelection].offsetTop; if (tipOffsetTop + searchTips[this._tooltip.currentSelection].clientHeight >= this._tooltip.scrollTop + this._tooltip.clientHeight) { this._tooltip.scrollTop = tipOffsetTop - this._tooltip.clientHeight + searchTips[this._tooltip.currentSelection].clientHeight; } else if (tipOffsetTop <= this._tooltip.scrollTop) { this._tooltip.scrollTop = tipOffsetTop; } } }, _handleSubmit: function() { //button and tooltip click and enter submit this._hideAutoType(); this.hideAlert(); this._hideTooltip(); if(this._input.style.display == 'none') //on first click show _input only this.expand(); else { if(this._input.value === '') //hide _input only this.collapse(); else { var loc = this._getLocation(this._input.value); if(!loc) { this.showAlert(); } else { this.showLocation(loc, this._input.value); this.fire('search:locationfound', { latlng: loc, text: this._input.value, layer: loc.layer ? loc.layer : null }); } } } }, _getLocation: function(key) { //extract latlng from _recordsCache if( this._recordsCache.hasOwnProperty(key) ) return this._recordsCache[key];//then after use .loc attribute else return false; }, _defaultMoveToLocation: function(latlng, title, map) { if(this.options.zoom) this._map.setView(latlng, this.options.zoom); else this._map.panTo(latlng); }, showLocation: function(latlng, title) { //set location on map from _recordsCache var self = this; self._map.once('moveend zoomend', function(e) { if(self._markerSearch) { self._markerSearch.addTo(self._map).setLatLng(latlng); } }); self._moveToLocation(latlng, title, self._map); //FIXME autoCollapse option hide self._markerSearch before visualized!! if(self.options.autoCollapse) self.collapse(); return self; } }); L.Control.Search.Marker = L.Marker.extend({ includes: L.version[0]==='1' ? L.Evented.prototype : L.Mixin.Events, options: { icon: new L.Icon.Default(), animate: true, circle: { radius: 10, weight: 3, color: '#e03', stroke: true, fill: false } }, initialize: function (latlng, options) { L.setOptions(this, options); if(options.icon === true) options.icon = new L.Icon.Default(); L.Marker.prototype.initialize.call(this, latlng, options); if( L.Control.Search.prototype._isObject(this.options.circle) ) this._circleLoc = new L.CircleMarker(latlng, this.options.circle); }, onAdd: function (map) { L.Marker.prototype.onAdd.call(this, map); if(this._circleLoc) { map.addLayer(this._circleLoc); if(this.options.animate) this.animate(); } }, onRemove: function (map) { L.Marker.prototype.onRemove.call(this, map); if(this._circleLoc) map.removeLayer(this._circleLoc); }, setLatLng: function (latlng) { L.Marker.prototype.setLatLng.call(this, latlng); if(this._circleLoc) this._circleLoc.setLatLng(latlng); return this; }, _initIcon: function () { if(this.options.icon) L.Marker.prototype._initIcon.call(this); }, _removeIcon: function () { if(this.options.icon) L.Marker.prototype._removeIcon.call(this); }, animate: function() { //TODO refact animate() more smooth! like this: http://goo.gl/DDlRs if(this._circleLoc) { var circle = this._circleLoc, tInt = 200, //time interval ss = 5, //frames mr = parseInt(circle._radius/ss), oldrad = this.options.circle.radius, newrad = circle._radius * 2, acc = 0; circle._timerAnimLoc = setInterval(function() { acc += 0.5; mr += acc; //adding acceleration newrad -= mr; circle.setRadius(newrad); if(newrad= currentZoom) { visibleLayer = visibleLayer.__parent; } } if (this._currentShownBounds.contains(visibleLayer.getLatLng())) { if (this.options.animateAddingMarkers) { this._animationAddLayer(layer, visibleLayer); } else { this._animationAddLayerNonAnimated(layer, visibleLayer); } } return this; }, removeLayer: function (layer) { if (layer instanceof L.LayerGroup) { return this.removeLayers([layer]); } //Non point layers if (!layer.getLatLng) { this._nonPointGroup.removeLayer(layer); this.fire('layerremove', { layer: layer }); return this; } if (!this._map) { if (!this._arraySplice(this._needsClustering, layer) && this.hasLayer(layer)) { this._needsRemoving.push({ layer: layer, latlng: layer._latlng }); } this.fire('layerremove', { layer: layer }); return this; } if (!layer.__parent) { return this; } if (this._unspiderfy) { this._unspiderfy(); this._unspiderfyLayer(layer); } //Remove the marker from clusters this._removeLayer(layer, true); this.fire('layerremove', { layer: layer }); // Refresh bounds and weighted positions. this._topClusterLevel._recalculateBounds(); this._refreshClustersIcons(); layer.off(this._childMarkerEventHandlers, this); if (this._featureGroup.hasLayer(layer)) { this._featureGroup.removeLayer(layer); if (layer.clusterShow) { layer.clusterShow(); } } return this; }, //Takes an array of markers and adds them in bulk addLayers: function (layersArray, skipLayerAddEvent) { if (!L.Util.isArray(layersArray)) { return this.addLayer(layersArray); } var fg = this._featureGroup, npg = this._nonPointGroup, chunked = this.options.chunkedLoading, chunkInterval = this.options.chunkInterval, chunkProgress = this.options.chunkProgress, l = layersArray.length, offset = 0, originalArray = true, m; if (this._map) { var started = (new Date()).getTime(); var process = L.bind(function () { var start = (new Date()).getTime(); // Make sure to unspiderfy before starting to add some layers if (this._map && this._unspiderfy) { this._unspiderfy(); } for (; offset < l; offset++) { if (chunked && offset % 200 === 0) { // every couple hundred markers, instrument the time elapsed since processing started: var elapsed = (new Date()).getTime() - start; if (elapsed > chunkInterval) { break; // been working too hard, time to take a break :-) } } m = layersArray[offset]; // Group of layers, append children to layersArray and skip. // Side effects: // - Total increases, so chunkProgress ratio jumps backward. // - Groups are not included in this group, only their non-group child layers (hasLayer). // Changing array length while looping does not affect performance in current browsers: // http://jsperf.com/for-loop-changing-length/6 if (m instanceof L.LayerGroup) { if (originalArray) { layersArray = layersArray.slice(); originalArray = false; } this._extractNonGroupLayers(m, layersArray); l = layersArray.length; continue; } //Not point data, can't be clustered if (!m.getLatLng) { npg.addLayer(m); if (!skipLayerAddEvent) { this.fire('layeradd', { layer: m }); } continue; } if (this.hasLayer(m)) { continue; } this._addLayer(m, this._maxZoom); if (!skipLayerAddEvent) { this.fire('layeradd', { layer: m }); } //If we just made a cluster of size 2 then we need to remove the other marker from the map (if it is) or we never will if (m.__parent) { if (m.__parent.getChildCount() === 2) { var markers = m.__parent.getAllChildMarkers(), otherMarker = markers[0] === m ? markers[1] : markers[0]; fg.removeLayer(otherMarker); } } } if (chunkProgress) { // report progress and time elapsed: chunkProgress(offset, l, (new Date()).getTime() - started); } // Completed processing all markers. if (offset === l) { // Refresh bounds and weighted positions. this._topClusterLevel._recalculateBounds(); this._refreshClustersIcons(); this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds); } else { setTimeout(process, this.options.chunkDelay); } }, this); process(); } else { var needsClustering = this._needsClustering; for (; offset < l; offset++) { m = layersArray[offset]; // Group of layers, append children to layersArray and skip. if (m instanceof L.LayerGroup) { if (originalArray) { layersArray = layersArray.slice(); originalArray = false; } this._extractNonGroupLayers(m, layersArray); l = layersArray.length; continue; } //Not point data, can't be clustered if (!m.getLatLng) { npg.addLayer(m); continue; } if (this.hasLayer(m)) { continue; } needsClustering.push(m); } } return this; }, //Takes an array of markers and removes them in bulk removeLayers: function (layersArray) { var i, m, l = layersArray.length, fg = this._featureGroup, npg = this._nonPointGroup, originalArray = true; if (!this._map) { for (i = 0; i < l; i++) { m = layersArray[i]; // Group of layers, append children to layersArray and skip. if (m instanceof L.LayerGroup) { if (originalArray) { layersArray = layersArray.slice(); originalArray = false; } this._extractNonGroupLayers(m, layersArray); l = layersArray.length; continue; } this._arraySplice(this._needsClustering, m); npg.removeLayer(m); if (this.hasLayer(m)) { this._needsRemoving.push({ layer: m, latlng: m._latlng }); } this.fire('layerremove', { layer: m }); } return this; } if (this._unspiderfy) { this._unspiderfy(); // Work on a copy of the array, so that next loop is not affected. var layersArray2 = layersArray.slice(), l2 = l; for (i = 0; i < l2; i++) { m = layersArray2[i]; // Group of layers, append children to layersArray and skip. if (m instanceof L.LayerGroup) { this._extractNonGroupLayers(m, layersArray2); l2 = layersArray2.length; continue; } this._unspiderfyLayer(m); } } for (i = 0; i < l; i++) { m = layersArray[i]; // Group of layers, append children to layersArray and skip. if (m instanceof L.LayerGroup) { if (originalArray) { layersArray = layersArray.slice(); originalArray = false; } this._extractNonGroupLayers(m, layersArray); l = layersArray.length; continue; } if (!m.__parent) { npg.removeLayer(m); this.fire('layerremove', { layer: m }); continue; } this._removeLayer(m, true, true); this.fire('layerremove', { layer: m }); if (fg.hasLayer(m)) { fg.removeLayer(m); if (m.clusterShow) { m.clusterShow(); } } } // Refresh bounds and weighted positions. this._topClusterLevel._recalculateBounds(); this._refreshClustersIcons(); //Fix up the clusters and markers on the map this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds); return this; }, //Removes all layers from the MarkerClusterGroup clearLayers: function () { //Need our own special implementation as the LayerGroup one doesn't work for us //If we aren't on the map (yet), blow away the markers we know of if (!this._map) { this._needsClustering = []; this._needsRemoving = []; delete this._gridClusters; delete this._gridUnclustered; } if (this._noanimationUnspiderfy) { this._noanimationUnspiderfy(); } //Remove all the visible layers this._featureGroup.clearLayers(); this._nonPointGroup.clearLayers(); this.eachLayer(function (marker) { marker.off(this._childMarkerEventHandlers, this); delete marker.__parent; }, this); if (this._map) { //Reset _topClusterLevel and the DistanceGrids this._generateInitialClusters(); } return this; }, //Override FeatureGroup.getBounds as it doesn't work getBounds: function () { var bounds = new L.LatLngBounds(); if (this._topClusterLevel) { bounds.extend(this._topClusterLevel._bounds); } for (var i = this._needsClustering.length - 1; i >= 0; i--) { bounds.extend(this._needsClustering[i].getLatLng()); } bounds.extend(this._nonPointGroup.getBounds()); return bounds; }, //Overrides LayerGroup.eachLayer eachLayer: function (method, context) { var markers = this._needsClustering.slice(), needsRemoving = this._needsRemoving, thisNeedsRemoving, i, j; if (this._topClusterLevel) { this._topClusterLevel.getAllChildMarkers(markers); } for (i = markers.length - 1; i >= 0; i--) { thisNeedsRemoving = true; for (j = needsRemoving.length - 1; j >= 0; j--) { if (needsRemoving[j].layer === markers[i]) { thisNeedsRemoving = false; break; } } if (thisNeedsRemoving) { method.call(context, markers[i]); } } this._nonPointGroup.eachLayer(method, context); }, //Overrides LayerGroup.getLayers getLayers: function () { var layers = []; this.eachLayer(function (l) { layers.push(l); }); return layers; }, //Overrides LayerGroup.getLayer, WARNING: Really bad performance getLayer: function (id) { var result = null; id = parseInt(id, 10); this.eachLayer(function (l) { if (L.stamp(l) === id) { result = l; } }); return result; }, //Returns true if the given layer is in this MarkerClusterGroup hasLayer: function (layer) { if (!layer) { return false; } var i, anArray = this._needsClustering; for (i = anArray.length - 1; i >= 0; i--) { if (anArray[i] === layer) { return true; } } anArray = this._needsRemoving; for (i = anArray.length - 1; i >= 0; i--) { if (anArray[i].layer === layer) { return false; } } return !!(layer.__parent && layer.__parent._group === this) || this._nonPointGroup.hasLayer(layer); }, //Zoom down to show the given layer (spiderfying if necessary) then calls the callback zoomToShowLayer: function (layer, callback) { var map = this._map; if (typeof callback !== 'function') { callback = function () {}; } var showMarker = function () { // Assumes that map.hasLayer checks for direct appearance on map, not recursively calling // hasLayer on Layer Groups that are on map (typically not calling this MarkerClusterGroup.hasLayer, which would always return true) if ((map.hasLayer(layer) || map.hasLayer(layer.__parent)) && !this._inZoomAnimation) { this._map.off('moveend', showMarker, this); this.off('animationend', showMarker, this); if (map.hasLayer(layer)) { callback(); } else if (layer.__parent._icon) { this.once('spiderfied', callback, this); layer.__parent.spiderfy(); } } }; if (layer._icon && this._map.getBounds().contains(layer.getLatLng())) { //Layer is visible ond on screen, immediate return callback(); } else if (layer.__parent._zoom < Math.round(this._map._zoom)) { //Layer should be visible at this zoom level. It must not be on screen so just pan over to it this._map.on('moveend', showMarker, this); this._map.panTo(layer.getLatLng()); } else { this._map.on('moveend', showMarker, this); this.on('animationend', showMarker, this); layer.__parent.zoomToBounds(); } }, //Overrides FeatureGroup.onAdd onAdd: function (map) { this._map = map; var i, l, layer; if (!isFinite(this._map.getMaxZoom())) { throw "Map has no maxZoom specified"; } this._featureGroup.addTo(map); this._nonPointGroup.addTo(map); if (!this._gridClusters) { this._generateInitialClusters(); } this._maxLat = map.options.crs.projection.MAX_LATITUDE; //Restore all the positions as they are in the MCG before removing them for (i = 0, l = this._needsRemoving.length; i < l; i++) { layer = this._needsRemoving[i]; layer.newlatlng = layer.layer._latlng; layer.layer._latlng = layer.latlng; } //Remove them, then restore their new positions for (i = 0, l = this._needsRemoving.length; i < l; i++) { layer = this._needsRemoving[i]; this._removeLayer(layer.layer, true); layer.layer._latlng = layer.newlatlng; } this._needsRemoving = []; //Remember the current zoom level and bounds this._zoom = Math.round(this._map._zoom); this._currentShownBounds = this._getExpandedVisibleBounds(); this._map.on('zoomend', this._zoomEnd, this); this._map.on('moveend', this._moveEnd, this); if (this._spiderfierOnAdd) { //TODO FIXME: Not sure how to have spiderfier add something on here nicely this._spiderfierOnAdd(); } this._bindEvents(); //Actually add our markers to the map: l = this._needsClustering; this._needsClustering = []; this.addLayers(l, true); }, //Overrides FeatureGroup.onRemove onRemove: function (map) { map.off('zoomend', this._zoomEnd, this); map.off('moveend', this._moveEnd, this); this._unbindEvents(); //In case we are in a cluster animation this._map._mapPane.className = this._map._mapPane.className.replace(' leaflet-cluster-anim', ''); if (this._spiderfierOnRemove) { //TODO FIXME: Not sure how to have spiderfier add something on here nicely this._spiderfierOnRemove(); } delete this._maxLat; //Clean up all the layers we added to the map this._hideCoverage(); this._featureGroup.remove(); this._nonPointGroup.remove(); this._featureGroup.clearLayers(); this._map = null; }, getVisibleParent: function (marker) { var vMarker = marker; while (vMarker && !vMarker._icon) { vMarker = vMarker.__parent; } return vMarker || null; }, //Remove the given object from the given array _arraySplice: function (anArray, obj) { for (var i = anArray.length - 1; i >= 0; i--) { if (anArray[i] === obj) { anArray.splice(i, 1); return true; } } }, /** * Removes a marker from all _gridUnclustered zoom levels, starting at the supplied zoom. * @param marker to be removed from _gridUnclustered. * @param z integer bottom start zoom level (included) * @private */ _removeFromGridUnclustered: function (marker, z) { var map = this._map, gridUnclustered = this._gridUnclustered, minZoom = Math.floor(this._map.getMinZoom()); for (; z >= minZoom; z--) { if (!gridUnclustered[z].removeObject(marker, map.project(marker.getLatLng(), z))) { break; } } }, _childMarkerDragStart: function (e) { e.target.__dragStart = e.target._latlng; }, _childMarkerMoved: function (e) { if (!this._ignoreMove && !e.target.__dragStart) { var isPopupOpen = e.target._popup && e.target._popup.isOpen(); this._moveChild(e.target, e.oldLatLng, e.latlng); if (isPopupOpen) { e.target.openPopup(); } } }, _moveChild: function (layer, from, to) { layer._latlng = from; this.removeLayer(layer); layer._latlng = to; this.addLayer(layer); }, _childMarkerDragEnd: function (e) { var dragStart = e.target.__dragStart; delete e.target.__dragStart; if (dragStart) { this._moveChild(e.target, dragStart, e.target._latlng); } }, //Internal function for removing a marker from everything. //dontUpdateMap: set to true if you will handle updating the map manually (for bulk functions) _removeLayer: function (marker, removeFromDistanceGrid, dontUpdateMap) { var gridClusters = this._gridClusters, gridUnclustered = this._gridUnclustered, fg = this._featureGroup, map = this._map, minZoom = Math.floor(this._map.getMinZoom()); //Remove the marker from distance clusters it might be in if (removeFromDistanceGrid) { this._removeFromGridUnclustered(marker, this._maxZoom); } //Work our way up the clusters removing them as we go if required var cluster = marker.__parent, markers = cluster._markers, otherMarker; //Remove the marker from the immediate parents marker list this._arraySplice(markers, marker); while (cluster) { cluster._childCount--; cluster._boundsNeedUpdate = true; if (cluster._zoom < minZoom) { //Top level, do nothing break; } else if (removeFromDistanceGrid && cluster._childCount <= 1) { //Cluster no longer required //We need to push the other marker up to the parent otherMarker = cluster._markers[0] === marker ? cluster._markers[1] : cluster._markers[0]; //Update distance grid gridClusters[cluster._zoom].removeObject(cluster, map.project(cluster._cLatLng, cluster._zoom)); gridUnclustered[cluster._zoom].addObject(otherMarker, map.project(otherMarker.getLatLng(), cluster._zoom)); //Move otherMarker up to parent this._arraySplice(cluster.__parent._childClusters, cluster); cluster.__parent._markers.push(otherMarker); otherMarker.__parent = cluster.__parent; if (cluster._icon) { //Cluster is currently on the map, need to put the marker on the map instead fg.removeLayer(cluster); if (!dontUpdateMap) { fg.addLayer(otherMarker); } } } else { cluster._iconNeedsUpdate = true; } cluster = cluster.__parent; } delete marker.__parent; }, _isOrIsParent: function (el, oel) { while (oel) { if (el === oel) { return true; } oel = oel.parentNode; } return false; }, //Override L.Evented.fire fire: function (type, data, propagate) { if (data && data.layer instanceof L.MarkerCluster) { //Prevent multiple clustermouseover/off events if the icon is made up of stacked divs (Doesn't work in ie <= 8, no relatedTarget) if (data.originalEvent && this._isOrIsParent(data.layer._icon, data.originalEvent.relatedTarget)) { return; } type = 'cluster' + type; } L.FeatureGroup.prototype.fire.call(this, type, data, propagate); }, //Override L.Evented.listens listens: function (type, propagate) { return L.FeatureGroup.prototype.listens.call(this, type, propagate) || L.FeatureGroup.prototype.listens.call(this, 'cluster' + type, propagate); }, //Default functionality _defaultIconCreateFunction: function (cluster) { var childCount = cluster.getChildCount(); var c = ' marker-cluster-'; if (childCount < 10) { c += 'small'; } else if (childCount < 100) { c += 'medium'; } else { c += 'large'; } return new L.DivIcon({ html: '
' + childCount + '
', className: 'marker-cluster' + c, iconSize: new L.Point(40, 40) }); }, _bindEvents: function () { var map = this._map, spiderfyOnMaxZoom = this.options.spiderfyOnMaxZoom, showCoverageOnHover = this.options.showCoverageOnHover, zoomToBoundsOnClick = this.options.zoomToBoundsOnClick, spiderfyOnEveryZoom = this.options.spiderfyOnEveryZoom; //Zoom on cluster click or spiderfy if we are at the lowest level if (spiderfyOnMaxZoom || zoomToBoundsOnClick || spiderfyOnEveryZoom) { this.on('clusterclick clusterkeypress', this._zoomOrSpiderfy, this); } //Show convex hull (boundary) polygon on mouse over if (showCoverageOnHover) { this.on('clustermouseover', this._showCoverage, this); this.on('clustermouseout', this._hideCoverage, this); map.on('zoomend', this._hideCoverage, this); } }, _zoomOrSpiderfy: function (e) { var cluster = e.layer, bottomCluster = cluster; if (e.type === 'clusterkeypress' && e.originalEvent && e.originalEvent.keyCode !== 13) { return; } while (bottomCluster._childClusters.length === 1) { bottomCluster = bottomCluster._childClusters[0]; } if (bottomCluster._zoom === this._maxZoom && bottomCluster._childCount === cluster._childCount && this.options.spiderfyOnMaxZoom) { // All child markers are contained in a single cluster from this._maxZoom to this cluster. cluster.spiderfy(); } else if (this.options.zoomToBoundsOnClick) { cluster.zoomToBounds(); } if (this.options.spiderfyOnEveryZoom) { cluster.spiderfy(); } // Focus the map again for keyboard users. if (e.originalEvent && e.originalEvent.keyCode === 13) { this._map._container.focus(); } }, _showCoverage: function (e) { var map = this._map; if (this._inZoomAnimation) { return; } if (this._shownPolygon) { map.removeLayer(this._shownPolygon); } if (e.layer.getChildCount() > 2 && e.layer !== this._spiderfied) { this._shownPolygon = new L.Polygon(e.layer.getConvexHull(), this.options.polygonOptions); map.addLayer(this._shownPolygon); } }, _hideCoverage: function () { if (this._shownPolygon) { this._map.removeLayer(this._shownPolygon); this._shownPolygon = null; } }, _unbindEvents: function () { var spiderfyOnMaxZoom = this.options.spiderfyOnMaxZoom, showCoverageOnHover = this.options.showCoverageOnHover, zoomToBoundsOnClick = this.options.zoomToBoundsOnClick, spiderfyOnEveryZoom = this.options.spiderfyOnEveryZoom, map = this._map; if (spiderfyOnMaxZoom || zoomToBoundsOnClick || spiderfyOnEveryZoom) { this.off('clusterclick clusterkeypress', this._zoomOrSpiderfy, this); } if (showCoverageOnHover) { this.off('clustermouseover', this._showCoverage, this); this.off('clustermouseout', this._hideCoverage, this); map.off('zoomend', this._hideCoverage, this); } }, _zoomEnd: function () { if (!this._map) { //May have been removed from the map by a zoomEnd handler return; } this._mergeSplitClusters(); this._zoom = Math.round(this._map._zoom); this._currentShownBounds = this._getExpandedVisibleBounds(); }, _moveEnd: function () { if (this._inZoomAnimation) { return; } var newBounds = this._getExpandedVisibleBounds(); this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), this._zoom, newBounds); this._topClusterLevel._recursivelyAddChildrenToMap(null, Math.round(this._map._zoom), newBounds); this._currentShownBounds = newBounds; return; }, _generateInitialClusters: function () { var maxZoom = Math.ceil(this._map.getMaxZoom()), minZoom = Math.floor(this._map.getMinZoom()), radius = this.options.maxClusterRadius, radiusFn = radius; //If we just set maxClusterRadius to a single number, we need to create //a simple function to return that number. Otherwise, we just have to //use the function we've passed in. if (typeof radius !== "function") { radiusFn = function () { return radius; }; } if (this.options.disableClusteringAtZoom !== null) { maxZoom = this.options.disableClusteringAtZoom - 1; } this._maxZoom = maxZoom; this._gridClusters = {}; this._gridUnclustered = {}; //Set up DistanceGrids for each zoom for (var zoom = maxZoom; zoom >= minZoom; zoom--) { this._gridClusters[zoom] = new L.DistanceGrid(radiusFn(zoom)); this._gridUnclustered[zoom] = new L.DistanceGrid(radiusFn(zoom)); } // Instantiate the appropriate L.MarkerCluster class (animated or not). this._topClusterLevel = new this._markerCluster(this, minZoom - 1); }, //Zoom: Zoom to start adding at (Pass this._maxZoom to start at the bottom) _addLayer: function (layer, zoom) { var gridClusters = this._gridClusters, gridUnclustered = this._gridUnclustered, minZoom = Math.floor(this._map.getMinZoom()), markerPoint, z; if (this.options.singleMarkerMode) { this._overrideMarkerIcon(layer); } layer.on(this._childMarkerEventHandlers, this); //Find the lowest zoom level to slot this one in for (; zoom >= minZoom; zoom--) { markerPoint = this._map.project(layer.getLatLng(), zoom); // calculate pixel position //Try find a cluster close by var closest = gridClusters[zoom].getNearObject(markerPoint); if (closest) { closest._addChild(layer); layer.__parent = closest; return; } //Try find a marker close by to form a new cluster with closest = gridUnclustered[zoom].getNearObject(markerPoint); if (closest) { var parent = closest.__parent; if (parent) { this._removeLayer(closest, false); } //Create new cluster with these 2 in it var newCluster = new this._markerCluster(this, zoom, closest, layer); gridClusters[zoom].addObject(newCluster, this._map.project(newCluster._cLatLng, zoom)); closest.__parent = newCluster; layer.__parent = newCluster; //First create any new intermediate parent clusters that don't exist var lastParent = newCluster; for (z = zoom - 1; z > parent._zoom; z--) { lastParent = new this._markerCluster(this, z, lastParent); gridClusters[z].addObject(lastParent, this._map.project(closest.getLatLng(), z)); } parent._addChild(lastParent); //Remove closest from this zoom level and any above that it is in, replace with newCluster this._removeFromGridUnclustered(closest, zoom); return; } //Didn't manage to cluster in at this zoom, record us as a marker here and continue upwards gridUnclustered[zoom].addObject(layer, markerPoint); } //Didn't get in anything, add us to the top this._topClusterLevel._addChild(layer); layer.__parent = this._topClusterLevel; return; }, /** * Refreshes the icon of all "dirty" visible clusters. * Non-visible "dirty" clusters will be updated when they are added to the map. * @private */ _refreshClustersIcons: function () { this._featureGroup.eachLayer(function (c) { if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) { c._updateIcon(); } }); }, //Enqueue code to fire after the marker expand/contract has happened _enqueue: function (fn) { this._queue.push(fn); if (!this._queueTimeout) { this._queueTimeout = setTimeout(L.bind(this._processQueue, this), 300); } }, _processQueue: function () { for (var i = 0; i < this._queue.length; i++) { this._queue[i].call(this); } this._queue.length = 0; clearTimeout(this._queueTimeout); this._queueTimeout = null; }, //Merge and split any existing clusters that are too big or small _mergeSplitClusters: function () { var mapZoom = Math.round(this._map._zoom); //In case we are starting to split before the animation finished this._processQueue(); if (this._zoom < mapZoom && this._currentShownBounds.intersects(this._getExpandedVisibleBounds())) { //Zoom in, split this._animationStart(); //Remove clusters now off screen this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), this._zoom, this._getExpandedVisibleBounds()); this._animationZoomIn(this._zoom, mapZoom); } else if (this._zoom > mapZoom) { //Zoom out, merge this._animationStart(); this._animationZoomOut(this._zoom, mapZoom); } else { this._moveEnd(); } }, //Gets the maps visible bounds expanded in each direction by the size of the screen (so the user cannot see an area we do not cover in one pan) _getExpandedVisibleBounds: function () { if (!this.options.removeOutsideVisibleBounds) { return this._mapBoundsInfinite; } else if (L.Browser.mobile) { return this._checkBoundsMaxLat(this._map.getBounds()); } return this._checkBoundsMaxLat(this._map.getBounds().pad(1)); // Padding expands the bounds by its own dimensions but scaled with the given factor. }, /** * Expands the latitude to Infinity (or -Infinity) if the input bounds reach the map projection maximum defined latitude * (in the case of Web/Spherical Mercator, it is 85.0511287798 / see https://en.wikipedia.org/wiki/Web_Mercator#Formulas). * Otherwise, the removeOutsideVisibleBounds option will remove markers beyond that limit, whereas the same markers without * this option (or outside MCG) will have their position floored (ceiled) by the projection and rendered at that limit, * making the user think that MCG "eats" them and never displays them again. * @param bounds L.LatLngBounds * @returns {L.LatLngBounds} * @private */ _checkBoundsMaxLat: function (bounds) { var maxLat = this._maxLat; if (maxLat !== undefined) { if (bounds.getNorth() >= maxLat) { bounds._northEast.lat = Infinity; } if (bounds.getSouth() <= -maxLat) { bounds._southWest.lat = -Infinity; } } return bounds; }, //Shared animation code _animationAddLayerNonAnimated: function (layer, newCluster) { if (newCluster === layer) { this._featureGroup.addLayer(layer); } else if (newCluster._childCount === 2) { newCluster._addToMap(); var markers = newCluster.getAllChildMarkers(); this._featureGroup.removeLayer(markers[0]); this._featureGroup.removeLayer(markers[1]); } else { newCluster._updateIcon(); } }, /** * Extracts individual (i.e. non-group) layers from a Layer Group. * @param group to extract layers from. * @param output {Array} in which to store the extracted layers. * @returns {*|Array} * @private */ _extractNonGroupLayers: function (group, output) { var layers = group.getLayers(), i = 0, layer; output = output || []; for (; i < layers.length; i++) { layer = layers[i]; if (layer instanceof L.LayerGroup) { this._extractNonGroupLayers(layer, output); continue; } output.push(layer); } return output; }, /** * Implements the singleMarkerMode option. * @param layer Marker to re-style using the Clusters iconCreateFunction. * @returns {L.Icon} The newly created icon. * @private */ _overrideMarkerIcon: function (layer) { var icon = layer.options.icon = this.options.iconCreateFunction({ getChildCount: function () { return 1; }, getAllChildMarkers: function () { return [layer]; } }); return icon; } }); // Constant bounds used in case option "removeOutsideVisibleBounds" is set to false. L.MarkerClusterGroup.include({ _mapBoundsInfinite: new L.LatLngBounds(new L.LatLng(-Infinity, -Infinity), new L.LatLng(Infinity, Infinity)) }); L.MarkerClusterGroup.include({ _noAnimation: { //Non Animated versions of everything _animationStart: function () { //Do nothing... }, _animationZoomIn: function (previousZoomLevel, newZoomLevel) { this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), previousZoomLevel); this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds()); //We didn't actually animate, but we use this event to mean "clustering animations have finished" this.fire('animationend'); }, _animationZoomOut: function (previousZoomLevel, newZoomLevel) { this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), previousZoomLevel); this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds()); //We didn't actually animate, but we use this event to mean "clustering animations have finished" this.fire('animationend'); }, _animationAddLayer: function (layer, newCluster) { this._animationAddLayerNonAnimated(layer, newCluster); } }, _withAnimation: { //Animated versions here _animationStart: function () { this._map._mapPane.className += ' leaflet-cluster-anim'; this._inZoomAnimation++; }, _animationZoomIn: function (previousZoomLevel, newZoomLevel) { var bounds = this._getExpandedVisibleBounds(), fg = this._featureGroup, minZoom = Math.floor(this._map.getMinZoom()), i; this._ignoreMove = true; //Add all children of current clusters to map and remove those clusters from map this._topClusterLevel._recursively(bounds, previousZoomLevel, minZoom, function (c) { var startPos = c._latlng, markers = c._markers, m; if (!bounds.contains(startPos)) { startPos = null; } if (c._isSingleParent() && previousZoomLevel + 1 === newZoomLevel) { //Immediately add the new child and remove us fg.removeLayer(c); c._recursivelyAddChildrenToMap(null, newZoomLevel, bounds); } else { //Fade out old cluster c.clusterHide(); c._recursivelyAddChildrenToMap(startPos, newZoomLevel, bounds); } //Remove all markers that aren't visible any more //TODO: Do we actually need to do this on the higher levels too? for (i = markers.length - 1; i >= 0; i--) { m = markers[i]; if (!bounds.contains(m._latlng)) { fg.removeLayer(m); } } }); this._forceLayout(); //Update opacities this._topClusterLevel._recursivelyBecomeVisible(bounds, newZoomLevel); //TODO Maybe? Update markers in _recursivelyBecomeVisible fg.eachLayer(function (n) { if (!(n instanceof L.MarkerCluster) && n._icon) { n.clusterShow(); } }); //update the positions of the just added clusters/markers this._topClusterLevel._recursively(bounds, previousZoomLevel, newZoomLevel, function (c) { c._recursivelyRestoreChildPositions(newZoomLevel); }); this._ignoreMove = false; //Remove the old clusters and close the zoom animation this._enqueue(function () { //update the positions of the just added clusters/markers this._topClusterLevel._recursively(bounds, previousZoomLevel, minZoom, function (c) { fg.removeLayer(c); c.clusterShow(); }); this._animationEnd(); }); }, _animationZoomOut: function (previousZoomLevel, newZoomLevel) { this._animationZoomOutSingle(this._topClusterLevel, previousZoomLevel - 1, newZoomLevel); //Need to add markers for those that weren't on the map before but are now this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds()); //Remove markers that were on the map before but won't be now this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), previousZoomLevel, this._getExpandedVisibleBounds()); }, _animationAddLayer: function (layer, newCluster) { var me = this, fg = this._featureGroup; fg.addLayer(layer); if (newCluster !== layer) { if (newCluster._childCount > 2) { //Was already a cluster newCluster._updateIcon(); this._forceLayout(); this._animationStart(); layer._setPos(this._map.latLngToLayerPoint(newCluster.getLatLng())); layer.clusterHide(); this._enqueue(function () { fg.removeLayer(layer); layer.clusterShow(); me._animationEnd(); }); } else { //Just became a cluster this._forceLayout(); me._animationStart(); me._animationZoomOutSingle(newCluster, this._map.getMaxZoom(), this._zoom); } } } }, // Private methods for animated versions. _animationZoomOutSingle: function (cluster, previousZoomLevel, newZoomLevel) { var bounds = this._getExpandedVisibleBounds(), minZoom = Math.floor(this._map.getMinZoom()); //Animate all of the markers in the clusters to move to their cluster center point cluster._recursivelyAnimateChildrenInAndAddSelfToMap(bounds, minZoom, previousZoomLevel + 1, newZoomLevel); var me = this; //Update the opacity (If we immediately set it they won't animate) this._forceLayout(); cluster._recursivelyBecomeVisible(bounds, newZoomLevel); //TODO: Maybe use the transition timing stuff to make this more reliable //When the animations are done, tidy up this._enqueue(function () { //This cluster stopped being a cluster before the timeout fired if (cluster._childCount === 1) { var m = cluster._markers[0]; //If we were in a cluster animation at the time then the opacity and position of our child could be wrong now, so fix it this._ignoreMove = true; m.setLatLng(m.getLatLng()); this._ignoreMove = false; if (m.clusterShow) { m.clusterShow(); } } else { cluster._recursively(bounds, newZoomLevel, minZoom, function (c) { c._recursivelyRemoveChildrenFromMap(bounds, minZoom, previousZoomLevel + 1); }); } me._animationEnd(); }); }, _animationEnd: function () { if (this._map) { this._map._mapPane.className = this._map._mapPane.className.replace(' leaflet-cluster-anim', ''); } this._inZoomAnimation--; this.fire('animationend'); }, //Force a browser layout of stuff in the map // Should apply the current opacity and location to all elements so we can update them again for an animation _forceLayout: function () { //In my testing this works, infact offsetWidth of any element seems to work. //Could loop all this._layers and do this for each _icon if it stops working L.Util.falseFn(document.body.offsetWidth); } }); L.markerClusterGroup = function (options) { return new L.MarkerClusterGroup(options); }; var MarkerCluster = L.MarkerCluster = L.Marker.extend({ options: L.Icon.prototype.options, initialize: function (group, zoom, a, b) { L.Marker.prototype.initialize.call(this, a ? (a._cLatLng || a.getLatLng()) : new L.LatLng(0, 0), { icon: this, pane: group.options.clusterPane }); this._group = group; this._zoom = zoom; this._markers = []; this._childClusters = []; this._childCount = 0; this._iconNeedsUpdate = true; this._boundsNeedUpdate = true; this._bounds = new L.LatLngBounds(); if (a) { this._addChild(a); } if (b) { this._addChild(b); } }, //Recursively retrieve all child markers of this cluster getAllChildMarkers: function (storageArray, ignoreDraggedMarker) { storageArray = storageArray || []; for (var i = this._childClusters.length - 1; i >= 0; i--) { this._childClusters[i].getAllChildMarkers(storageArray, ignoreDraggedMarker); } for (var j = this._markers.length - 1; j >= 0; j--) { if (ignoreDraggedMarker && this._markers[j].__dragStart) { continue; } storageArray.push(this._markers[j]); } return storageArray; }, //Returns the count of how many child markers we have getChildCount: function () { return this._childCount; }, //Zoom to the minimum of showing all of the child markers, or the extents of this cluster zoomToBounds: function (fitBoundsOptions) { var childClusters = this._childClusters.slice(), map = this._group._map, boundsZoom = map.getBoundsZoom(this._bounds), zoom = this._zoom + 1, mapZoom = map.getZoom(), i; //calculate how far we need to zoom down to see all of the markers while (childClusters.length > 0 && boundsZoom > zoom) { zoom++; var newClusters = []; for (i = 0; i < childClusters.length; i++) { newClusters = newClusters.concat(childClusters[i]._childClusters); } childClusters = newClusters; } if (boundsZoom > zoom) { this._group._map.setView(this._latlng, zoom); } else if (boundsZoom <= mapZoom) { //If fitBounds wouldn't zoom us down, zoom us down instead this._group._map.setView(this._latlng, mapZoom + 1); } else { this._group._map.fitBounds(this._bounds, fitBoundsOptions); } }, getBounds: function () { var bounds = new L.LatLngBounds(); bounds.extend(this._bounds); return bounds; }, _updateIcon: function () { this._iconNeedsUpdate = true; if (this._icon) { this.setIcon(this); } }, //Cludge for Icon, we pretend to be an icon for performance createIcon: function () { if (this._iconNeedsUpdate) { this._iconObj = this._group.options.iconCreateFunction(this); this._iconNeedsUpdate = false; } return this._iconObj.createIcon(); }, createShadow: function () { return this._iconObj.createShadow(); }, _addChild: function (new1, isNotificationFromChild) { this._iconNeedsUpdate = true; this._boundsNeedUpdate = true; this._setClusterCenter(new1); if (new1 instanceof L.MarkerCluster) { if (!isNotificationFromChild) { this._childClusters.push(new1); new1.__parent = this; } this._childCount += new1._childCount; } else { if (!isNotificationFromChild) { this._markers.push(new1); } this._childCount++; } if (this.__parent) { this.__parent._addChild(new1, true); } }, /** * Makes sure the cluster center is set. If not, uses the child center if it is a cluster, or the marker position. * @param child L.MarkerCluster|L.Marker that will be used as cluster center if not defined yet. * @private */ _setClusterCenter: function (child) { if (!this._cLatLng) { // when clustering, take position of the first point as the cluster center this._cLatLng = child._cLatLng || child._latlng; } }, /** * Assigns impossible bounding values so that the next extend entirely determines the new bounds. * This method avoids having to trash the previous L.LatLngBounds object and to create a new one, which is much slower for this class. * As long as the bounds are not extended, most other methods would probably fail, as they would with bounds initialized but not extended. * @private */ _resetBounds: function () { var bounds = this._bounds; if (bounds._southWest) { bounds._southWest.lat = Infinity; bounds._southWest.lng = Infinity; } if (bounds._northEast) { bounds._northEast.lat = -Infinity; bounds._northEast.lng = -Infinity; } }, _recalculateBounds: function () { var markers = this._markers, childClusters = this._childClusters, latSum = 0, lngSum = 0, totalCount = this._childCount, i, child, childLatLng, childCount; // Case where all markers are removed from the map and we are left with just an empty _topClusterLevel. if (totalCount === 0) { return; } // Reset rather than creating a new object, for performance. this._resetBounds(); // Child markers. for (i = 0; i < markers.length; i++) { childLatLng = markers[i]._latlng; this._bounds.extend(childLatLng); latSum += childLatLng.lat; lngSum += childLatLng.lng; } // Child clusters. for (i = 0; i < childClusters.length; i++) { child = childClusters[i]; // Re-compute child bounds and weighted position first if necessary. if (child._boundsNeedUpdate) { child._recalculateBounds(); } this._bounds.extend(child._bounds); childLatLng = child._wLatLng; childCount = child._childCount; latSum += childLatLng.lat * childCount; lngSum += childLatLng.lng * childCount; } this._latlng = this._wLatLng = new L.LatLng(latSum / totalCount, lngSum / totalCount); // Reset dirty flag. this._boundsNeedUpdate = false; }, //Set our markers position as given and add it to the map _addToMap: function (startPos) { if (startPos) { this._backupLatlng = this._latlng; this.setLatLng(startPos); } this._group._featureGroup.addLayer(this); }, _recursivelyAnimateChildrenIn: function (bounds, center, maxZoom) { this._recursively(bounds, this._group._map.getMinZoom(), maxZoom - 1, function (c) { var markers = c._markers, i, m; for (i = markers.length - 1; i >= 0; i--) { m = markers[i]; //Only do it if the icon is still on the map if (m._icon) { m._setPos(center); m.clusterHide(); } } }, function (c) { var childClusters = c._childClusters, j, cm; for (j = childClusters.length - 1; j >= 0; j--) { cm = childClusters[j]; if (cm._icon) { cm._setPos(center); cm.clusterHide(); } } } ); }, _recursivelyAnimateChildrenInAndAddSelfToMap: function (bounds, mapMinZoom, previousZoomLevel, newZoomLevel) { this._recursively(bounds, newZoomLevel, mapMinZoom, function (c) { c._recursivelyAnimateChildrenIn(bounds, c._group._map.latLngToLayerPoint(c.getLatLng()).round(), previousZoomLevel); //TODO: depthToAnimateIn affects _isSingleParent, if there is a multizoom we may/may not be. //As a hack we only do a animation free zoom on a single level zoom, if someone does multiple levels then we always animate if (c._isSingleParent() && previousZoomLevel - 1 === newZoomLevel) { c.clusterShow(); c._recursivelyRemoveChildrenFromMap(bounds, mapMinZoom, previousZoomLevel); //Immediately remove our children as we are replacing them. TODO previousBounds not bounds } else { c.clusterHide(); } c._addToMap(); } ); }, _recursivelyBecomeVisible: function (bounds, zoomLevel) { this._recursively(bounds, this._group._map.getMinZoom(), zoomLevel, null, function (c) { c.clusterShow(); }); }, _recursivelyAddChildrenToMap: function (startPos, zoomLevel, bounds) { this._recursively(bounds, this._group._map.getMinZoom() - 1, zoomLevel, function (c) { if (zoomLevel === c._zoom) { return; } //Add our child markers at startPos (so they can be animated out) for (var i = c._markers.length - 1; i >= 0; i--) { var nm = c._markers[i]; if (!bounds.contains(nm._latlng)) { continue; } if (startPos) { nm._backupLatlng = nm.getLatLng(); nm.setLatLng(startPos); if (nm.clusterHide) { nm.clusterHide(); } } c._group._featureGroup.addLayer(nm); } }, function (c) { c._addToMap(startPos); } ); }, _recursivelyRestoreChildPositions: function (zoomLevel) { //Fix positions of child markers for (var i = this._markers.length - 1; i >= 0; i--) { var nm = this._markers[i]; if (nm._backupLatlng) { nm.setLatLng(nm._backupLatlng); delete nm._backupLatlng; } } if (zoomLevel - 1 === this._zoom) { //Reposition child clusters for (var j = this._childClusters.length - 1; j >= 0; j--) { this._childClusters[j]._restorePosition(); } } else { for (var k = this._childClusters.length - 1; k >= 0; k--) { this._childClusters[k]._recursivelyRestoreChildPositions(zoomLevel); } } }, _restorePosition: function () { if (this._backupLatlng) { this.setLatLng(this._backupLatlng); delete this._backupLatlng; } }, //exceptBounds: If set, don't remove any markers/clusters in it _recursivelyRemoveChildrenFromMap: function (previousBounds, mapMinZoom, zoomLevel, exceptBounds) { var m, i; this._recursively(previousBounds, mapMinZoom - 1, zoomLevel - 1, function (c) { //Remove markers at every level for (i = c._markers.length - 1; i >= 0; i--) { m = c._markers[i]; if (!exceptBounds || !exceptBounds.contains(m._latlng)) { c._group._featureGroup.removeLayer(m); if (m.clusterShow) { m.clusterShow(); } } } }, function (c) { //Remove child clusters at just the bottom level for (i = c._childClusters.length - 1; i >= 0; i--) { m = c._childClusters[i]; if (!exceptBounds || !exceptBounds.contains(m._latlng)) { c._group._featureGroup.removeLayer(m); if (m.clusterShow) { m.clusterShow(); } } } } ); }, //Run the given functions recursively to this and child clusters // boundsToApplyTo: a L.LatLngBounds representing the bounds of what clusters to recurse in to // zoomLevelToStart: zoom level to start running functions (inclusive) // zoomLevelToStop: zoom level to stop running functions (inclusive) // runAtEveryLevel: function that takes an L.MarkerCluster as an argument that should be applied on every level // runAtBottomLevel: function that takes an L.MarkerCluster as an argument that should be applied at only the bottom level _recursively: function (boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel) { var childClusters = this._childClusters, zoom = this._zoom, i, c; if (zoomLevelToStart <= zoom) { if (runAtEveryLevel) { runAtEveryLevel(this); } if (runAtBottomLevel && zoom === zoomLevelToStop) { runAtBottomLevel(this); } } if (zoom < zoomLevelToStart || zoom < zoomLevelToStop) { for (i = childClusters.length - 1; i >= 0; i--) { c = childClusters[i]; if (c._boundsNeedUpdate) { c._recalculateBounds(); } if (boundsToApplyTo.intersects(c._bounds)) { c._recursively(boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel); } } } }, //Returns true if we are the parent of only one cluster and that cluster is the same as us _isSingleParent: function () { //Don't need to check this._markers as the rest won't work if there are any return this._childClusters.length > 0 && this._childClusters[0]._childCount === this._childCount; } }); /* * Extends L.Marker to include two extra methods: clusterHide and clusterShow. * * They work as setOpacity(0) and setOpacity(1) respectively, but * don't overwrite the options.opacity * */ L.Marker.include({ clusterHide: function () { var backup = this.options.opacity; this.setOpacity(0); this.options.opacity = backup; return this; }, clusterShow: function () { return this.setOpacity(this.options.opacity); } }); L.DistanceGrid = function (cellSize) { this._cellSize = cellSize; this._sqCellSize = cellSize * cellSize; this._grid = {}; this._objectPoint = { }; }; L.DistanceGrid.prototype = { addObject: function (obj, point) { var x = this._getCoord(point.x), y = this._getCoord(point.y), grid = this._grid, row = grid[y] = grid[y] || {}, cell = row[x] = row[x] || [], stamp = L.Util.stamp(obj); this._objectPoint[stamp] = point; cell.push(obj); }, updateObject: function (obj, point) { this.removeObject(obj); this.addObject(obj, point); }, //Returns true if the object was found removeObject: function (obj, point) { var x = this._getCoord(point.x), y = this._getCoord(point.y), grid = this._grid, row = grid[y] = grid[y] || {}, cell = row[x] = row[x] || [], i, len; delete this._objectPoint[L.Util.stamp(obj)]; for (i = 0, len = cell.length; i < len; i++) { if (cell[i] === obj) { cell.splice(i, 1); if (len === 1) { delete row[x]; } return true; } } }, eachObject: function (fn, context) { var i, j, k, len, row, cell, removed, grid = this._grid; for (i in grid) { row = grid[i]; for (j in row) { cell = row[j]; for (k = 0, len = cell.length; k < len; k++) { removed = fn.call(context, cell[k]); if (removed) { k--; len--; } } } } }, getNearObject: function (point) { var x = this._getCoord(point.x), y = this._getCoord(point.y), i, j, k, row, cell, len, obj, dist, objectPoint = this._objectPoint, closestDistSq = this._sqCellSize, closest = null; for (i = y - 1; i <= y + 1; i++) { row = this._grid[i]; if (row) { for (j = x - 1; j <= x + 1; j++) { cell = row[j]; if (cell) { for (k = 0, len = cell.length; k < len; k++) { obj = cell[k]; dist = this._sqDist(objectPoint[L.Util.stamp(obj)], point); if (dist < closestDistSq || dist <= closestDistSq && closest === null) { closestDistSq = dist; closest = obj; } } } } } } return closest; }, _getCoord: function (x) { var coord = Math.floor(x / this._cellSize); return isFinite(coord) ? coord : x; }, _sqDist: function (p, p2) { var dx = p2.x - p.x, dy = p2.y - p.y; return dx * dx + dy * dy; } }; /* Copyright (c) 2012 the authors listed at the following URL, and/or the authors of referenced articles or incorporated external code: http://en.literateprograms.org/Quickhull_(Javascript)?action=history&offset=20120410175256 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Retrieved from: http://en.literateprograms.org/Quickhull_(Javascript)?oldid=18434 */ (function () { L.QuickHull = { /* * @param {Object} cpt a point to be measured from the baseline * @param {Array} bl the baseline, as represented by a two-element * array of latlng objects. * @returns {Number} an approximate distance measure */ getDistant: function (cpt, bl) { var vY = bl[1].lat - bl[0].lat, vX = bl[0].lng - bl[1].lng; return (vX * (cpt.lat - bl[0].lat) + vY * (cpt.lng - bl[0].lng)); }, /* * @param {Array} baseLine a two-element array of latlng objects * representing the baseline to project from * @param {Array} latLngs an array of latlng objects * @returns {Object} the maximum point and all new points to stay * in consideration for the hull. */ findMostDistantPointFromBaseLine: function (baseLine, latLngs) { var maxD = 0, maxPt = null, newPoints = [], i, pt, d; for (i = latLngs.length - 1; i >= 0; i--) { pt = latLngs[i]; d = this.getDistant(pt, baseLine); if (d > 0) { newPoints.push(pt); } else { continue; } if (d > maxD) { maxD = d; maxPt = pt; } } return { maxPoint: maxPt, newPoints: newPoints }; }, /* * Given a baseline, compute the convex hull of latLngs as an array * of latLngs. * * @param {Array} latLngs * @returns {Array} */ buildConvexHull: function (baseLine, latLngs) { var convexHullBaseLines = [], t = this.findMostDistantPointFromBaseLine(baseLine, latLngs); if (t.maxPoint) { // if there is still a point "outside" the base line convexHullBaseLines = convexHullBaseLines.concat( this.buildConvexHull([baseLine[0], t.maxPoint], t.newPoints) ); convexHullBaseLines = convexHullBaseLines.concat( this.buildConvexHull([t.maxPoint, baseLine[1]], t.newPoints) ); return convexHullBaseLines; } else { // if there is no more point "outside" the base line, the current base line is part of the convex hull return [baseLine[0]]; } }, /* * Given an array of latlngs, compute a convex hull as an array * of latlngs * * @param {Array} latLngs * @returns {Array} */ getConvexHull: function (latLngs) { // find first baseline var maxLat = false, minLat = false, maxLng = false, minLng = false, maxLatPt = null, minLatPt = null, maxLngPt = null, minLngPt = null, maxPt = null, minPt = null, i; for (i = latLngs.length - 1; i >= 0; i--) { var pt = latLngs[i]; if (maxLat === false || pt.lat > maxLat) { maxLatPt = pt; maxLat = pt.lat; } if (minLat === false || pt.lat < minLat) { minLatPt = pt; minLat = pt.lat; } if (maxLng === false || pt.lng > maxLng) { maxLngPt = pt; maxLng = pt.lng; } if (minLng === false || pt.lng < minLng) { minLngPt = pt; minLng = pt.lng; } } if (minLat !== maxLat) { minPt = minLatPt; maxPt = maxLatPt; } else { minPt = minLngPt; maxPt = maxLngPt; } var ch = [].concat(this.buildConvexHull([minPt, maxPt], latLngs), this.buildConvexHull([maxPt, minPt], latLngs)); return ch; } }; }()); L.MarkerCluster.include({ getConvexHull: function () { var childMarkers = this.getAllChildMarkers(), points = [], p, i; for (i = childMarkers.length - 1; i >= 0; i--) { p = childMarkers[i].getLatLng(); points.push(p); } return L.QuickHull.getConvexHull(points); } }); //This code is 100% based on https://github.com/jawj/OverlappingMarkerSpiderfier-Leaflet //Huge thanks to jawj for implementing it first to make my job easy :-) L.MarkerCluster.include({ _2PI: Math.PI * 2, _circleFootSeparation: 25, //related to circumference of circle _circleStartAngle: 0, _spiralFootSeparation: 28, //related to size of spiral (experiment!) _spiralLengthStart: 11, _spiralLengthFactor: 5, _circleSpiralSwitchover: 9, //show spiral instead of circle from this marker count upwards. // 0 -> always spiral; Infinity -> always circle spiderfy: function () { if (this._group._spiderfied === this || this._group._inZoomAnimation) { return; } var childMarkers = this.getAllChildMarkers(null, true), group = this._group, map = group._map, center = map.latLngToLayerPoint(this._latlng), positions; this._group._unspiderfy(); this._group._spiderfied = this; //TODO Maybe: childMarkers order by distance to center if (this._group.options.spiderfyShapePositions) { positions = this._group.options.spiderfyShapePositions(childMarkers.length, center); } else if (childMarkers.length >= this._circleSpiralSwitchover) { positions = this._generatePointsSpiral(childMarkers.length, center); } else { center.y += 10; // Otherwise circles look wrong => hack for standard blue icon, renders differently for other icons. positions = this._generatePointsCircle(childMarkers.length, center); } this._animationSpiderfy(childMarkers, positions); }, unspiderfy: function (zoomDetails) { /// Argument from zoomanim if being called in a zoom animation or null otherwise if (this._group._inZoomAnimation) { return; } this._animationUnspiderfy(zoomDetails); this._group._spiderfied = null; }, _generatePointsCircle: function (count, centerPt) { var circumference = this._group.options.spiderfyDistanceMultiplier * this._circleFootSeparation * (2 + count), legLength = circumference / this._2PI, //radius from circumference angleStep = this._2PI / count, res = [], i, angle; legLength = Math.max(legLength, 35); // Minimum distance to get outside the cluster icon. res.length = count; for (i = 0; i < count; i++) { // Clockwise, like spiral. angle = this._circleStartAngle + i * angleStep; res[i] = new L.Point(centerPt.x + legLength * Math.cos(angle), centerPt.y + legLength * Math.sin(angle))._round(); } return res; }, _generatePointsSpiral: function (count, centerPt) { var spiderfyDistanceMultiplier = this._group.options.spiderfyDistanceMultiplier, legLength = spiderfyDistanceMultiplier * this._spiralLengthStart, separation = spiderfyDistanceMultiplier * this._spiralFootSeparation, lengthFactor = spiderfyDistanceMultiplier * this._spiralLengthFactor * this._2PI, angle = 0, res = [], i; res.length = count; // Higher index, closer position to cluster center. for (i = count; i >= 0; i--) { // Skip the first position, so that we are already farther from center and we avoid // being under the default cluster icon (especially important for Circle Markers). if (i < count) { res[i] = new L.Point(centerPt.x + legLength * Math.cos(angle), centerPt.y + legLength * Math.sin(angle))._round(); } angle += separation / legLength + i * 0.0005; legLength += lengthFactor / angle; } return res; }, _noanimationUnspiderfy: function () { var group = this._group, map = group._map, fg = group._featureGroup, childMarkers = this.getAllChildMarkers(null, true), m, i; group._ignoreMove = true; this.setOpacity(1); for (i = childMarkers.length - 1; i >= 0; i--) { m = childMarkers[i]; fg.removeLayer(m); if (m._preSpiderfyLatlng) { m.setLatLng(m._preSpiderfyLatlng); delete m._preSpiderfyLatlng; } if (m.setZIndexOffset) { m.setZIndexOffset(0); } if (m._spiderLeg) { map.removeLayer(m._spiderLeg); delete m._spiderLeg; } } group.fire('unspiderfied', { cluster: this, markers: childMarkers }); group._ignoreMove = false; group._spiderfied = null; } }); //Non Animated versions of everything L.MarkerClusterNonAnimated = L.MarkerCluster.extend({ _animationSpiderfy: function (childMarkers, positions) { var group = this._group, map = group._map, fg = group._featureGroup, legOptions = this._group.options.spiderLegPolylineOptions, i, m, leg, newPos; group._ignoreMove = true; // Traverse in ascending order to make sure that inner circleMarkers are on top of further legs. Normal markers are re-ordered by newPosition. // The reverse order trick no longer improves performance on modern browsers. for (i = 0; i < childMarkers.length; i++) { newPos = map.layerPointToLatLng(positions[i]); m = childMarkers[i]; // Add the leg before the marker, so that in case the latter is a circleMarker, the leg is behind it. leg = new L.Polyline([this._latlng, newPos], legOptions); map.addLayer(leg); m._spiderLeg = leg; // Now add the marker. m._preSpiderfyLatlng = m._latlng; m.setLatLng(newPos); if (m.setZIndexOffset) { m.setZIndexOffset(1000000); //Make these appear on top of EVERYTHING } fg.addLayer(m); } this.setOpacity(0.3); group._ignoreMove = false; group.fire('spiderfied', { cluster: this, markers: childMarkers }); }, _animationUnspiderfy: function () { this._noanimationUnspiderfy(); } }); //Animated versions here L.MarkerCluster.include({ _animationSpiderfy: function (childMarkers, positions) { var me = this, group = this._group, map = group._map, fg = group._featureGroup, thisLayerLatLng = this._latlng, thisLayerPos = map.latLngToLayerPoint(thisLayerLatLng), svg = L.Path.SVG, legOptions = L.extend({}, this._group.options.spiderLegPolylineOptions), // Copy the options so that we can modify them for animation. finalLegOpacity = legOptions.opacity, i, m, leg, legPath, legLength, newPos; if (finalLegOpacity === undefined) { finalLegOpacity = L.MarkerClusterGroup.prototype.options.spiderLegPolylineOptions.opacity; } if (svg) { // If the initial opacity of the spider leg is not 0 then it appears before the animation starts. legOptions.opacity = 0; // Add the class for CSS transitions. legOptions.className = (legOptions.className || '') + ' leaflet-cluster-spider-leg'; } else { // Make sure we have a defined opacity. legOptions.opacity = finalLegOpacity; } group._ignoreMove = true; // Add markers and spider legs to map, hidden at our center point. // Traverse in ascending order to make sure that inner circleMarkers are on top of further legs. Normal markers are re-ordered by newPosition. // The reverse order trick no longer improves performance on modern browsers. for (i = 0; i < childMarkers.length; i++) { m = childMarkers[i]; newPos = map.layerPointToLatLng(positions[i]); // Add the leg before the marker, so that in case the latter is a circleMarker, the leg is behind it. leg = new L.Polyline([thisLayerLatLng, newPos], legOptions); map.addLayer(leg); m._spiderLeg = leg; // Explanations: https://jakearchibald.com/2013/animated-line-drawing-svg/ // In our case the transition property is declared in the CSS file. if (svg) { legPath = leg._path; legLength = legPath.getTotalLength() + 0.1; // Need a small extra length to avoid remaining dot in Firefox. legPath.style.strokeDasharray = legLength; // Just 1 length is enough, it will be duplicated. legPath.style.strokeDashoffset = legLength; } // If it is a marker, add it now and we'll animate it out if (m.setZIndexOffset) { m.setZIndexOffset(1000000); // Make normal markers appear on top of EVERYTHING } if (m.clusterHide) { m.clusterHide(); } // Vectors just get immediately added fg.addLayer(m); if (m._setPos) { m._setPos(thisLayerPos); } } group._forceLayout(); group._animationStart(); // Reveal markers and spider legs. for (i = childMarkers.length - 1; i >= 0; i--) { newPos = map.layerPointToLatLng(positions[i]); m = childMarkers[i]; //Move marker to new position m._preSpiderfyLatlng = m._latlng; m.setLatLng(newPos); if (m.clusterShow) { m.clusterShow(); } // Animate leg (animation is actually delegated to CSS transition). if (svg) { leg = m._spiderLeg; legPath = leg._path; legPath.style.strokeDashoffset = 0; //legPath.style.strokeOpacity = finalLegOpacity; leg.setStyle({opacity: finalLegOpacity}); } } this.setOpacity(0.3); group._ignoreMove = false; setTimeout(function () { group._animationEnd(); group.fire('spiderfied', { cluster: me, markers: childMarkers }); }, 200); }, _animationUnspiderfy: function (zoomDetails) { var me = this, group = this._group, map = group._map, fg = group._featureGroup, thisLayerPos = zoomDetails ? map._latLngToNewLayerPoint(this._latlng, zoomDetails.zoom, zoomDetails.center) : map.latLngToLayerPoint(this._latlng), childMarkers = this.getAllChildMarkers(null, true), svg = L.Path.SVG, m, i, leg, legPath, legLength, nonAnimatable; group._ignoreMove = true; group._animationStart(); //Make us visible and bring the child markers back in this.setOpacity(1); for (i = childMarkers.length - 1; i >= 0; i--) { m = childMarkers[i]; //Marker was added to us after we were spiderfied if (!m._preSpiderfyLatlng) { continue; } //Close any popup on the marker first, otherwise setting the location of the marker will make the map scroll m.closePopup(); //Fix up the location to the real one m.setLatLng(m._preSpiderfyLatlng); delete m._preSpiderfyLatlng; //Hack override the location to be our center nonAnimatable = true; if (m._setPos) { m._setPos(thisLayerPos); nonAnimatable = false; } if (m.clusterHide) { m.clusterHide(); nonAnimatable = false; } if (nonAnimatable) { fg.removeLayer(m); } // Animate the spider leg back in (animation is actually delegated to CSS transition). if (svg) { leg = m._spiderLeg; legPath = leg._path; legLength = legPath.getTotalLength() + 0.1; legPath.style.strokeDashoffset = legLength; leg.setStyle({opacity: 0}); } } group._ignoreMove = false; setTimeout(function () { //If we have only <= one child left then that marker will be shown on the map so don't remove it! var stillThereChildCount = 0; for (i = childMarkers.length - 1; i >= 0; i--) { m = childMarkers[i]; if (m._spiderLeg) { stillThereChildCount++; } } for (i = childMarkers.length - 1; i >= 0; i--) { m = childMarkers[i]; if (!m._spiderLeg) { //Has already been unspiderfied continue; } if (m.clusterShow) { m.clusterShow(); } if (m.setZIndexOffset) { m.setZIndexOffset(0); } if (stillThereChildCount > 1) { fg.removeLayer(m); } map.removeLayer(m._spiderLeg); delete m._spiderLeg; } group._animationEnd(); group.fire('unspiderfied', { cluster: me, markers: childMarkers }); }, 200); } }); L.MarkerClusterGroup.include({ //The MarkerCluster currently spiderfied (if any) _spiderfied: null, unspiderfy: function () { this._unspiderfy.apply(this, arguments); }, _spiderfierOnAdd: function () { this._map.on('click', this._unspiderfyWrapper, this); if (this._map.options.zoomAnimation) { this._map.on('zoomstart', this._unspiderfyZoomStart, this); } //Browsers without zoomAnimation or a big zoom don't fire zoomstart this._map.on('zoomend', this._noanimationUnspiderfy, this); if (!L.Browser.touch) { this._map.getRenderer(this); //Needs to happen in the pageload, not after, or animations don't work in webkit // http://stackoverflow.com/questions/8455200/svg-animate-with-dynamically-added-elements //Disable on touch browsers as the animation messes up on a touch zoom and isn't very noticable } }, _spiderfierOnRemove: function () { this._map.off('click', this._unspiderfyWrapper, this); this._map.off('zoomstart', this._unspiderfyZoomStart, this); this._map.off('zoomanim', this._unspiderfyZoomAnim, this); this._map.off('zoomend', this._noanimationUnspiderfy, this); //Ensure that markers are back where they should be // Use no animation to avoid a sticky leaflet-cluster-anim class on mapPane this._noanimationUnspiderfy(); }, //On zoom start we add a zoomanim handler so that we are guaranteed to be last (after markers are animated) //This means we can define the animation they do rather than Markers doing an animation to their actual location _unspiderfyZoomStart: function () { if (!this._map) { //May have been removed from the map by a zoomEnd handler return; } this._map.on('zoomanim', this._unspiderfyZoomAnim, this); }, _unspiderfyZoomAnim: function (zoomDetails) { //Wait until the first zoomanim after the user has finished touch-zooming before running the animation if (L.DomUtil.hasClass(this._map._mapPane, 'leaflet-touching')) { return; } this._map.off('zoomanim', this._unspiderfyZoomAnim, this); this._unspiderfy(zoomDetails); }, _unspiderfyWrapper: function () { /// _unspiderfy but passes no arguments this._unspiderfy(); }, _unspiderfy: function (zoomDetails) { if (this._spiderfied) { this._spiderfied.unspiderfy(zoomDetails); } }, _noanimationUnspiderfy: function () { if (this._spiderfied) { this._spiderfied._noanimationUnspiderfy(); } }, //If the given layer is currently being spiderfied then we unspiderfy it so it isn't on the map anymore etc _unspiderfyLayer: function (layer) { if (layer._spiderLeg) { this._featureGroup.removeLayer(layer); if (layer.clusterShow) { layer.clusterShow(); } //Position will be fixed up immediately in _animationUnspiderfy if (layer.setZIndexOffset) { layer.setZIndexOffset(0); } this._map.removeLayer(layer._spiderLeg); delete layer._spiderLeg; } } }); /** * Adds 1 public method to MCG and 1 to L.Marker to facilitate changing * markers' icon options and refreshing their icon and their parent clusters * accordingly (case where their iconCreateFunction uses data of childMarkers * to make up the cluster icon). */ L.MarkerClusterGroup.include({ /** * Updates the icon of all clusters which are parents of the given marker(s). * In singleMarkerMode, also updates the given marker(s) icon. * @param layers L.MarkerClusterGroup|L.LayerGroup|Array(L.Marker)|Map(L.Marker)| * L.MarkerCluster|L.Marker (optional) list of markers (or single marker) whose parent * clusters need to be updated. If not provided, retrieves all child markers of this. * @returns {L.MarkerClusterGroup} */ refreshClusters: function (layers) { if (!layers) { layers = this._topClusterLevel.getAllChildMarkers(); } else if (layers instanceof L.MarkerClusterGroup) { layers = layers._topClusterLevel.getAllChildMarkers(); } else if (layers instanceof L.LayerGroup) { layers = layers._layers; } else if (layers instanceof L.MarkerCluster) { layers = layers.getAllChildMarkers(); } else if (layers instanceof L.Marker) { layers = [layers]; } // else: must be an Array(L.Marker)|Map(L.Marker) this._flagParentsIconsNeedUpdate(layers); this._refreshClustersIcons(); // In case of singleMarkerMode, also re-draw the markers. if (this.options.singleMarkerMode) { this._refreshSingleMarkerModeMarkers(layers); } return this; }, /** * Simply flags all parent clusters of the given markers as having a "dirty" icon. * @param layers Array(L.Marker)|Map(L.Marker) list of markers. * @private */ _flagParentsIconsNeedUpdate: function (layers) { var id, parent; // Assumes layers is an Array or an Object whose prototype is non-enumerable. for (id in layers) { // Flag parent clusters' icon as "dirty", all the way up. // Dumb process that flags multiple times upper parents, but still // much more efficient than trying to be smart and make short lists, // at least in the case of a hierarchy following a power law: // http://jsperf.com/flag-nodes-in-power-hierarchy/2 parent = layers[id].__parent; while (parent) { parent._iconNeedsUpdate = true; parent = parent.__parent; } } }, /** * Re-draws the icon of the supplied markers. * To be used in singleMarkerMode only. * @param layers Array(L.Marker)|Map(L.Marker) list of markers. * @private */ _refreshSingleMarkerModeMarkers: function (layers) { var id, layer; for (id in layers) { layer = layers[id]; // Make sure we do not override markers that do not belong to THIS group. if (this.hasLayer(layer)) { // Need to re-create the icon first, then re-draw the marker. layer.setIcon(this._overrideMarkerIcon(layer)); } } } }); L.Marker.include({ /** * Updates the given options in the marker's icon and refreshes the marker. * @param options map object of icon options. * @param directlyRefreshClusters boolean (optional) true to trigger * MCG.refreshClustersOf() right away with this single marker. * @returns {L.Marker} */ refreshIconOptions: function (options, directlyRefreshClusters) { var icon = this.options.icon; L.setOptions(icon, options); this.setIcon(icon); // Shortcut to refresh the associated MCG clusters right away. // To be used when refreshing a single marker. // Otherwise, better use MCG.refreshClusters() once at the end with // the list of modified markers. if (directlyRefreshClusters && this.__parent) { this.__parent._group.refreshClusters(this); } return this; } }); exports.MarkerClusterGroup = MarkerClusterGroup; exports.MarkerCluster = MarkerCluster; Object.defineProperty(exports, '__esModule', { value: true }); })); //# sourceMappingURL=leaflet.markercluster-src.js.map /***/ }), /***/ "../../node_modules/leaflet/dist/leaflet-src.js": /*!******************************************************!*\ !*** ../../node_modules/leaflet/dist/leaflet-src.js ***! \******************************************************/ /***/ (function(__unused_webpack_module, exports) { /* @preserve * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade */ (function (global, factory) { true ? factory(exports) : 0; })(this, (function (exports) { 'use strict'; var version = "1.9.4"; /* * @namespace Util * * Various utility functions, used by Leaflet internally. */ // @function extend(dest: Object, src?: Object): Object // Merges the properties of the `src` object (or multiple objects) into `dest` object and returns the latter. Has an `L.extend` shortcut. function extend(dest) { var i, j, len, src; for (j = 1, len = arguments.length; j < len; j++) { src = arguments[j]; for (i in src) { dest[i] = src[i]; } } return dest; } // @function create(proto: Object, properties?: Object): Object // Compatibility polyfill for [Object.create](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/create) var create$2 = Object.create || (function () { function F() {} return function (proto) { F.prototype = proto; return new F(); }; })(); // @function bind(fn: Function, …): Function // Returns a new function bound to the arguments passed, like [Function.prototype.bind](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). // Has a `L.bind()` shortcut. function bind(fn, obj) { var slice = Array.prototype.slice; if (fn.bind) { return fn.bind.apply(fn, slice.call(arguments, 1)); } var args = slice.call(arguments, 2); return function () { return fn.apply(obj, args.length ? args.concat(slice.call(arguments)) : arguments); }; } // @property lastId: Number // Last unique ID used by [`stamp()`](#util-stamp) var lastId = 0; // @function stamp(obj: Object): Number // Returns the unique ID of an object, assigning it one if it doesn't have it. function stamp(obj) { if (!('_leaflet_id' in obj)) { obj['_leaflet_id'] = ++lastId; } return obj._leaflet_id; } // @function throttle(fn: Function, time: Number, context: Object): Function // Returns a function which executes function `fn` with the given scope `context` // (so that the `this` keyword refers to `context` inside `fn`'s code). The function // `fn` will be called no more than one time per given amount of `time`. The arguments // received by the bound function will be any arguments passed when binding the // function, followed by any arguments passed when invoking the bound function. // Has an `L.throttle` shortcut. function throttle(fn, time, context) { var lock, args, wrapperFn, later; later = function () { // reset lock and call if queued lock = false; if (args) { wrapperFn.apply(context, args); args = false; } }; wrapperFn = function () { if (lock) { // called too soon, queue to call later args = arguments; } else { // call and lock until later fn.apply(context, arguments); setTimeout(later, time); lock = true; } }; return wrapperFn; } // @function wrapNum(num: Number, range: Number[], includeMax?: Boolean): Number // Returns the number `num` modulo `range` in such a way so it lies within // `range[0]` and `range[1]`. The returned value will be always smaller than // `range[1]` unless `includeMax` is set to `true`. function wrapNum(x, range, includeMax) { var max = range[1], min = range[0], d = max - min; return x === max && includeMax ? x : ((x - min) % d + d) % d + min; } // @function falseFn(): Function // Returns a function which always returns `false`. function falseFn() { return false; } // @function formatNum(num: Number, precision?: Number|false): Number // Returns the number `num` rounded with specified `precision`. // The default `precision` value is 6 decimal places. // `false` can be passed to skip any processing (can be useful to avoid round-off errors). function formatNum(num, precision) { if (precision === false) { return num; } var pow = Math.pow(10, precision === undefined ? 6 : precision); return Math.round(num * pow) / pow; } // @function trim(str: String): String // Compatibility polyfill for [String.prototype.trim](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim) function trim(str) { return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); } // @function splitWords(str: String): String[] // Trims and splits the string on whitespace and returns the array of parts. function splitWords(str) { return trim(str).split(/\s+/); } // @function setOptions(obj: Object, options: Object): Object // Merges the given properties to the `options` of the `obj` object, returning the resulting options. See `Class options`. Has an `L.setOptions` shortcut. function setOptions(obj, options) { if (!Object.prototype.hasOwnProperty.call(obj, 'options')) { obj.options = obj.options ? create$2(obj.options) : {}; } for (var i in options) { obj.options[i] = options[i]; } return obj.options; } // @function getParamString(obj: Object, existingUrl?: String, uppercase?: Boolean): String // Converts an object into a parameter URL string, e.g. `{a: "foo", b: "bar"}` // translates to `'?a=foo&b=bar'`. If `existingUrl` is set, the parameters will // be appended at the end. If `uppercase` is `true`, the parameter names will // be uppercased (e.g. `'?A=foo&B=bar'`) function getParamString(obj, existingUrl, uppercase) { var params = []; for (var i in obj) { params.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i])); } return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&'); } var templateRe = /\{ *([\w_ -]+) *\}/g; // @function template(str: String, data: Object): String // Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'` // and a data object like `{a: 'foo', b: 'bar'}`, returns evaluated string // `('Hello foo, bar')`. You can also specify functions instead of strings for // data values — they will be evaluated passing `data` as an argument. function template(str, data) { return str.replace(templateRe, function (str, key) { var value = data[key]; if (value === undefined) { throw new Error('No value provided for variable ' + str); } else if (typeof value === 'function') { value = value(data); } return value; }); } // @function isArray(obj): Boolean // Compatibility polyfill for [Array.isArray](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray) var isArray = Array.isArray || function (obj) { return (Object.prototype.toString.call(obj) === '[object Array]'); }; // @function indexOf(array: Array, el: Object): Number // Compatibility polyfill for [Array.prototype.indexOf](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) function indexOf(array, el) { for (var i = 0; i < array.length; i++) { if (array[i] === el) { return i; } } return -1; } // @property emptyImageUrl: String // Data URI string containing a base64-encoded empty GIF image. // Used as a hack to free memory from unused images on WebKit-powered // mobile devices (by setting image `src` to this string). var emptyImageUrl = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='; // inspired by https://paulirish.com/2011/requestanimationframe-for-smart-animating/ function getPrefixed(name) { return window['webkit' + name] || window['moz' + name] || window['ms' + name]; } var lastTime = 0; // fallback for IE 7-8 function timeoutDefer(fn) { var time = +new Date(), timeToCall = Math.max(0, 16 - (time - lastTime)); lastTime = time + timeToCall; return window.setTimeout(fn, timeToCall); } var requestFn = window.requestAnimationFrame || getPrefixed('RequestAnimationFrame') || timeoutDefer; var cancelFn = window.cancelAnimationFrame || getPrefixed('CancelAnimationFrame') || getPrefixed('CancelRequestAnimationFrame') || function (id) { window.clearTimeout(id); }; // @function requestAnimFrame(fn: Function, context?: Object, immediate?: Boolean): Number // Schedules `fn` to be executed when the browser repaints. `fn` is bound to // `context` if given. When `immediate` is set, `fn` is called immediately if // the browser doesn't have native support for // [`window.requestAnimationFrame`](https://developer.mozilla.org/docs/Web/API/window/requestAnimationFrame), // otherwise it's delayed. Returns a request ID that can be used to cancel the request. function requestAnimFrame(fn, context, immediate) { if (immediate && requestFn === timeoutDefer) { fn.call(context); } else { return requestFn.call(window, bind(fn, context)); } } // @function cancelAnimFrame(id: Number): undefined // Cancels a previous `requestAnimFrame`. See also [window.cancelAnimationFrame](https://developer.mozilla.org/docs/Web/API/window/cancelAnimationFrame). function cancelAnimFrame(id) { if (id) { cancelFn.call(window, id); } } var Util = { __proto__: null, extend: extend, create: create$2, bind: bind, get lastId () { return lastId; }, stamp: stamp, throttle: throttle, wrapNum: wrapNum, falseFn: falseFn, formatNum: formatNum, trim: trim, splitWords: splitWords, setOptions: setOptions, getParamString: getParamString, template: template, isArray: isArray, indexOf: indexOf, emptyImageUrl: emptyImageUrl, requestFn: requestFn, cancelFn: cancelFn, requestAnimFrame: requestAnimFrame, cancelAnimFrame: cancelAnimFrame }; // @class Class // @aka L.Class // @section // @uninheritable // Thanks to John Resig and Dean Edwards for inspiration! function Class() {} Class.extend = function (props) { // @function extend(props: Object): Function // [Extends the current class](#class-inheritance) given the properties to be included. // Returns a Javascript function that is a class constructor (to be called with `new`). var NewClass = function () { setOptions(this); // call the constructor if (this.initialize) { this.initialize.apply(this, arguments); } // call all constructor hooks this.callInitHooks(); }; var parentProto = NewClass.__super__ = this.prototype; var proto = create$2(parentProto); proto.constructor = NewClass; NewClass.prototype = proto; // inherit parent's statics for (var i in this) { if (Object.prototype.hasOwnProperty.call(this, i) && i !== 'prototype' && i !== '__super__') { NewClass[i] = this[i]; } } // mix static properties into the class if (props.statics) { extend(NewClass, props.statics); } // mix includes into the prototype if (props.includes) { checkDeprecatedMixinEvents(props.includes); extend.apply(null, [proto].concat(props.includes)); } // mix given properties into the prototype extend(proto, props); delete proto.statics; delete proto.includes; // merge options if (proto.options) { proto.options = parentProto.options ? create$2(parentProto.options) : {}; extend(proto.options, props.options); } proto._initHooks = []; // add method for calling all hooks proto.callInitHooks = function () { if (this._initHooksCalled) { return; } if (parentProto.callInitHooks) { parentProto.callInitHooks.call(this); } this._initHooksCalled = true; for (var i = 0, len = proto._initHooks.length; i < len; i++) { proto._initHooks[i].call(this); } }; return NewClass; }; // @function include(properties: Object): this // [Includes a mixin](#class-includes) into the current class. Class.include = function (props) { var parentOptions = this.prototype.options; extend(this.prototype, props); if (props.options) { this.prototype.options = parentOptions; this.mergeOptions(props.options); } return this; }; // @function mergeOptions(options: Object): this // [Merges `options`](#class-options) into the defaults of the class. Class.mergeOptions = function (options) { extend(this.prototype.options, options); return this; }; // @function addInitHook(fn: Function): this // Adds a [constructor hook](#class-constructor-hooks) to the class. Class.addInitHook = function (fn) { // (Function) || (String, args...) var args = Array.prototype.slice.call(arguments, 1); var init = typeof fn === 'function' ? fn : function () { this[fn].apply(this, args); }; this.prototype._initHooks = this.prototype._initHooks || []; this.prototype._initHooks.push(init); return this; }; function checkDeprecatedMixinEvents(includes) { /* global L: true */ if (typeof L === 'undefined' || !L || !L.Mixin) { return; } includes = isArray(includes) ? includes : [includes]; for (var i = 0; i < includes.length; i++) { if (includes[i] === L.Mixin.Events) { console.warn('Deprecated include of L.Mixin.Events: ' + 'this property will be removed in future releases, ' + 'please inherit from L.Evented instead.', new Error().stack); } } } /* * @class Evented * @aka L.Evented * @inherits Class * * A set of methods shared between event-powered classes (like `Map` and `Marker`). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire `'click'` event). * * @example * * ```js * map.on('click', function(e) { * alert(e.latlng); * } ); * ``` * * Leaflet deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function: * * ```js * function onClick(e) { ... } * * map.on('click', onClick); * map.off('click', onClick); * ``` */ var Events = { /* @method on(type: String, fn: Function, context?: Object): this * Adds a listener function (`fn`) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. `'click dblclick'`). * * @alternative * @method on(eventMap: Object): this * Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}` */ on: function (types, fn, context) { // types can be a map of types/handlers if (typeof types === 'object') { for (var type in types) { // we don't process space-separated events here for performance; // it's a hot path since Layer uses the on(obj) syntax this._on(type, types[type], fn); } } else { // types can be a string of space-separated words types = splitWords(types); for (var i = 0, len = types.length; i < len; i++) { this._on(types[i], fn, context); } } return this; }, /* @method off(type: String, fn?: Function, context?: Object): this * Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to `on`, you must pass the same context to `off` in order to remove the listener. * * @alternative * @method off(eventMap: Object): this * Removes a set of type/listener pairs. * * @alternative * @method off: this * Removes all listeners to all events on the object. This includes implicitly attached events. */ off: function (types, fn, context) { if (!arguments.length) { // clear all listeners if called without arguments delete this._events; } else if (typeof types === 'object') { for (var type in types) { this._off(type, types[type], fn); } } else { types = splitWords(types); var removeAll = arguments.length === 1; for (var i = 0, len = types.length; i < len; i++) { if (removeAll) { this._off(types[i]); } else { this._off(types[i], fn, context); } } } return this; }, // attach listener (without syntactic sugar now) _on: function (type, fn, context, _once) { if (typeof fn !== 'function') { console.warn('wrong listener type: ' + typeof fn); return; } // check if fn already there if (this._listens(type, fn, context) !== false) { return; } if (context === this) { // Less memory footprint. context = undefined; } var newListener = {fn: fn, ctx: context}; if (_once) { newListener.once = true; } this._events = this._events || {}; this._events[type] = this._events[type] || []; this._events[type].push(newListener); }, _off: function (type, fn, context) { var listeners, i, len; if (!this._events) { return; } listeners = this._events[type]; if (!listeners) { return; } if (arguments.length === 1) { // remove all if (this._firingCount) { // Set all removed listeners to noop // so they are not called if remove happens in fire for (i = 0, len = listeners.length; i < len; i++) { listeners[i].fn = falseFn; } } // clear all listeners for a type if function isn't specified delete this._events[type]; return; } if (typeof fn !== 'function') { console.warn('wrong listener type: ' + typeof fn); return; } // find fn and remove it var index = this._listens(type, fn, context); if (index !== false) { var listener = listeners[index]; if (this._firingCount) { // set the removed listener to noop so that's not called if remove happens in fire listener.fn = falseFn; /* copy array in case events are being fired */ this._events[type] = listeners = listeners.slice(); } listeners.splice(index, 1); } }, // @method fire(type: String, data?: Object, propagate?: Boolean): this // Fires an event of the specified type. You can optionally provide a data // object — the first argument of the listener function will contain its // properties. The event can optionally be propagated to event parents. fire: function (type, data, propagate) { if (!this.listens(type, propagate)) { return this; } var event = extend({}, data, { type: type, target: this, sourceTarget: data && data.sourceTarget || this }); if (this._events) { var listeners = this._events[type]; if (listeners) { this._firingCount = (this._firingCount + 1) || 1; for (var i = 0, len = listeners.length; i < len; i++) { var l = listeners[i]; // off overwrites l.fn, so we need to copy fn to a var var fn = l.fn; if (l.once) { this.off(type, fn, l.ctx); } fn.call(l.ctx || this, event); } this._firingCount--; } } if (propagate) { // propagate the event to parents (set with addEventParent) this._propagateEvent(event); } return this; }, // @method listens(type: String, propagate?: Boolean): Boolean // @method listens(type: String, fn: Function, context?: Object, propagate?: Boolean): Boolean // Returns `true` if a particular event type has any listeners attached to it. // The verification can optionally be propagated, it will return `true` if parents have the listener attached to it. listens: function (type, fn, context, propagate) { if (typeof type !== 'string') { console.warn('"string" type argument expected'); } // we don't overwrite the input `fn` value, because we need to use it for propagation var _fn = fn; if (typeof fn !== 'function') { propagate = !!fn; _fn = undefined; context = undefined; } var listeners = this._events && this._events[type]; if (listeners && listeners.length) { if (this._listens(type, _fn, context) !== false) { return true; } } if (propagate) { // also check parents for listeners if event propagates for (var id in this._eventParents) { if (this._eventParents[id].listens(type, fn, context, propagate)) { return true; } } } return false; }, // returns the index (number) or false _listens: function (type, fn, context) { if (!this._events) { return false; } var listeners = this._events[type] || []; if (!fn) { return !!listeners.length; } if (context === this) { // Less memory footprint. context = undefined; } for (var i = 0, len = listeners.length; i < len; i++) { if (listeners[i].fn === fn && listeners[i].ctx === context) { return i; } } return false; }, // @method once(…): this // Behaves as [`on(…)`](#evented-on), except the listener will only get fired once and then removed. once: function (types, fn, context) { // types can be a map of types/handlers if (typeof types === 'object') { for (var type in types) { // we don't process space-separated events here for performance; // it's a hot path since Layer uses the on(obj) syntax this._on(type, types[type], fn, true); } } else { // types can be a string of space-separated words types = splitWords(types); for (var i = 0, len = types.length; i < len; i++) { this._on(types[i], fn, context, true); } } return this; }, // @method addEventParent(obj: Evented): this // Adds an event parent - an `Evented` that will receive propagated events addEventParent: function (obj) { this._eventParents = this._eventParents || {}; this._eventParents[stamp(obj)] = obj; return this; }, // @method removeEventParent(obj: Evented): this // Removes an event parent, so it will stop receiving propagated events removeEventParent: function (obj) { if (this._eventParents) { delete this._eventParents[stamp(obj)]; } return this; }, _propagateEvent: function (e) { for (var id in this._eventParents) { this._eventParents[id].fire(e.type, extend({ layer: e.target, propagatedFrom: e.target }, e), true); } } }; // aliases; we should ditch those eventually // @method addEventListener(…): this // Alias to [`on(…)`](#evented-on) Events.addEventListener = Events.on; // @method removeEventListener(…): this // Alias to [`off(…)`](#evented-off) // @method clearAllEventListeners(…): this // Alias to [`off()`](#evented-off) Events.removeEventListener = Events.clearAllEventListeners = Events.off; // @method addOneTimeEventListener(…): this // Alias to [`once(…)`](#evented-once) Events.addOneTimeEventListener = Events.once; // @method fireEvent(…): this // Alias to [`fire(…)`](#evented-fire) Events.fireEvent = Events.fire; // @method hasEventListeners(…): Boolean // Alias to [`listens(…)`](#evented-listens) Events.hasEventListeners = Events.listens; var Evented = Class.extend(Events); /* * @class Point * @aka L.Point * * Represents a point with `x` and `y` coordinates in pixels. * * @example * * ```js * var point = L.point(200, 300); * ``` * * All Leaflet methods and options that accept `Point` objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent: * * ```js * map.panBy([200, 300]); * map.panBy(L.point(200, 300)); * ``` * * Note that `Point` does not inherit from Leaflet's `Class` object, * which means new classes can't inherit from it, and new methods * can't be added to it with the `include` function. */ function Point(x, y, round) { // @property x: Number; The `x` coordinate of the point this.x = (round ? Math.round(x) : x); // @property y: Number; The `y` coordinate of the point this.y = (round ? Math.round(y) : y); } var trunc = Math.trunc || function (v) { return v > 0 ? Math.floor(v) : Math.ceil(v); }; Point.prototype = { // @method clone(): Point // Returns a copy of the current point. clone: function () { return new Point(this.x, this.y); }, // @method add(otherPoint: Point): Point // Returns the result of addition of the current and the given points. add: function (point) { // non-destructive, returns a new point return this.clone()._add(toPoint(point)); }, _add: function (point) { // destructive, used directly for performance in situations where it's safe to modify existing point this.x += point.x; this.y += point.y; return this; }, // @method subtract(otherPoint: Point): Point // Returns the result of subtraction of the given point from the current. subtract: function (point) { return this.clone()._subtract(toPoint(point)); }, _subtract: function (point) { this.x -= point.x; this.y -= point.y; return this; }, // @method divideBy(num: Number): Point // Returns the result of division of the current point by the given number. divideBy: function (num) { return this.clone()._divideBy(num); }, _divideBy: function (num) { this.x /= num; this.y /= num; return this; }, // @method multiplyBy(num: Number): Point // Returns the result of multiplication of the current point by the given number. multiplyBy: function (num) { return this.clone()._multiplyBy(num); }, _multiplyBy: function (num) { this.x *= num; this.y *= num; return this; }, // @method scaleBy(scale: Point): Point // Multiply each coordinate of the current point by each coordinate of // `scale`. In linear algebra terms, multiply the point by the // [scaling matrix](https://en.wikipedia.org/wiki/Scaling_%28geometry%29#Matrix_representation) // defined by `scale`. scaleBy: function (point) { return new Point(this.x * point.x, this.y * point.y); }, // @method unscaleBy(scale: Point): Point // Inverse of `scaleBy`. Divide each coordinate of the current point by // each coordinate of `scale`. unscaleBy: function (point) { return new Point(this.x / point.x, this.y / point.y); }, // @method round(): Point // Returns a copy of the current point with rounded coordinates. round: function () { return this.clone()._round(); }, _round: function () { this.x = Math.round(this.x); this.y = Math.round(this.y); return this; }, // @method floor(): Point // Returns a copy of the current point with floored coordinates (rounded down). floor: function () { return this.clone()._floor(); }, _floor: function () { this.x = Math.floor(this.x); this.y = Math.floor(this.y); return this; }, // @method ceil(): Point // Returns a copy of the current point with ceiled coordinates (rounded up). ceil: function () { return this.clone()._ceil(); }, _ceil: function () { this.x = Math.ceil(this.x); this.y = Math.ceil(this.y); return this; }, // @method trunc(): Point // Returns a copy of the current point with truncated coordinates (rounded towards zero). trunc: function () { return this.clone()._trunc(); }, _trunc: function () { this.x = trunc(this.x); this.y = trunc(this.y); return this; }, // @method distanceTo(otherPoint: Point): Number // Returns the cartesian distance between the current and the given points. distanceTo: function (point) { point = toPoint(point); var x = point.x - this.x, y = point.y - this.y; return Math.sqrt(x * x + y * y); }, // @method equals(otherPoint: Point): Boolean // Returns `true` if the given point has the same coordinates. equals: function (point) { point = toPoint(point); return point.x === this.x && point.y === this.y; }, // @method contains(otherPoint: Point): Boolean // Returns `true` if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). contains: function (point) { point = toPoint(point); return Math.abs(point.x) <= Math.abs(this.x) && Math.abs(point.y) <= Math.abs(this.y); }, // @method toString(): String // Returns a string representation of the point for debugging purposes. toString: function () { return 'Point(' + formatNum(this.x) + ', ' + formatNum(this.y) + ')'; } }; // @factory L.point(x: Number, y: Number, round?: Boolean) // Creates a Point object with the given `x` and `y` coordinates. If optional `round` is set to true, rounds the `x` and `y` values. // @alternative // @factory L.point(coords: Number[]) // Expects an array of the form `[x, y]` instead. // @alternative // @factory L.point(coords: Object) // Expects a plain object of the form `{x: Number, y: Number}` instead. function toPoint(x, y, round) { if (x instanceof Point) { return x; } if (isArray(x)) { return new Point(x[0], x[1]); } if (x === undefined || x === null) { return x; } if (typeof x === 'object' && 'x' in x && 'y' in x) { return new Point(x.x, x.y); } return new Point(x, y, round); } /* * @class Bounds * @aka L.Bounds * * Represents a rectangular area in pixel coordinates. * * @example * * ```js * var p1 = L.point(10, 10), * p2 = L.point(40, 60), * bounds = L.bounds(p1, p2); * ``` * * All Leaflet methods that accept `Bounds` objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this: * * ```js * otherBounds.intersects([[10, 10], [40, 60]]); * ``` * * Note that `Bounds` does not inherit from Leaflet's `Class` object, * which means new classes can't inherit from it, and new methods * can't be added to it with the `include` function. */ function Bounds(a, b) { if (!a) { return; } var points = b ? [a, b] : a; for (var i = 0, len = points.length; i < len; i++) { this.extend(points[i]); } } Bounds.prototype = { // @method extend(point: Point): this // Extends the bounds to contain the given point. // @alternative // @method extend(otherBounds: Bounds): this // Extend the bounds to contain the given bounds extend: function (obj) { var min2, max2; if (!obj) { return this; } if (obj instanceof Point || typeof obj[0] === 'number' || 'x' in obj) { min2 = max2 = toPoint(obj); } else { obj = toBounds(obj); min2 = obj.min; max2 = obj.max; if (!min2 || !max2) { return this; } } // @property min: Point // The top left corner of the rectangle. // @property max: Point // The bottom right corner of the rectangle. if (!this.min && !this.max) { this.min = min2.clone(); this.max = max2.clone(); } else { this.min.x = Math.min(min2.x, this.min.x); this.max.x = Math.max(max2.x, this.max.x); this.min.y = Math.min(min2.y, this.min.y); this.max.y = Math.max(max2.y, this.max.y); } return this; }, // @method getCenter(round?: Boolean): Point // Returns the center point of the bounds. getCenter: function (round) { return toPoint( (this.min.x + this.max.x) / 2, (this.min.y + this.max.y) / 2, round); }, // @method getBottomLeft(): Point // Returns the bottom-left point of the bounds. getBottomLeft: function () { return toPoint(this.min.x, this.max.y); }, // @method getTopRight(): Point // Returns the top-right point of the bounds. getTopRight: function () { // -> Point return toPoint(this.max.x, this.min.y); }, // @method getTopLeft(): Point // Returns the top-left point of the bounds (i.e. [`this.min`](#bounds-min)). getTopLeft: function () { return this.min; // left, top }, // @method getBottomRight(): Point // Returns the bottom-right point of the bounds (i.e. [`this.max`](#bounds-max)). getBottomRight: function () { return this.max; // right, bottom }, // @method getSize(): Point // Returns the size of the given bounds getSize: function () { return this.max.subtract(this.min); }, // @method contains(otherBounds: Bounds): Boolean // Returns `true` if the rectangle contains the given one. // @alternative // @method contains(point: Point): Boolean // Returns `true` if the rectangle contains the given point. contains: function (obj) { var min, max; if (typeof obj[0] === 'number' || obj instanceof Point) { obj = toPoint(obj); } else { obj = toBounds(obj); } if (obj instanceof Bounds) { min = obj.min; max = obj.max; } else { min = max = obj; } return (min.x >= this.min.x) && (max.x <= this.max.x) && (min.y >= this.min.y) && (max.y <= this.max.y); }, // @method intersects(otherBounds: Bounds): Boolean // Returns `true` if the rectangle intersects the given bounds. Two bounds // intersect if they have at least one point in common. intersects: function (bounds) { // (Bounds) -> Boolean bounds = toBounds(bounds); var min = this.min, max = this.max, min2 = bounds.min, max2 = bounds.max, xIntersects = (max2.x >= min.x) && (min2.x <= max.x), yIntersects = (max2.y >= min.y) && (min2.y <= max.y); return xIntersects && yIntersects; }, // @method overlaps(otherBounds: Bounds): Boolean // Returns `true` if the rectangle overlaps the given bounds. Two bounds // overlap if their intersection is an area. overlaps: function (bounds) { // (Bounds) -> Boolean bounds = toBounds(bounds); var min = this.min, max = this.max, min2 = bounds.min, max2 = bounds.max, xOverlaps = (max2.x > min.x) && (min2.x < max.x), yOverlaps = (max2.y > min.y) && (min2.y < max.y); return xOverlaps && yOverlaps; }, // @method isValid(): Boolean // Returns `true` if the bounds are properly initialized. isValid: function () { return !!(this.min && this.max); }, // @method pad(bufferRatio: Number): Bounds // Returns bounds created by extending or retracting the current bounds by a given ratio in each direction. // For example, a ratio of 0.5 extends the bounds by 50% in each direction. // Negative values will retract the bounds. pad: function (bufferRatio) { var min = this.min, max = this.max, heightBuffer = Math.abs(min.x - max.x) * bufferRatio, widthBuffer = Math.abs(min.y - max.y) * bufferRatio; return toBounds( toPoint(min.x - heightBuffer, min.y - widthBuffer), toPoint(max.x + heightBuffer, max.y + widthBuffer)); }, // @method equals(otherBounds: Bounds): Boolean // Returns `true` if the rectangle is equivalent to the given bounds. equals: function (bounds) { if (!bounds) { return false; } bounds = toBounds(bounds); return this.min.equals(bounds.getTopLeft()) && this.max.equals(bounds.getBottomRight()); }, }; // @factory L.bounds(corner1: Point, corner2: Point) // Creates a Bounds object from two corners coordinate pairs. // @alternative // @factory L.bounds(points: Point[]) // Creates a Bounds object from the given array of points. function toBounds(a, b) { if (!a || a instanceof Bounds) { return a; } return new Bounds(a, b); } /* * @class LatLngBounds * @aka L.LatLngBounds * * Represents a rectangular geographical area on a map. * * @example * * ```js * var corner1 = L.latLng(40.712, -74.227), * corner2 = L.latLng(40.774, -74.125), * bounds = L.latLngBounds(corner1, corner2); * ``` * * All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this: * * ```js * map.fitBounds([ * [40.712, -74.227], * [40.774, -74.125] * ]); * ``` * * Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range. * * Note that `LatLngBounds` does not inherit from Leaflet's `Class` object, * which means new classes can't inherit from it, and new methods * can't be added to it with the `include` function. */ function LatLngBounds(corner1, corner2) { // (LatLng, LatLng) or (LatLng[]) if (!corner1) { return; } var latlngs = corner2 ? [corner1, corner2] : corner1; for (var i = 0, len = latlngs.length; i < len; i++) { this.extend(latlngs[i]); } } LatLngBounds.prototype = { // @method extend(latlng: LatLng): this // Extend the bounds to contain the given point // @alternative // @method extend(otherBounds: LatLngBounds): this // Extend the bounds to contain the given bounds extend: function (obj) { var sw = this._southWest, ne = this._northEast, sw2, ne2; if (obj instanceof LatLng) { sw2 = obj; ne2 = obj; } else if (obj instanceof LatLngBounds) { sw2 = obj._southWest; ne2 = obj._northEast; if (!sw2 || !ne2) { return this; } } else { return obj ? this.extend(toLatLng(obj) || toLatLngBounds(obj)) : this; } if (!sw && !ne) { this._southWest = new LatLng(sw2.lat, sw2.lng); this._northEast = new LatLng(ne2.lat, ne2.lng); } else { sw.lat = Math.min(sw2.lat, sw.lat); sw.lng = Math.min(sw2.lng, sw.lng); ne.lat = Math.max(ne2.lat, ne.lat); ne.lng = Math.max(ne2.lng, ne.lng); } return this; }, // @method pad(bufferRatio: Number): LatLngBounds // Returns bounds created by extending or retracting the current bounds by a given ratio in each direction. // For example, a ratio of 0.5 extends the bounds by 50% in each direction. // Negative values will retract the bounds. pad: function (bufferRatio) { var sw = this._southWest, ne = this._northEast, heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio, widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio; return new LatLngBounds( new LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer), new LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer)); }, // @method getCenter(): LatLng // Returns the center point of the bounds. getCenter: function () { return new LatLng( (this._southWest.lat + this._northEast.lat) / 2, (this._southWest.lng + this._northEast.lng) / 2); }, // @method getSouthWest(): LatLng // Returns the south-west point of the bounds. getSouthWest: function () { return this._southWest; }, // @method getNorthEast(): LatLng // Returns the north-east point of the bounds. getNorthEast: function () { return this._northEast; }, // @method getNorthWest(): LatLng // Returns the north-west point of the bounds. getNorthWest: function () { return new LatLng(this.getNorth(), this.getWest()); }, // @method getSouthEast(): LatLng // Returns the south-east point of the bounds. getSouthEast: function () { return new LatLng(this.getSouth(), this.getEast()); }, // @method getWest(): Number // Returns the west longitude of the bounds getWest: function () { return this._southWest.lng; }, // @method getSouth(): Number // Returns the south latitude of the bounds getSouth: function () { return this._southWest.lat; }, // @method getEast(): Number // Returns the east longitude of the bounds getEast: function () { return this._northEast.lng; }, // @method getNorth(): Number // Returns the north latitude of the bounds getNorth: function () { return this._northEast.lat; }, // @method contains(otherBounds: LatLngBounds): Boolean // Returns `true` if the rectangle contains the given one. // @alternative // @method contains (latlng: LatLng): Boolean // Returns `true` if the rectangle contains the given point. contains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean if (typeof obj[0] === 'number' || obj instanceof LatLng || 'lat' in obj) { obj = toLatLng(obj); } else { obj = toLatLngBounds(obj); } var sw = this._southWest, ne = this._northEast, sw2, ne2; if (obj instanceof LatLngBounds) { sw2 = obj.getSouthWest(); ne2 = obj.getNorthEast(); } else { sw2 = ne2 = obj; } return (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) && (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng); }, // @method intersects(otherBounds: LatLngBounds): Boolean // Returns `true` if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common. intersects: function (bounds) { bounds = toLatLngBounds(bounds); var sw = this._southWest, ne = this._northEast, sw2 = bounds.getSouthWest(), ne2 = bounds.getNorthEast(), latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat), lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng); return latIntersects && lngIntersects; }, // @method overlaps(otherBounds: LatLngBounds): Boolean // Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area. overlaps: function (bounds) { bounds = toLatLngBounds(bounds); var sw = this._southWest, ne = this._northEast, sw2 = bounds.getSouthWest(), ne2 = bounds.getNorthEast(), latOverlaps = (ne2.lat > sw.lat) && (sw2.lat < ne.lat), lngOverlaps = (ne2.lng > sw.lng) && (sw2.lng < ne.lng); return latOverlaps && lngOverlaps; }, // @method toBBoxString(): String // Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data. toBBoxString: function () { return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(','); }, // @method equals(otherBounds: LatLngBounds, maxMargin?: Number): Boolean // Returns `true` if the rectangle is equivalent (within a small margin of error) to the given bounds. The margin of error can be overridden by setting `maxMargin` to a small number. equals: function (bounds, maxMargin) { if (!bounds) { return false; } bounds = toLatLngBounds(bounds); return this._southWest.equals(bounds.getSouthWest(), maxMargin) && this._northEast.equals(bounds.getNorthEast(), maxMargin); }, // @method isValid(): Boolean // Returns `true` if the bounds are properly initialized. isValid: function () { return !!(this._southWest && this._northEast); } }; // TODO International date line? // @factory L.latLngBounds(corner1: LatLng, corner2: LatLng) // Creates a `LatLngBounds` object by defining two diagonally opposite corners of the rectangle. // @alternative // @factory L.latLngBounds(latlngs: LatLng[]) // Creates a `LatLngBounds` object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with [`fitBounds`](#map-fitbounds). function toLatLngBounds(a, b) { if (a instanceof LatLngBounds) { return a; } return new LatLngBounds(a, b); } /* @class LatLng * @aka L.LatLng * * Represents a geographical point with a certain latitude and longitude. * * @example * * ``` * var latlng = L.latLng(50.5, 30.5); * ``` * * All Leaflet methods that accept LatLng objects also accept them in a simple Array form and simple object form (unless noted otherwise), so these lines are equivalent: * * ``` * map.panTo([50, 30]); * map.panTo({lon: 30, lat: 50}); * map.panTo({lat: 50, lng: 30}); * map.panTo(L.latLng(50, 30)); * ``` * * Note that `LatLng` does not inherit from Leaflet's `Class` object, * which means new classes can't inherit from it, and new methods * can't be added to it with the `include` function. */ function LatLng(lat, lng, alt) { if (isNaN(lat) || isNaN(lng)) { throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')'); } // @property lat: Number // Latitude in degrees this.lat = +lat; // @property lng: Number // Longitude in degrees this.lng = +lng; // @property alt: Number // Altitude in meters (optional) if (alt !== undefined) { this.alt = +alt; } } LatLng.prototype = { // @method equals(otherLatLng: LatLng, maxMargin?: Number): Boolean // Returns `true` if the given `LatLng` point is at the same position (within a small margin of error). The margin of error can be overridden by setting `maxMargin` to a small number. equals: function (obj, maxMargin) { if (!obj) { return false; } obj = toLatLng(obj); var margin = Math.max( Math.abs(this.lat - obj.lat), Math.abs(this.lng - obj.lng)); return margin <= (maxMargin === undefined ? 1.0E-9 : maxMargin); }, // @method toString(): String // Returns a string representation of the point (for debugging purposes). toString: function (precision) { return 'LatLng(' + formatNum(this.lat, precision) + ', ' + formatNum(this.lng, precision) + ')'; }, // @method distanceTo(otherLatLng: LatLng): Number // Returns the distance (in meters) to the given `LatLng` calculated using the [Spherical Law of Cosines](https://en.wikipedia.org/wiki/Spherical_law_of_cosines). distanceTo: function (other) { return Earth.distance(this, toLatLng(other)); }, // @method wrap(): LatLng // Returns a new `LatLng` object with the longitude wrapped so it's always between -180 and +180 degrees. wrap: function () { return Earth.wrapLatLng(this); }, // @method toBounds(sizeInMeters: Number): LatLngBounds // Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2` meters apart from the `LatLng`. toBounds: function (sizeInMeters) { var latAccuracy = 180 * sizeInMeters / 40075017, lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat); return toLatLngBounds( [this.lat - latAccuracy, this.lng - lngAccuracy], [this.lat + latAccuracy, this.lng + lngAccuracy]); }, clone: function () { return new LatLng(this.lat, this.lng, this.alt); } }; // @factory L.latLng(latitude: Number, longitude: Number, altitude?: Number): LatLng // Creates an object representing a geographical point with the given latitude and longitude (and optionally altitude). // @alternative // @factory L.latLng(coords: Array): LatLng // Expects an array of the form `[Number, Number]` or `[Number, Number, Number]` instead. // @alternative // @factory L.latLng(coords: Object): LatLng // Expects an plain object of the form `{lat: Number, lng: Number}` or `{lat: Number, lng: Number, alt: Number}` instead. function toLatLng(a, b, c) { if (a instanceof LatLng) { return a; } if (isArray(a) && typeof a[0] !== 'object') { if (a.length === 3) { return new LatLng(a[0], a[1], a[2]); } if (a.length === 2) { return new LatLng(a[0], a[1]); } return null; } if (a === undefined || a === null) { return a; } if (typeof a === 'object' && 'lat' in a) { return new LatLng(a.lat, 'lng' in a ? a.lng : a.lon, a.alt); } if (b === undefined) { return null; } return new LatLng(a, b, c); } /* * @namespace CRS * @crs L.CRS.Base * Object that defines coordinate reference systems for projecting * geographical points into pixel (screen) coordinates and back (and to * coordinates in other units for [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services). See * [spatial reference system](https://en.wikipedia.org/wiki/Spatial_reference_system). * * Leaflet defines the most usual CRSs by default. If you want to use a * CRS not defined by default, take a look at the * [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) plugin. * * Note that the CRS instances do not inherit from Leaflet's `Class` object, * and can't be instantiated. Also, new classes can't inherit from them, * and methods can't be added to them with the `include` function. */ var CRS = { // @method latLngToPoint(latlng: LatLng, zoom: Number): Point // Projects geographical coordinates into pixel coordinates for a given zoom. latLngToPoint: function (latlng, zoom) { var projectedPoint = this.projection.project(latlng), scale = this.scale(zoom); return this.transformation._transform(projectedPoint, scale); }, // @method pointToLatLng(point: Point, zoom: Number): LatLng // The inverse of `latLngToPoint`. Projects pixel coordinates on a given // zoom into geographical coordinates. pointToLatLng: function (point, zoom) { var scale = this.scale(zoom), untransformedPoint = this.transformation.untransform(point, scale); return this.projection.unproject(untransformedPoint); }, // @method project(latlng: LatLng): Point // Projects geographical coordinates into coordinates in units accepted for // this CRS (e.g. meters for EPSG:3857, for passing it to WMS services). project: function (latlng) { return this.projection.project(latlng); }, // @method unproject(point: Point): LatLng // Given a projected coordinate returns the corresponding LatLng. // The inverse of `project`. unproject: function (point) { return this.projection.unproject(point); }, // @method scale(zoom: Number): Number // Returns the scale used when transforming projected coordinates into // pixel coordinates for a particular zoom. For example, it returns // `256 * 2^zoom` for Mercator-based CRS. scale: function (zoom) { return 256 * Math.pow(2, zoom); }, // @method zoom(scale: Number): Number // Inverse of `scale()`, returns the zoom level corresponding to a scale // factor of `scale`. zoom: function (scale) { return Math.log(scale / 256) / Math.LN2; }, // @method getProjectedBounds(zoom: Number): Bounds // Returns the projection's bounds scaled and transformed for the provided `zoom`. getProjectedBounds: function (zoom) { if (this.infinite) { return null; } var b = this.projection.bounds, s = this.scale(zoom), min = this.transformation.transform(b.min, s), max = this.transformation.transform(b.max, s); return new Bounds(min, max); }, // @method distance(latlng1: LatLng, latlng2: LatLng): Number // Returns the distance between two geographical coordinates. // @property code: String // Standard code name of the CRS passed into WMS services (e.g. `'EPSG:3857'`) // // @property wrapLng: Number[] // An array of two numbers defining whether the longitude (horizontal) coordinate // axis wraps around a given range and how. Defaults to `[-180, 180]` in most // geographical CRSs. If `undefined`, the longitude axis does not wrap around. // // @property wrapLat: Number[] // Like `wrapLng`, but for the latitude (vertical) axis. // wrapLng: [min, max], // wrapLat: [min, max], // @property infinite: Boolean // If true, the coordinate space will be unbounded (infinite in both axes) infinite: false, // @method wrapLatLng(latlng: LatLng): LatLng // Returns a `LatLng` where lat and lng has been wrapped according to the // CRS's `wrapLat` and `wrapLng` properties, if they are outside the CRS's bounds. wrapLatLng: function (latlng) { var lng = this.wrapLng ? wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng, lat = this.wrapLat ? wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat, alt = latlng.alt; return new LatLng(lat, lng, alt); }, // @method wrapLatLngBounds(bounds: LatLngBounds): LatLngBounds // Returns a `LatLngBounds` with the same size as the given one, ensuring // that its center is within the CRS's bounds. // Only accepts actual `L.LatLngBounds` instances, not arrays. wrapLatLngBounds: function (bounds) { var center = bounds.getCenter(), newCenter = this.wrapLatLng(center), latShift = center.lat - newCenter.lat, lngShift = center.lng - newCenter.lng; if (latShift === 0 && lngShift === 0) { return bounds; } var sw = bounds.getSouthWest(), ne = bounds.getNorthEast(), newSw = new LatLng(sw.lat - latShift, sw.lng - lngShift), newNe = new LatLng(ne.lat - latShift, ne.lng - lngShift); return new LatLngBounds(newSw, newNe); } }; /* * @namespace CRS * @crs L.CRS.Earth * * Serves as the base for CRS that are global such that they cover the earth. * Can only be used as the base for other CRS and cannot be used directly, * since it does not have a `code`, `projection` or `transformation`. `distance()` returns * meters. */ var Earth = extend({}, CRS, { wrapLng: [-180, 180], // Mean Earth Radius, as recommended for use by // the International Union of Geodesy and Geophysics, // see https://rosettacode.org/wiki/Haversine_formula R: 6371000, // distance between two geographical points using spherical law of cosines approximation distance: function (latlng1, latlng2) { var rad = Math.PI / 180, lat1 = latlng1.lat * rad, lat2 = latlng2.lat * rad, sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2), sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2), a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon, c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); return this.R * c; } }); /* * @namespace Projection * @projection L.Projection.SphericalMercator * * Spherical Mercator projection — the most common projection for online maps, * used by almost all free and commercial tile providers. Assumes that Earth is * a sphere. Used by the `EPSG:3857` CRS. */ var earthRadius = 6378137; var SphericalMercator = { R: earthRadius, MAX_LATITUDE: 85.0511287798, project: function (latlng) { var d = Math.PI / 180, max = this.MAX_LATITUDE, lat = Math.max(Math.min(max, latlng.lat), -max), sin = Math.sin(lat * d); return new Point( this.R * latlng.lng * d, this.R * Math.log((1 + sin) / (1 - sin)) / 2); }, unproject: function (point) { var d = 180 / Math.PI; return new LatLng( (2 * Math.atan(Math.exp(point.y / this.R)) - (Math.PI / 2)) * d, point.x * d / this.R); }, bounds: (function () { var d = earthRadius * Math.PI; return new Bounds([-d, -d], [d, d]); })() }; /* * @class Transformation * @aka L.Transformation * * Represents an affine transformation: a set of coefficients `a`, `b`, `c`, `d` * for transforming a point of a form `(x, y)` into `(a*x + b, c*y + d)` and doing * the reverse. Used by Leaflet in its projections code. * * @example * * ```js * var transformation = L.transformation(2, 5, -1, 10), * p = L.point(1, 2), * p2 = transformation.transform(p), // L.point(7, 8) * p3 = transformation.untransform(p2); // L.point(1, 2) * ``` */ // factory new L.Transformation(a: Number, b: Number, c: Number, d: Number) // Creates a `Transformation` object with the given coefficients. function Transformation(a, b, c, d) { if (isArray(a)) { // use array properties this._a = a[0]; this._b = a[1]; this._c = a[2]; this._d = a[3]; return; } this._a = a; this._b = b; this._c = c; this._d = d; } Transformation.prototype = { // @method transform(point: Point, scale?: Number): Point // Returns a transformed point, optionally multiplied by the given scale. // Only accepts actual `L.Point` instances, not arrays. transform: function (point, scale) { // (Point, Number) -> Point return this._transform(point.clone(), scale); }, // destructive transform (faster) _transform: function (point, scale) { scale = scale || 1; point.x = scale * (this._a * point.x + this._b); point.y = scale * (this._c * point.y + this._d); return point; }, // @method untransform(point: Point, scale?: Number): Point // Returns the reverse transformation of the given point, optionally divided // by the given scale. Only accepts actual `L.Point` instances, not arrays. untransform: function (point, scale) { scale = scale || 1; return new Point( (point.x / scale - this._b) / this._a, (point.y / scale - this._d) / this._c); } }; // factory L.transformation(a: Number, b: Number, c: Number, d: Number) // @factory L.transformation(a: Number, b: Number, c: Number, d: Number) // Instantiates a Transformation object with the given coefficients. // @alternative // @factory L.transformation(coefficients: Array): Transformation // Expects an coefficients array of the form // `[a: Number, b: Number, c: Number, d: Number]`. function toTransformation(a, b, c, d) { return new Transformation(a, b, c, d); } /* * @namespace CRS * @crs L.CRS.EPSG3857 * * The most common CRS for online maps, used by almost all free and commercial * tile providers. Uses Spherical Mercator projection. Set in by default in * Map's `crs` option. */ var EPSG3857 = extend({}, Earth, { code: 'EPSG:3857', projection: SphericalMercator, transformation: (function () { var scale = 0.5 / (Math.PI * SphericalMercator.R); return toTransformation(scale, 0.5, -scale, 0.5); }()) }); var EPSG900913 = extend({}, EPSG3857, { code: 'EPSG:900913' }); // @namespace SVG; @section // There are several static functions which can be called without instantiating L.SVG: // @function create(name: String): SVGElement // Returns a instance of [SVGElement](https://developer.mozilla.org/docs/Web/API/SVGElement), // corresponding to the class name passed. For example, using 'line' will return // an instance of [SVGLineElement](https://developer.mozilla.org/docs/Web/API/SVGLineElement). function svgCreate(name) { return document.createElementNS('http://www.w3.org/2000/svg', name); } // @function pointsToPath(rings: Point[], closed: Boolean): String // Generates a SVG path string for multiple rings, with each ring turning // into "M..L..L.." instructions function pointsToPath(rings, closed) { var str = '', i, j, len, len2, points, p; for (i = 0, len = rings.length; i < len; i++) { points = rings[i]; for (j = 0, len2 = points.length; j < len2; j++) { p = points[j]; str += (j ? 'L' : 'M') + p.x + ' ' + p.y; } // closes the ring for polygons; "x" is VML syntax str += closed ? (Browser.svg ? 'z' : 'x') : ''; } // SVG complains about empty path strings return str || 'M0 0'; } /* * @namespace Browser * @aka L.Browser * * A namespace with static properties for browser/feature detection used by Leaflet internally. * * @example * * ```js * if (L.Browser.ielt9) { * alert('Upgrade your browser, dude!'); * } * ``` */ var style = document.documentElement.style; // @property ie: Boolean; `true` for all Internet Explorer versions (not Edge). var ie = 'ActiveXObject' in window; // @property ielt9: Boolean; `true` for Internet Explorer versions less than 9. var ielt9 = ie && !document.addEventListener; // @property edge: Boolean; `true` for the Edge web browser. var edge = 'msLaunchUri' in navigator && !('documentMode' in document); // @property webkit: Boolean; // `true` for webkit-based browsers like Chrome and Safari (including mobile versions). var webkit = userAgentContains('webkit'); // @property android: Boolean // **Deprecated.** `true` for any browser running on an Android platform. var android = userAgentContains('android'); // @property android23: Boolean; **Deprecated.** `true` for browsers running on Android 2 or Android 3. var android23 = userAgentContains('android 2') || userAgentContains('android 3'); /* See https://stackoverflow.com/a/17961266 for details on detecting stock Android */ var webkitVer = parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1], 10); // also matches AppleWebKit // @property androidStock: Boolean; **Deprecated.** `true` for the Android stock browser (i.e. not Chrome) var androidStock = android && userAgentContains('Google') && webkitVer < 537 && !('AudioNode' in window); // @property opera: Boolean; `true` for the Opera browser var opera = !!window.opera; // @property chrome: Boolean; `true` for the Chrome browser. var chrome = !edge && userAgentContains('chrome'); // @property gecko: Boolean; `true` for gecko-based browsers like Firefox. var gecko = userAgentContains('gecko') && !webkit && !opera && !ie; // @property safari: Boolean; `true` for the Safari browser. var safari = !chrome && userAgentContains('safari'); var phantom = userAgentContains('phantom'); // @property opera12: Boolean // `true` for the Opera browser supporting CSS transforms (version 12 or later). var opera12 = 'OTransition' in style; // @property win: Boolean; `true` when the browser is running in a Windows platform var win = navigator.platform.indexOf('Win') === 0; // @property ie3d: Boolean; `true` for all Internet Explorer versions supporting CSS transforms. var ie3d = ie && ('transition' in style); // @property webkit3d: Boolean; `true` for webkit-based browsers supporting CSS transforms. var webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23; // @property gecko3d: Boolean; `true` for gecko-based browsers supporting CSS transforms. var gecko3d = 'MozPerspective' in style; // @property any3d: Boolean // `true` for all browsers supporting CSS transforms. var any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d) && !opera12 && !phantom; // @property mobile: Boolean; `true` for all browsers running in a mobile device. var mobile = typeof orientation !== 'undefined' || userAgentContains('mobile'); // @property mobileWebkit: Boolean; `true` for all webkit-based browsers in a mobile device. var mobileWebkit = mobile && webkit; // @property mobileWebkit3d: Boolean // `true` for all webkit-based browsers in a mobile device supporting CSS transforms. var mobileWebkit3d = mobile && webkit3d; // @property msPointer: Boolean // `true` for browsers implementing the Microsoft touch events model (notably IE10). var msPointer = !window.PointerEvent && window.MSPointerEvent; // @property pointer: Boolean // `true` for all browsers supporting [pointer events](https://msdn.microsoft.com/en-us/library/dn433244%28v=vs.85%29.aspx). var pointer = !!(window.PointerEvent || msPointer); // @property touchNative: Boolean // `true` for all browsers supporting [touch events](https://developer.mozilla.org/docs/Web/API/Touch_events). // **This does not necessarily mean** that the browser is running in a computer with // a touchscreen, it only means that the browser is capable of understanding // touch events. var touchNative = 'ontouchstart' in window || !!window.TouchEvent; // @property touch: Boolean // `true` for all browsers supporting either [touch](#browser-touch) or [pointer](#browser-pointer) events. // Note: pointer events will be preferred (if available), and processed for all `touch*` listeners. var touch = !window.L_NO_TOUCH && (touchNative || pointer); // @property mobileOpera: Boolean; `true` for the Opera browser in a mobile device. var mobileOpera = mobile && opera; // @property mobileGecko: Boolean // `true` for gecko-based browsers running in a mobile device. var mobileGecko = mobile && gecko; // @property retina: Boolean // `true` for browsers on a high-resolution "retina" screen or on any screen when browser's display zoom is more than 100%. var retina = (window.devicePixelRatio || (window.screen.deviceXDPI / window.screen.logicalXDPI)) > 1; // @property passiveEvents: Boolean // `true` for browsers that support passive events. var passiveEvents = (function () { var supportsPassiveOption = false; try { var opts = Object.defineProperty({}, 'passive', { get: function () { // eslint-disable-line getter-return supportsPassiveOption = true; } }); window.addEventListener('testPassiveEventSupport', falseFn, opts); window.removeEventListener('testPassiveEventSupport', falseFn, opts); } catch (e) { // Errors can safely be ignored since this is only a browser support test. } return supportsPassiveOption; }()); // @property canvas: Boolean // `true` when the browser supports [``](https://developer.mozilla.org/docs/Web/API/Canvas_API). var canvas$1 = (function () { return !!document.createElement('canvas').getContext; }()); // @property svg: Boolean // `true` when the browser supports [SVG](https://developer.mozilla.org/docs/Web/SVG). var svg$1 = !!(document.createElementNS && svgCreate('svg').createSVGRect); var inlineSvg = !!svg$1 && (function () { var div = document.createElement('div'); div.innerHTML = ''; return (div.firstChild && div.firstChild.namespaceURI) === 'http://www.w3.org/2000/svg'; })(); // @property vml: Boolean // `true` if the browser supports [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language). var vml = !svg$1 && (function () { try { var div = document.createElement('div'); div.innerHTML = ''; var shape = div.firstChild; shape.style.behavior = 'url(#default#VML)'; return shape && (typeof shape.adj === 'object'); } catch (e) { return false; } }()); // @property mac: Boolean; `true` when the browser is running in a Mac platform var mac = navigator.platform.indexOf('Mac') === 0; // @property mac: Boolean; `true` when the browser is running in a Linux platform var linux = navigator.platform.indexOf('Linux') === 0; function userAgentContains(str) { return navigator.userAgent.toLowerCase().indexOf(str) >= 0; } var Browser = { ie: ie, ielt9: ielt9, edge: edge, webkit: webkit, android: android, android23: android23, androidStock: androidStock, opera: opera, chrome: chrome, gecko: gecko, safari: safari, phantom: phantom, opera12: opera12, win: win, ie3d: ie3d, webkit3d: webkit3d, gecko3d: gecko3d, any3d: any3d, mobile: mobile, mobileWebkit: mobileWebkit, mobileWebkit3d: mobileWebkit3d, msPointer: msPointer, pointer: pointer, touch: touch, touchNative: touchNative, mobileOpera: mobileOpera, mobileGecko: mobileGecko, retina: retina, passiveEvents: passiveEvents, canvas: canvas$1, svg: svg$1, vml: vml, inlineSvg: inlineSvg, mac: mac, linux: linux }; /* * Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices. */ var POINTER_DOWN = Browser.msPointer ? 'MSPointerDown' : 'pointerdown'; var POINTER_MOVE = Browser.msPointer ? 'MSPointerMove' : 'pointermove'; var POINTER_UP = Browser.msPointer ? 'MSPointerUp' : 'pointerup'; var POINTER_CANCEL = Browser.msPointer ? 'MSPointerCancel' : 'pointercancel'; var pEvent = { touchstart : POINTER_DOWN, touchmove : POINTER_MOVE, touchend : POINTER_UP, touchcancel : POINTER_CANCEL }; var handle = { touchstart : _onPointerStart, touchmove : _handlePointer, touchend : _handlePointer, touchcancel : _handlePointer }; var _pointers = {}; var _pointerDocListener = false; // Provides a touch events wrapper for (ms)pointer events. // ref https://www.w3.org/TR/pointerevents/ https://www.w3.org/Bugs/Public/show_bug.cgi?id=22890 function addPointerListener(obj, type, handler) { if (type === 'touchstart') { _addPointerDocListener(); } if (!handle[type]) { console.warn('wrong event specified:', type); return falseFn; } handler = handle[type].bind(this, handler); obj.addEventListener(pEvent[type], handler, false); return handler; } function removePointerListener(obj, type, handler) { if (!pEvent[type]) { console.warn('wrong event specified:', type); return; } obj.removeEventListener(pEvent[type], handler, false); } function _globalPointerDown(e) { _pointers[e.pointerId] = e; } function _globalPointerMove(e) { if (_pointers[e.pointerId]) { _pointers[e.pointerId] = e; } } function _globalPointerUp(e) { delete _pointers[e.pointerId]; } function _addPointerDocListener() { // need to keep track of what pointers and how many are active to provide e.touches emulation if (!_pointerDocListener) { // we listen document as any drags that end by moving the touch off the screen get fired there document.addEventListener(POINTER_DOWN, _globalPointerDown, true); document.addEventListener(POINTER_MOVE, _globalPointerMove, true); document.addEventListener(POINTER_UP, _globalPointerUp, true); document.addEventListener(POINTER_CANCEL, _globalPointerUp, true); _pointerDocListener = true; } } function _handlePointer(handler, e) { if (e.pointerType === (e.MSPOINTER_TYPE_MOUSE || 'mouse')) { return; } e.touches = []; for (var i in _pointers) { e.touches.push(_pointers[i]); } e.changedTouches = [e]; handler(e); } function _onPointerStart(handler, e) { // IE10 specific: MsTouch needs preventDefault. See #2000 if (e.MSPOINTER_TYPE_TOUCH && e.pointerType === e.MSPOINTER_TYPE_TOUCH) { preventDefault(e); } _handlePointer(handler, e); } /* * Extends the event handling code with double tap support for mobile browsers. * * Note: currently most browsers fire native dblclick, with only a few exceptions * (see https://github.com/Leaflet/Leaflet/issues/7012#issuecomment-595087386) */ function makeDblclick(event) { // in modern browsers `type` cannot be just overridden: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only var newEvent = {}, prop, i; for (i in event) { prop = event[i]; newEvent[i] = prop && prop.bind ? prop.bind(event) : prop; } event = newEvent; newEvent.type = 'dblclick'; newEvent.detail = 2; newEvent.isTrusted = false; newEvent._simulated = true; // for debug purposes return newEvent; } var delay = 200; function addDoubleTapListener(obj, handler) { // Most browsers handle double tap natively obj.addEventListener('dblclick', handler); // On some platforms the browser doesn't fire native dblclicks for touch events. // It seems that in all such cases `detail` property of `click` event is always `1`. // So here we rely on that fact to avoid excessive 'dblclick' simulation when not needed. var last = 0, detail; function simDblclick(e) { if (e.detail !== 1) { detail = e.detail; // keep in sync to avoid false dblclick in some cases return; } if (e.pointerType === 'mouse' || (e.sourceCapabilities && !e.sourceCapabilities.firesTouchEvents)) { return; } // When clicking on an , the browser generates a click on its //