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

1 line
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(){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}"function"!=typeof window.CustomEvent&&(e.prototype=window.Event.prototype,window.CustomEvent=e)}(),function(){for(var r=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-r)),i=window.setTimeout(function(){e(n+o)},o);return r=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(b){"use strict";function E(){for(var e={},t=0;t<arguments.length;t++){n=void 0;var n,o=arguments[t];for(n in o)o.hasOwnProperty(n)&&(e[n]=o[n])}return e}function c(t){var n;try{n=decodeURIComponent(t)}catch(e){n=t}return n}function s(e){"#"===e.charAt(0)&&(e=e.substr(1));for(var t,n,o=String(e),i=o.length,r=-1,a="",c=o.charCodeAt(0);++r<i;){if(0===(t=o.charCodeAt(r)))throw new InvalidCharacterError("Invalid character: the input contains U+0000.");1<=t&&t<=31||127==t||0===r&&48<=t&&t<=57||1===r&&48<=t&&t<=57&&45===c?a+="\\"+t.toString(16)+" ":a+=128<=t||45===t||95===t||48<=t&&t<=57||65<=t&&t<=90||97<=t&&t<=122?o.charAt(r):"\\"+o.charAt(r)}try{n=decodeURIComponent("#"+a)}catch(e){n="#"+a}return n}function A(e){return e?t(e)+e.offsetTop:0}function C(e,t,n,o){t.emitEvents&&"function"==typeof b.CustomEvent&&(t=new CustomEvent(e,{bubbles:!0,detail:{anchor:n,toggle:o}}),document.dispatchEvent(t))}var q={ignore:"[data-scroll-ignore]",header:null,topOnEmptyHash:!0,speed:500,clip:!0,offset:0,easing:"easeInOutCubic",customEasing:null,updateURL:!0,popstate:!0,emitEvents:!0},t=function(e){return parseInt(b.getComputedStyle(e).height,10)},O=function(){return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight)};return function(o,e){function t(e){var t,n;"matchMedia"in b&&b.matchMedia("(prefers-reduced-motion)").matches||0!==e.button||e.metaKey||e.ctrlKey||"closest"in e.target&&(r=e.target.closest(o))&&"a"===r.tagName.toLowerCase()&&!e.target.closest(g.ignore)&&r.hostname===b.location.hostname&&r.pathname===b.location.pathname&&/#/.test(r.href)&&(t=s(c(r.hash)),n=(n=g.topOnEmptyHash&&"#"===t?document.documentElement:document.querySelector(t))||"#top"!==t?n:document.documentElement)&&(e.preventDefault(),S.animateScroll(n,r))}function n(e){var t;null!==history.state&&history.state.smoothScroll&&history.state.smoothScroll===JSON.stringify(g)&&history.state.anchor&&(t=document.querySelector(s(c(history.state.anchor))))&&S.animateScroll(t,null,{updateURL:!1})}function i(e){a=a||setTimeout(function(){a=null,v=A(y)},66)}var g,r,y,v,a,w,S={cancelScroll:function(e){cancelAnimationFrame(w),w=null,e||C("scrollCancel",g)}};S.animateScroll=function(o,i,e){var r,a,c,s,u,l,m,d,f,t,h=E(g||q,e||{}),p="[object Number]"===Object.prototype.toString.call(o),e=p||!o.tagName?null:o;(p||e)&&(r=b.pageYOffset,h.header&&!y&&(y=document.querySelector(h.header)),v=v||A(y),a=p?o: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),i=o?Math.min(i,O()-b.innerHeight):i}(e,v,parseInt("function"==typeof h.offset?h.offset(o,i):h.offset,10),h.clip),c=a-r,s=O(),d=function(e,t){var n=b.pageYO