UNPKG

bookie-d3-timer

Version:

An efficient queue capable of managing thousands of concurrent animations.

2 lines 1.69 kB
$(preamble) $(preamble)(function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.d3=t.d3||{})}(this,function(t){"use strict";function n(){return h||(v(e),h=d.now()+y)}function e(){h=0}function i(){this._call=this._time=this._next=null}function r(t,n,e){var r=new i;return r.restart(t,n,e),r}function o(){n(),++s;for(var t,e=a;e;)(t=h-e._time)>=0&&e._call.call(null,t),e=e._next;--s}function u(){h=(p=d.now())+y,s=m=0;try{o()}finally{s=0,l(),h=0}}function l(){for(var t,n,e=a,i=1/0;e;)e._call?(i>e._time&&(i=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:a=n);f=t,c(i)}function c(t){if(!s){m&&(m=clearTimeout(m));var n=t-h;n>24?(t<1/0&&(m=setTimeout(u,n)),_&&(_=clearInterval(_))):(_||(p=h),s=1,v(u))}}var a,f,s=0,m=0,_=0,p=0,h=0,y=0,d="object"==typeof performance&&performance.now?performance:Date,v="function"==typeof requestAnimationFrame?requestAnimationFrame:function(t){setTimeout(t,17)};i.prototype=r.prototype={constructor:i,restart:function(t,e,i){if("function"!=typeof t)throw new TypeError("callback is not a function");i=(null==i?n():+i)+(null==e?0:+e),this._next||f===this||(f?f._next=this:a=this,f=this),this._call=t,this._time=i,c()},stop:function(){this._call&&(this._call=null,this._time=1/0,c())}};var x=function(t,n,e){var r=new i;return n=null==n?0:+n,r.restart(function(e){r.stop(),t(e+n)},n,e),r},w=function(t,e,r){var o=new i,u=e;return null==e?(o.restart(t,e,r),o):(e=+e,r=null==r?n():+r,o.restart(function n(i){i+=u,o.restart(n,u+=e,r),t(i)},e,r),o)};t.now=n,t.timer=r,t.timerFlush=o,t.timeout=x,t.interval=w,Object.defineProperty(t,"__esModule",{value:!0})}));