laipower/wp-content/plugins/gp-premium/general/js/smooth-scroll.min.js

2 lines
6.7 KiB
JavaScript
Raw Normal View History

window.Element&&!Element.prototype.closest&&(Element.prototype.closest=function(e){var t,n=(this.document||this.ownerDocument).querySelectorAll(e),o=this;do{for(t=n.length;0<=--t&&n.item(t)!==o;);}while(t<0&&(o=o.parentElement));return o}),function(){if("function"==typeof window.CustomEvent)return;function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}e.prototype=window.Event.prototype,window.CustomEvent=e}(),function(){for(var a=0,e=["ms","moz","webkit","o"],t=0;t<e.length&&!window.requestAnimationFrame;++t)window.requestAnimationFrame=window[e[t]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[e[t]+"CancelAnimationFrame"]||window[e[t]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(e,t){var n=(new Date).getTime(),o=Math.max(0,16-(n-a)),i=window.setTimeout(function(){e(n+o)},o);return a=n+o,i}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(e){clearTimeout(e)})}(),function(e,t){"function"==typeof define&&define.amd?define([],function(){return t(e)}):"object"==typeof exports?module.exports=t(e):e.SmoothScroll=t(e)}("undefined"!=typeof global?global:"undefined"!=typeof window?window:this,function(A){"use strict";var C={ignore:"[data-scroll-ignore]",header:null,topOnEmptyHash:!0,speed:500,clip:!0,offset:0,easing:"easeInOutCubic",customEasing:null,updateURL:!0,popstate:!0,emitEvents:!0},q=function(){for(var n={},e=function(e){for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t])},t=0;t<arguments.length;t++)e(arguments[t]);return n},c=function(t){var n;try{n=decodeURIComponent(t)}catch(e){n=t}return n},s=function(e){"#"===e.charAt(0)&&(e=e.substr(1));for(var t,n,o=String(e),i=o.length,a=-1,r="",c=o.charCodeAt(0);++a<i;){if(0===(t=o.charCodeAt(a)))throw new InvalidCharacterError("Invalid character: the input contains U+0000.");1<=t&&t<=31||127==t||0===a&&48<=t&&t<=57||1===a&&48<=t&&t<=57&&45===c?r+="\\"+t.toString(16)+" ":r+=128<=t||45===t||95===t||48<=t&&t<=57||65<=t&&t<=90||97<=t&&t<=122?o.charAt(a):"\\"+o.charAt(a)}try{n=decodeURIComponent("#"+r)}catch(e){n="#"+r}return n},O=function(){return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight)},H=function(e){return e?(t=e,parseInt(A.getComputedStyle(t).height,10)+e.offsetTop):0;var t},I=function(e,t,n,o){if(t.emitEvents&&"function"==typeof A.CustomEvent){var i=new CustomEvent(e,{bubbles:!0,detail:{anchor:n,toggle:o}});document.dispatchEvent(i)}};return function(o,e){var v,i,w,b,t,S,E={};E.cancelScroll=function(e){cancelAnimationFrame(S),S=null,e||I("scrollCancel",v)},E.animateScroll=function(r,c,e){var s=q(v||C,e||{}),u="[object Number]"===Object.prototype.toString.call(r),t=u||!r.tagName?null:r;if(u||t){var l=A.pageYOffset;s.header&&!w&&(w=document.querySelector(s.header)),b||(b=H(w));var m,i,a,n,o,d=u?r:function(e,t,n,o){var i=0;if(e.offsetParent)for(;i+=e.offsetTop,e=e.offsetParent;);return i=Math.max(i-t-n,0),o&&(i=Math.min(i,O()-A.innerHeight)),i}(t,b,parseInt("function"==typeof s.offset?s.offset(r,c):s.offset,10),s.clip),f=d-l,h=O(),p=0,g=function(e,t){var n,o,i,a=A.pageYOffset;if(e==t||a==t||(l<t&&A.innerHeight+a)>=h)return E.cancelScroll(!0),o=t,i=u,0===(n=r)&&document.body.focus(),i||(n.focus(),document.activeElement!==n&&(n.setAttribute("tabindex","-1"),n.focus(),n.style.outline="none"),A.scrollTo(0,o)),I("scrollStop",s,r,c),!(S=m=null)},y=function(e){var t,n,o;m||(m=e),i=(p+=e-m)/parseInt(s.speed,10),a=l+f*(n=i=1<i?1:i,"easeInQuad"===(t=s).easing&&(o=n*n),"easeOutQuad"===t.easing&&(o=n*(2-n)),"easeInOutQuad"===t.easing&&(o=n<.5?2*n*n:(4-2*n)*n-1),"easeInCubic"===t.easing&&(o=n*n*n),"easeOutCubic"===t.easing&&(o=--n*n*n+1),"easeInOutCubic"===t.easing&&(o=n<.5?4*n*n*n:(n-1)*(2*n-2)*(2*n-2)+1),"easeInQuart"===t.easing&&(o=n*n*n*n),"easeOutQuart"===t.easing&&(o=1- --n*n*n*n),"easeInOutQuart"===t.easing&&(o=n<.5?8*n*n*n*n:1-8*--n*