diff --git a/d3-timer.v0.4.js b/d3-timer.v0.4.js index ea42b857..e54c42ad 100644 --- a/d3-timer.v0.4.js +++ b/d3-timer.v0.4.js @@ -4,7 +4,7 @@ (factory((global.d3_timer = global.d3_timer || {}))); }(this, function (exports) { 'use strict'; - var version = "0.4.3"; + var version = "0.4.4"; var frame = 0; var timeout = 0; @@ -16,7 +16,9 @@ var clockNow = 0; var clockSkew = 0; var clock = typeof performance === "object" ? performance : Date; - var setFrame = typeof requestAnimationFrame === "function" ? requestAnimationFrame : function(callback) { return setTimeout(callback, 17); }; + var setFrame = typeof requestAnimationFrame === "function" + ? (clock === Date ? function(f) { requestAnimationFrame(function() { f(clock.now()); }); } : requestAnimationFrame) + : function(f) { setTimeout(f, 17); }; function now() { return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew); } diff --git a/d3-timer.v0.4.min.js b/d3-timer.v0.4.min.js index 001eff69..5dd8b64d 100644 --- a/d3-timer.v0.4.min.js +++ b/d3-timer.v0.4.min.js @@ -1 +1 @@ -!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.d3_timer=t.d3_timer||{})}(this,function(t){"use strict";function n(){return w||(F(e),w=b.now()+T)}function e(){w=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(),++h;for(var t,e=m;e;)(t=w-e._time)>=0&&e._call.call(null,t),e=e._next;--h}function u(t){w=(d=t||b.now())+T,h=v=0;try{o()}finally{h=0,c(),w=0}}function l(){var t=b.now(),n=t-d;n>y&&(T-=n,d=t)}function c(){for(var t,n=m,e=1/0;n;)n._call?(e>n._time&&(e=n._time),n=(t=n)._next):n=t?t._next=n._next:m=n._next;_=t,f(e)}function f(t){if(!h){v&&(v=clearTimeout(v));var n=t-w;n>24?(1/0>t&&(v=setTimeout(u,n)),x&&(x=clearInterval(x))):(x||(x=setInterval(l,y)),h=1,F(u))}}function a(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}function s(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 l(n){n+=u,o.restart(l,u+=e,r),t(n)},e,r),o)}var m,_,p="0.4.3",h=0,v=0,x=0,y=1e3,d=0,w=0,T=0,b="object"==typeof performance?performance:Date,F="function"==typeof requestAnimationFrame?requestAnimationFrame:function(t){return 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||_===this||(_?_._next=this:m=this,_=this),this._call=t,this._time=i,f()},stop:function(){this._call&&(this._call=null,this._time=1/0,f())}},t.version=p,t.now=n,t.timer=r,t.timerFlush=o,t.timeout=a,t.interval=s}); \ No newline at end of file +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.d3_timer=t.d3_timer||{})}(this,function(t){"use strict";function n(){return d||(b(e),d=T.now()+F)}function e(){d=0}function i(){this._call=this._time=this._next=null}function o(t,n,e){var o=new i;return o.restart(t,n,e),o}function r(){n(),++h;for(var t,e=m;e;)(t=d-e._time)>=0&&e._call.call(null,t),e=e._next;--h}function u(t){d=(w=t||T.now())+F,h=v=0;try{r()}finally{h=0,a(),d=0}}function c(){var t=T.now(),n=t-w;n>y&&(F-=n,w=t)}function a(){for(var t,n=m,e=1/0;n;)n._call?(e>n._time&&(e=n._time),n=(t=n)._next):n=t?t._next=n._next:m=n._next;_=t,f(e)}function f(t){if(!h){v&&(v=clearTimeout(v));var n=t-d;n>24?(1/0>t&&(v=setTimeout(u,n)),x&&(x=clearInterval(x))):(x||(x=setInterval(c,y)),h=1,b(u))}}function l(t,n,e){var o=new i;return n=null==n?0:+n,o.restart(function(e){o.stop(),t(e+n)},n,e),o}function s(t,e,o){var r=new i,u=e;return null==e?(r.restart(t,e,o),r):(e=+e,o=null==o?n():+o,r.restart(function c(n){n+=u,r.restart(c,u+=e,o),t(n)},e,o),r)}var m,_,p="0.4.4",h=0,v=0,x=0,y=1e3,w=0,d=0,F=0,T="object"==typeof performance?performance:Date,b="function"==typeof requestAnimationFrame?T===Date?function(t){requestAnimationFrame(function(){t(T.now())})}:requestAnimationFrame:function(t){setTimeout(t,17)};i.prototype=o.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||_===this||(_?_._next=this:m=this,_=this),this._call=t,this._time=i,f()},stop:function(){this._call&&(this._call=null,this._time=1/0,f())}},t.version=p,t.now=n,t.timer=o,t.timerFlush=r,t.timeout=l,t.interval=s}); \ No newline at end of file