/*! * simpleParallax.min - simpleParallax is a simple JavaScript library that gives your website parallax animations on any images or videos, * @date: 08-04-2020 8:7:34, * @version: 5.4.0, * @link: https://simpleparallax.com/ */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("simpleParallax",[],e):"object"==typeof exports?exports.simpleParallax=e():t.simpleParallax=e()}(window,(function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";function n(t,e){for(var i=0;i0&&setTimeout((function(){t.setTransitionCSS()}),10),this.isInit=!0)}},{key:"wrapElement",value:function(){var t=this.settings.customWrapper&&this.element.closest(this.settings.customWrapper),e=this.element.closest("picture")||this.element,i=document.createElement("div");t&&(i=this.element.closest(this.settings.customWrapper)),i.classList.add("simpleParallax"),i.style.overflow="hidden",t||(e.parentNode.insertBefore(i,e),i.appendChild(e)),this.elementContainer=i}},{key:"unWrapElement",value:function(){var t=this.elementContainer;this.settings.customWrapper&&this.element.closest(this.settings.customWrapper)?(t.classList.remove("simpleParallax"),t.style.overflow=""):t.replaceWith.apply(t,l(t.childNodes))}},{key:"setTransformCSS",value:function(){!1===this.settings.overflow&&(this.element.style[r]="scale(".concat(this.settings.scale,")")),this.element.style.willChange="transform"}},{key:"setTransitionCSS",value:function(){this.element.style.transition="transform ".concat(this.settings.delay,"s ").concat(this.settings.transition)}},{key:"unSetStyle",value:function(){this.element.style.willChange="",this.element.style[r]="",this.element.style.transition=""}},{key:"getElementOffset",value:function(){var t=this.elementContainer.getBoundingClientRect();if(this.elementHeight=t.height,this.elementTop=t.top+s.positions.top,this.settings.customContainer){var e=this.settings.customContainer.getBoundingClientRect();this.elementTop=t.top-e.top+s.positions.top}this.elementBottom=this.elementHeight+this.elementTop}},{key:"buildThresholdList",value:function(){for(var t=[],e=1;e<=this.elementHeight;e++){var i=e/this.elementHeight;t.push(i)}return t}},{key:"intersectionObserver",value:function(){var t={root:null,threshold:this.buildThresholdList()};this.observer=new IntersectionObserver(this.intersectionObserverCallback.bind(this),t),this.observer.observe(this.element)}},{key:"intersectionObserverCallback",value:function(t){for(var e=t.length-1;e>=0;e--)t[e].isIntersecting?this.isVisible=!0:this.isVisible=!1}},{key:"checkIfVisible",value:function(){return this.elementBottom>s.positions.top&&this.elementTopthis.settings.maxTransition&&(t=this.settings.maxTransition),this.oldPercentage!==t&&(this.rangeMax||this.getRangeMax(),this.translateValue=(t/100*this.rangeMax-this.rangeMax/2).toFixed(0),this.oldTranslateValue!==this.translateValue&&(this.oldPercentage=t,this.oldTranslateValue=this.translateValue,!0))}},{key:"animate",value:function(){var t,e=0,i=0;(this.settings.orientation.includes("left")||this.settings.orientation.includes("right"))&&(i="".concat(this.settings.orientation.includes("left")?-1*this.translateValue:this.translateValue,"px")),(this.settings.orientation.includes("up")||this.settings.orientation.includes("down"))&&(e="".concat(this.settings.orientation.includes("up")?-1*this.translateValue:this.translateValue,"px")),t=!1===this.settings.overflow?"translate3d(".concat(i,", ").concat(e,", 0) scale(").concat(this.settings.scale,")"):"translate3d(".concat(i,", ").concat(e,", 0)"),this.element.style[r]=t}}])&&u(e.prototype,i),n&&u(e,n),t}();function h(t){return function(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e=0;t--)y[t].getElementOffset(),y[t].getRangeMax();this.lastPosition=-1}},{key:"proceedRequestAnimationFrame",value:function(){if(s.setViewportTop(this.customContainer),this.lastPosition!==s.positions.top){s.setViewportBottom();for(var t=m-1;t>=0;t--)this.proceedElement(y[t]);p=window.requestAnimationFrame(this.proceedRequestAnimationFrame),this.lastPosition=s.positions.top}else p=window.requestAnimationFrame(this.proceedRequestAnimationFrame)}},{key:"proceedElement",value:function(t){(!g||this.customContainer?t.checkIfVisible():t.isVisible)&&t.getTranslateValue()&&t.animate()}},{key:"destroy",value:function(){var t=this,e=[];y=y.filter((function(i){return t.elements.includes(i.element)?(e.push(i),!1):i}));for(var i=e.length-1;i>=0;i--)e[i].unSetStyle(),!1===this.settings.overflow&&e[i].unWrapElement();(m=y.length)||(window.cancelAnimationFrame(p),window.removeEventListener("resize",this.handleResize))}}])&&f(e.prototype,i),n&&f(e,n),t}()}]).default}));