File "smooth-scroll.js"
Full Path: /home/digimqhe/flashdigi.uk/assets/js/extra/smooth-scroll.js
File size: 7.64 KB
MIME-type: text/plain
Charset: utf-8
/* SmoothScroll v1.4.10 */
var smoothAllowedBrowsers = ["ieWin7","chrome","firefox","safari"];
!function(){var s,a,i,r,o={frameRate:150,animationTime:400,stepSize:100,pulseAlgorithm:!0,pulseScale:4,pulseNormalize:1,accelerationDelta:50,accelerationMax:3,keyboardSupport:!0,arrowScroll:50,fixedBackground:!0,excluded:""},h=o,c=!1,u=!1,n={x:0,y:0},d=!1,m=document.documentElement,l=[],f=/^Mac/.test(navigator.platform),w={left:37,up:38,right:39,down:40,spacebar:32,pageup:33,pagedown:34,end:35,home:36},p={37:1,38:1,39:1,40:1};function y(){var e,t,o,n,r,l;!d&&document.body&&(d=!0,e=document.body,t=document.documentElement,l=window.innerHeight,o=e.scrollHeight,m=0<=document.compatMode.indexOf("CSS")?t:e,s=e,h.keyboardSupport&&X("keydown",S),top!=self?u=!0:Q&&l<o&&(e.offsetHeight<=l||t.offsetHeight<=l)&&((n=document.createElement("div")).style.cssText="position:absolute; z-index:-10000; top:0; left:0; right:0; height:"+m.scrollHeight+"px",document.body.appendChild(n),i=function(){r=r||setTimeout(function(){c||(n.style.height="0",n.style.height=m.scrollHeight+"px",r=null)},500)},setTimeout(i,10),X("resize",i),(a=new R(i)).observe(e,{attributes:!0,childList:!0,characterData:!1}),m.offsetHeight<=l&&((l=document.createElement("div")).style.clear="both",e.appendChild(l))),h.fixedBackground||c||(e.style.backgroundAttachment="scroll",t.style.backgroundAttachment="scroll"))}var v=[],b=!1,g=Date.now();function x(s,u,d){var e,t,o,m,f;e=0<(e=u)?1:-1,t=0<(t=d)?1:-1,n.x===e&&n.y===t||(n.x=e,n.y=t,v=[],g=0),1!=h.accelerationMax&&((t=Date.now()-g)<h.accelerationDelta&&(1<(o=(1+50/t)/2)&&(o=Math.min(o,h.accelerationMax),u*=o,d*=o)),g=Date.now()),v.push({x:u,y:d,lastX:u<0?.99:-.99,lastY:d<0?.99:-.99,start:Date.now()}),b||(o=q(),m=s===o||s===document.body,null==s.$scrollBehavior&&function(e){var t=D(e);null==T[t]&&(e=getComputedStyle(e,"")["scroll-behavior"],T[t]="smooth"==e);return T[t]}(s)&&(s.$scrollBehavior=s.style.scrollBehavior,s.style.scrollBehavior="auto"),f=function(e){for(var t=Date.now(),o=0,n=0,r=0;r<v.length;r++){var l=v[r],a=t-l.start,i=a>=h.animationTime,c=i?1:a/h.animationTime;h.pulseAlgorithm&&(c=function(e){if(1<=e)return 1;if(e<=0)return 0;1==h.pulseNormalize&&(h.pulseNormalize/=F(1));return F(e)}(c));a=l.x*c-l.lastX>>0,c=l.y*c-l.lastY>>0;o+=a,n+=c,l.lastX+=a,l.lastY+=c,i&&(v.splice(r,1),r--)}m?window.scrollBy(o,n):(o&&(s.scrollLeft+=o),n&&(s.scrollTop+=n)),u||d||(v=[]),v.length?j(f,s,1e3/h.frameRate+1):(b=!1,null!=s.$scrollBehavior&&(s.style.scrollBehavior=s.$scrollBehavior,s.$scrollBehavior=null))},j(f,s,0),b=!0)}function e(e){d||y();var t=e.target;if(e.defaultPrevented||e.ctrlKey)return!0;if(N(s,"embed")||N(t,"embed")&&/\.pdf/i.test(t.src)||N(s,"object")||t.shadowRoot)return!0;var o=-e.wheelDeltaX||e.deltaX||0,n=-e.wheelDeltaY||e.deltaY||0;f&&(e.wheelDeltaX&&K(e.wheelDeltaX,120)&&(o=e.wheelDeltaX/Math.abs(e.wheelDeltaX)*-120),e.wheelDeltaY&&K(e.wheelDeltaY,120)&&(n=e.wheelDeltaY/Math.abs(e.wheelDeltaY)*-120)),o||n||(n=-e.wheelDelta||0),1===e.deltaMode&&(o*=40,n*=40);t=A(t);return t?!!function(e){if(!e)return;l.length||(l=[e,e,e]);e=Math.abs(e),l.push(e),l.shift(),clearTimeout(r),r=setTimeout(function(){try{localStorage.SS_deltaBuffer=l.join(",")}catch(e){}},1e3);var t=120<e&&P(e),t=!P(120)&&!P(100)&&!t;return e<50||t}(n)||(1.2<Math.abs(o)&&(o*=h.stepSize/120),1.2<Math.abs(n)&&(n*=h.stepSize/120),x(t,o,n),e.preventDefault(),void O()):!u||!W||(Object.defineProperty(e,"target",{value:window.frameElement}),parent.wheel(e))}function S(e){var t=e.target,o=e.ctrlKey||e.altKey||e.metaKey||e.shiftKey&&e.keyCode!==w.spacebar;document.body.contains(s)||(s=document.activeElement);var n=/^(button|submit|radio|checkbox|file|color|image)$/i;if(e.defaultPrevented||/^(textarea|select|embed|object)$/i.test(t.nodeName)||N(t,"input")&&!n.test(t.type)||N(s,"video")||function(e){var t=e.target,o=!1;if(-1!=document.URL.indexOf("www.youtube.com/watch"))do{if(o=t.classList&&t.classList.contains("html5-video-controls"))break}while(t=t.parentNode);return o}(e)||t.isContentEditable||o)return!0;if((N(t,"button")||N(t,"input")&&n.test(t.type))&&e.keyCode===w.spacebar)return!0;if(N(t,"input")&&"radio"==t.type&&p[e.keyCode])return!0;var r=0,l=0,a=A(s);if(!a)return!u||!W||parent.keydown(e);var i=a.clientHeight;switch(a==document.body&&(i=window.innerHeight),e.keyCode){case w.up:l=-h.arrowScroll;break;case w.down:l=h.arrowScroll;break;case w.spacebar:l=-(e.shiftKey?1:-1)*i*.9;break;case w.pageup:l=.9*-i;break;case w.pagedown:l=.9*i;break;case w.home:a==document.body&&document.scrollingElement&&(a=document.scrollingElement),l=-a.scrollTop;break;case w.end:var c=a.scrollHeight-a.scrollTop-i,l=0<c?10+c:0;break;case w.left:r=-h.arrowScroll;break;case w.right:r=h.arrowScroll;break;default:return!0}x(a,r,l),e.preventDefault(),O()}function t(e){s=e.target}var k,B,D=(k=0,function(e){return e.uniqueID||(e.uniqueID=k++)}),E={},M={},T={};function O(){clearTimeout(B),B=setInterval(function(){E=M=T={}},1e3)}function C(e,t,o){for(var n=o?E:M,r=e.length;r--;)n[D(e[r])]=t;return t}function A(e){var t=[],o=document.body,n=m.scrollHeight;do{var r=(!1?E:M)[D(e)];if(r)return C(t,r);if(t.push(e),n===e.scrollHeight){r=z(m)&&z(o)||L(m);if(u&&H(m)||!u&&r)return C(t,q())}else if(H(e)&&L(e))return C(t,e)}while(e=e.parentElement)}function H(e){return e.clientHeight+10<e.scrollHeight}function z(e){return"hidden"!==getComputedStyle(e,"").getPropertyValue("overflow-y")}function L(e){e=getComputedStyle(e,"").getPropertyValue("overflow-y");return"scroll"===e||"auto"===e}function X(e,t,o){window.addEventListener(e,t,o||!1)}function Y(e,t,o){window.removeEventListener(e,t,o||!1)}function N(e,t){return e&&(e.nodeName||"").toLowerCase()===t.toLowerCase()}if(window.localStorage&&localStorage.SS_deltaBuffer)try{l=localStorage.SS_deltaBuffer.split(",")}catch(e){}function K(e,t){return Math.floor(e/t)==e/t}function P(e){return K(l[0],e)&&K(l[1],e)&&K(l[2],e)}var $,j=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(e,t,o){window.setTimeout(e,o||1e3/60)},R=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,q=($=document.scrollingElement,function(){var e,t;return $||((e=document.createElement("div")).style.cssText="height:10000px;width:1px;",document.body.appendChild(e),t=document.body.scrollTop,document.documentElement.scrollTop,window.scrollBy(0,3),$=document.body.scrollTop!=t?document.body:document.documentElement,window.scrollBy(0,-3),document.body.removeChild(e)),$});function F(e){var t;return((e*=h.pulseScale)<1?e-(1-Math.exp(-e)):(--e,(t=Math.exp(-1))+(1-Math.exp(-e))*(1-t)))*h.pulseNormalize}var I=window.navigator.userAgent,V=/Edge/.test(I),W=/chrome/i.test(I)&&!V,_=/safari/i.test(I)&&!V,U=/firefox/i.test(I),G=/mobile/i.test(I),J=/Windows NT 6.1/i.test(I)&&/rv:11/i.test(I),Q=_&&(/Version\/8/i.test(I)||/Version\/9/i.test(I)),Z=function(){if(G)return~smoothAllowedBrowsers.indexOf("mobile");return V?~smoothAllowedBrowsers.indexOf("edge"):W?~smoothAllowedBrowsers.indexOf("chrome"):_?~smoothAllowedBrowsers.indexOf("safari"):U?~smoothAllowedBrowsers.indexOf("firefox"):J?~smoothAllowedBrowsers.indexOf("ieWin7"):~smoothAllowedBrowsers.indexOf("other")}(),ee=!1;try{window.addEventListener("test",null,Object.defineProperty({},"passive",{get:function(){ee=!0}}))}catch(e){}var I=!!ee&&{passive:!1},te="onwheel"in document.createElement("div")?"wheel":"mousewheel";function oe(e){for(var t in e)o.hasOwnProperty(t)&&(h[t]=e[t])}te&&Z&&(X(te,e,I),X("mousedown",t),X("load",y)),oe.destroy=function(){a&&a.disconnect(),Y(te,e),Y("mousedown",t),Y("keydown",S),Y("resize",i),Y("load",y)},window.SmoothScrollOptions&&oe(window.SmoothScrollOptions),"function"==typeof define&&define.amd?define(function(){return oe}):"object"==typeof exports?module.exports=oe:window.SmoothScroll=oe}();