UNPKG

scrollto-with-animation

Version:

Animated scroll with requestAnimationFrame. For smooth animate scrollTo defining the easing, running at 60FPS and cross-browser

2 lines 7.34 kB
!function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){(function(t){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.rAF=void 0;var i=n(3),o=r(i),u=n(8),a=r(u),c={name:"scrollto-with-animation",url:"https://github.com/davesnx/scrollto-with-animation"},s=new o.default,f=t.env.NODE_ENV||!0,l="easeInQuad",h=""+c.name,m=h+": Transition not found - "+c.url,d=h+": callback transition don't look like a valid equation - "+c.url,p=h+": Transition isn't string or Function - "+c.url,v="animation-cancel",w="animation-end",T="undefined"!=typeof document?document:{},_="undefined"!=typeof window?window:{},g=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l,e=a.default[t];if(void 0===e&&f)throw new Error(m);return e},y=function(t){if(4!==t.length&&f)throw new Error(d);return t},I=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"scrollTop",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:l,o=arguments[5],u=void 0,a="scrollTop"===e?t.scrollTop:t.scrollLeft,c=n-a,f=+new Date,h=!0,m=void 0,d=void 0;if(t||(t=T.documentElement),"string"==typeof i||null===i)d=g(i);else{if("function"!=typeof i)throw new Error(p);d=y(i)}var _=function i(){var l=+new Date,p=Math.floor(d(l-f,a,c,r));m&&n===t[e]?(h=!1,o&&(o(v),s.cancel(u))):(m=p,t[e]=p),l>f+r&&(t[e]=n,h=!1,o&&(o(w),s.cancel(u))),h&&(u=s.request(i))};u=s.request(_)};_!=={}&&(_.scrollToWithAnimation=I),e.default=I,e.rAF=s}).call(e,n(9))},function(t,e){"use strict";t.exports=Date.now||function(){return(new Date).getTime()}},function(t,e){var n;n="undefined"!=typeof window?window:"undefined"!=typeof self?self:this,t.exports=n},function(t,e,n){t.exports=n(4)},function(t,e,n){"use strict";function r(t){return this instanceof r?(t||(t={}),"number"==typeof t&&(t={frameRate:t}),null!=t.useNative||(t.useNative=!0),this.options=t,this.frameRate=t.frameRate||r.FRAME_RATE,this._frameLength=1e3/this.frameRate,this._isCustomFrameRate=this.frameRate!==r.FRAME_RATE,this._timeoutId=null,this._callbacks={},this._lastTickTime=0,void(this._tickCounter=0)):new r(t)}var i=n(5),o=n(1),u=n(7),a=n(2),c=i.request,s=i.cancel;t.exports=r,r.FRAME_RATE=60,r.shim=function(t){var e=new r(t);return a.requestAnimationFrame=function(t){return e.request(t)},a.cancelAnimationFrame=function(t){return e.cancel(t)},e},r.prototype.request=function(t){var e=this;if(++this._tickCounter,i.supported&&this.options.useNative&&!this._isCustomFrameRate)return c(t);if(!t)throw new TypeError("Not enough arguments");if(null==this._timeoutId){var n=this._frameLength+this._lastTickTime-o();n<0&&(n=0),this._timeoutId=setTimeout(function(){e._lastTickTime=o(),e._timeoutId=null,++e._tickCounter;var t=e._callbacks;e._callbacks={};for(var n in t)t[n]&&(i.supported&&e.options.useNative?c(t[n]):t[n](u.now()))},n)}return this._callbacks[this._tickCounter]=t,this._tickCounter},r.prototype.cancel=function(t){i.supported&&this.options.useNative&&s(t),delete this._callbacks[t]}},function(t,e,n){"use strict";var r=n(2);try{r.top.name,r=r.top}catch(t){}e.request=r.requestAnimationFrame,e.cancel=r.cancelAnimationFrame||r.cancelRequestAnimationFrame,e.supported=!1;for(var i=["Webkit","Moz","ms","O"],o=0;o<i.length&&!e.request;o++)e.request=r[i[o]+"RequestAnimationFrame"],e.cancel=r[i[o]+"CancelAnimationFrame"]||r[i[o]+"CancelRequestAnimationFrame"];e.request&&e.request.call(null,function(){e.supported=!0})},function(t,e,n){"use strict";var r=n(1);e.navigationStart=r()},function(t,e,n){"use strict";var r=n(1),i=n(6),o=n(2);e.now=function(){return o.performance&&o.performance.now?o.performance.now():r()-i.navigationStart}},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={linearTween:function(t,e,n,r){return n*t/r+e},easeInQuad:function(t,e,n,r){return t/=r,n*t*t+e},easeOutQuad:function(t,e,n,r){return t/=r,-n*t*(t-2)+e},easeInOutQuad:function(t,e,n,r){return t/=r/2,t<1?n/2*t*t+e:(t--,-n/2*(t*(t-2)-1)+e)},easeInCubic:function(t,e,n,r){return t/=r,n*t*t*t+e},easeOutCubic:function(t,e,n,r){return t/=r,t--,n*(t*t*t+1)+e},easeInOutCubic:function(t,e,n,r){return t/=r/2,t<1?n/2*t*t*t+e:(t-=2,n/2*(t*t*t+2)+e)},easeInQuart:function(t,e,n,r){return t/=r,n*t*t*t*t+e},easeOutQuart:function(t,e,n,r){return t/=r,t--,-n*(t*t*t*t-1)+e},easeInOutQuart:function(t,e,n,r){return t/=r/2,t<1?n/2*t*t*t*t+e:(t-=2,-n/2*(t*t*t*t-2)+e)},easeInQuint:function(t,e,n,r){return t/=r,n*t*t*t*t*t+e},easeOutQuint:function(t,e,n,r){return t/=r,t--,n*(t*t*t*t*t+1)+e},easeInOutQuint:function(t,e,n,r){return t/=r/2,t<1?n/2*t*t*t*t*t+e:(t-=2,n/2*(t*t*t*t*t+2)+e)},easeInSine:function(t,e,n,r){return-n*Math.cos(t/r*(Math.PI/2))+n+e},easeOutSine:function(t,e,n,r){return n*Math.sin(t/r*(Math.PI/2))+e},easeInOutSine:function(t,e,n,r){return-n/2*(Math.cos(Math.PI*t/r)-1)+e},easeInExpo:function(t,e,n,r){return n*Math.pow(2,10*(t/r-1))+e},easeOutExpo:function(t,e,n,r){return n*(-Math.pow(2,-10*t/r)+1)+e},easeInOutExpo:function(t,e,n,r){return t/=r/2,t<1?n/2*Math.pow(2,10*(t-1))+e:(t--,n/2*(-Math.pow(2,-10*t)+2)+e)},easeInCirc:function(t,e,n,r){return t/=r,-n*(Math.sqrt(1-t*t)-1)+e},easeOutCirc:function(t,e,n,r){return t/=r,t--,n*Math.sqrt(1-t*t)+e},easeInOutCirc:function(t,e,n,r){return t/=r/2,t<1?-n/2*(Math.sqrt(1-t*t)-1)+e:(t-=2,n/2*(Math.sqrt(1-t*t)+1)+e)}}},function(t,e){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function i(t){if(f===setTimeout)return setTimeout(t,0);if((f===n||!f)&&setTimeout)return f=setTimeout,setTimeout(t,0);try{return f(t,0)}catch(e){try{return f.call(null,t,0)}catch(e){return f.call(this,t,0)}}}function o(t){if(l===clearTimeout)return clearTimeout(t);if((l===r||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(t);try{return l(t)}catch(e){try{return l.call(null,t)}catch(e){return l.call(this,t)}}}function u(){p&&m&&(p=!1,m.length?d=m.concat(d):v=-1,d.length&&a())}function a(){if(!p){var t=i(u);p=!0;for(var e=d.length;e;){for(m=d,d=[];++v<e;)m&&m[v].run();v=-1,e=d.length}m=null,p=!1,o(t)}}function c(t,e){this.fun=t,this.array=e}function s(){}var f,l,h=t.exports={};!function(){try{f="function"==typeof setTimeout?setTimeout:n}catch(t){f=n}try{l="function"==typeof clearTimeout?clearTimeout:r}catch(t){l=r}}();var m,d=[],p=!1,v=-1;h.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];d.push(new c(t,e)),1!==d.length||p||i(a)},c.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=s,h.addListener=s,h.once=s,h.off=s,h.removeListener=s,h.removeAllListeners=s,h.emit=s,h.prependListener=s,h.prependOnceListener=s,h.listeners=function(t){return[]},h.binding=function(t){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(t){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}}]); //# sourceMappingURL=scrollto-with-animation.js.map