first commit
This commit is contained in:
13
node_modules/d3-timer/LICENSE
generated
vendored
Normal file
13
node_modules/d3-timer/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
Copyright 2010-2021 Mike Bostock
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose
|
||||
with or without fee is hereby granted, provided that the above copyright notice
|
||||
and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
87
node_modules/d3-timer/README.md
generated
vendored
Normal file
87
node_modules/d3-timer/README.md
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
# d3-timer
|
||||
|
||||
This module provides an efficient queue capable of managing thousands of concurrent animations, while guaranteeing consistent, synchronized timing with concurrent or staged animations. Internally, it uses [requestAnimationFrame](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame) for fluid animation (if available), switching to [setTimeout](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout) for delays longer than 24ms.
|
||||
|
||||
## Installing
|
||||
|
||||
If you use npm, `npm install d3-timer`. You can also download the [latest release on GitHub](https://github.com/d3/d3-timer/releases/latest). For vanilla HTML in modern browsers, import d3-timer from Skypack:
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
|
||||
import {timer} from "https://cdn.skypack.dev/d3-timer@3";
|
||||
|
||||
const t = timer(callback);
|
||||
|
||||
</script>
|
||||
```
|
||||
|
||||
For legacy environments, you can load d3-timer’s UMD bundle from an npm-based CDN such as jsDelivr; a `d3` global is exported:
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/d3-timer@3"></script>
|
||||
<script>
|
||||
|
||||
const timer = d3.timer(callback);
|
||||
|
||||
</script>
|
||||
```
|
||||
|
||||
## API Reference
|
||||
|
||||
<a name="now" href="#now">#</a> d3.<b>now</b>() [<>](https://github.com/d3/d3-timer/blob/master/src/timer.js "Source")
|
||||
|
||||
Returns the current time as defined by [performance.now](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now) if available, and [Date.now](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/now) if not. The current time is updated at the start of a frame; it is thus consistent during the frame, and any timers scheduled during the same frame will be synchronized. If this method is called outside of a frame, such as in response to a user event, the current time is calculated and then fixed until the next frame, again ensuring consistent timing during event handling.
|
||||
|
||||
<a name="timer" href="#timer">#</a> d3.<b>timer</b>(<i>callback</i>[, <i>delay</i>[, <i>time</i>]]) [<>](https://github.com/d3/d3-timer/blob/master/src/timer.js "Source")
|
||||
|
||||
Schedules a new timer, invoking the specified *callback* repeatedly until the timer is [stopped](#timer_stop). An optional numeric *delay* in milliseconds may be specified to invoke the given *callback* after a delay; if *delay* is not specified, it defaults to zero. The delay is relative to the specified *time* in milliseconds; if *time* is not specified, it defaults to [now](#now).
|
||||
|
||||
The *callback* is passed the (apparent) *elapsed* time since the timer became active. For example:
|
||||
|
||||
```js
|
||||
const t = d3.timer((elapsed) => {
|
||||
console.log(elapsed);
|
||||
if (elapsed > 200) t.stop();
|
||||
}, 150);
|
||||
```
|
||||
|
||||
This produces roughly the following console output:
|
||||
|
||||
```
|
||||
3
|
||||
25
|
||||
48
|
||||
65
|
||||
85
|
||||
106
|
||||
125
|
||||
146
|
||||
167
|
||||
189
|
||||
209
|
||||
```
|
||||
|
||||
(The exact values may vary depending on your JavaScript runtime and what else your computer is doing.) Note that the first *elapsed* time is 3ms: this is the elapsed time since the timer started, not since the timer was scheduled. Here the timer started 150ms after it was scheduled due to the specified delay. The apparent *elapsed* time may be less than the true *elapsed* time if the page is backgrounded and [requestAnimationFrame](https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame) is paused; in the background, apparent time is frozen.
|
||||
|
||||
If [timer](#timer) is called within the callback of another timer, the new timer callback (if eligible as determined by the specified *delay* and *time*) will be invoked immediately at the end of the current frame, rather than waiting until the next frame. Within a frame, timer callbacks are guaranteed to be invoked in the order they were scheduled, regardless of their start time.
|
||||
|
||||
<a name="timer_restart" href="#timer_restart">#</a> <i>timer</i>.<b>restart</b>(<i>callback</i>[, <i>delay</i>[, <i>time</i>]]) [<>](https://github.com/d3/d3-timer/blob/master/src/timer.js "Source")
|
||||
|
||||
Restart a timer with the specified *callback* and optional *delay* and *time*. This is equivalent to stopping this timer and creating a new timer with the specified arguments, although this timer retains the original invocation priority.
|
||||
|
||||
<a name="timer_stop" href="#timer_stop">#</a> <i>timer</i>.<b>stop</b>() [<>](https://github.com/d3/d3-timer/blob/master/src/timer.js "Source")
|
||||
|
||||
Stops this timer, preventing subsequent callbacks. This method has no effect if the timer has already stopped.
|
||||
|
||||
<a name="timerFlush" href="#timerFlush">#</a> d3.<b>timerFlush</b>() [<>](https://github.com/d3/d3-timer/blob/master/src/timer.js "Source")
|
||||
|
||||
Immediately invoke any eligible timer callbacks. Note that zero-delay timers are normally first executed after one frame (~17ms). This can cause a brief flicker because the browser renders the page twice: once at the end of the first event loop, then again immediately on the first timer callback. By flushing the timer queue at the end of the first event loop, you can run any zero-delay timers immediately and avoid the flicker.
|
||||
|
||||
<a name="timeout" href="#timeout">#</a> d3.<b>timeout</b>(<i>callback</i>[, <i>delay</i>[, <i>time</i>]]) [<>](https://github.com/d3/d3-timer/blob/master/src/timeout.js "Source")
|
||||
|
||||
Like [timer](#timer), except the timer automatically [stops](#timer_stop) on its first callback. A suitable replacement for [setTimeout](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout) that is guaranteed to not run in the background. The *callback* is passed the elapsed time.
|
||||
|
||||
<a name="interval" href="#interval">#</a> d3.<b>interval</b>(<i>callback</i>[, <i>delay</i>[, <i>time</i>]]) [<>](https://github.com/d3/d3-timer/blob/master/src/interval.js "Source")
|
||||
|
||||
Like [timer](#timer), except the *callback* is invoked only every *delay* milliseconds; if *delay* is not specified, this is equivalent to [timer](#timer). A suitable replacement for [setInterval](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval) that is guaranteed to not run in the background. The *callback* is passed the elapsed time.
|
||||
153
node_modules/d3-timer/dist/d3-timer.js
generated
vendored
Normal file
153
node_modules/d3-timer/dist/d3-timer.js
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
// https://d3js.org/d3-timer/ v3.0.1 Copyright 2010-2021 Mike Bostock
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {}));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
var frame = 0, // is an animation frame pending?
|
||||
timeout$1 = 0, // is a timeout pending?
|
||||
interval$1 = 0, // are any timers active?
|
||||
pokeDelay = 1000, // how frequently we check for clock skew
|
||||
taskHead,
|
||||
taskTail,
|
||||
clockLast = 0,
|
||||
clockNow = 0,
|
||||
clockSkew = 0,
|
||||
clock = typeof performance === "object" && performance.now ? performance : Date,
|
||||
setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); };
|
||||
|
||||
function now() {
|
||||
return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
|
||||
}
|
||||
|
||||
function clearNow() {
|
||||
clockNow = 0;
|
||||
}
|
||||
|
||||
function Timer() {
|
||||
this._call =
|
||||
this._time =
|
||||
this._next = null;
|
||||
}
|
||||
|
||||
Timer.prototype = timer.prototype = {
|
||||
constructor: Timer,
|
||||
restart: function(callback, delay, time) {
|
||||
if (typeof callback !== "function") throw new TypeError("callback is not a function");
|
||||
time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
|
||||
if (!this._next && taskTail !== this) {
|
||||
if (taskTail) taskTail._next = this;
|
||||
else taskHead = this;
|
||||
taskTail = this;
|
||||
}
|
||||
this._call = callback;
|
||||
this._time = time;
|
||||
sleep();
|
||||
},
|
||||
stop: function() {
|
||||
if (this._call) {
|
||||
this._call = null;
|
||||
this._time = Infinity;
|
||||
sleep();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function timer(callback, delay, time) {
|
||||
var t = new Timer;
|
||||
t.restart(callback, delay, time);
|
||||
return t;
|
||||
}
|
||||
|
||||
function timerFlush() {
|
||||
now(); // Get the current time, if not already set.
|
||||
++frame; // Pretend we’ve set an alarm, if we haven’t already.
|
||||
var t = taskHead, e;
|
||||
while (t) {
|
||||
if ((e = clockNow - t._time) >= 0) t._call.call(undefined, e);
|
||||
t = t._next;
|
||||
}
|
||||
--frame;
|
||||
}
|
||||
|
||||
function wake() {
|
||||
clockNow = (clockLast = clock.now()) + clockSkew;
|
||||
frame = timeout$1 = 0;
|
||||
try {
|
||||
timerFlush();
|
||||
} finally {
|
||||
frame = 0;
|
||||
nap();
|
||||
clockNow = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function poke() {
|
||||
var now = clock.now(), delay = now - clockLast;
|
||||
if (delay > pokeDelay) clockSkew -= delay, clockLast = now;
|
||||
}
|
||||
|
||||
function nap() {
|
||||
var t0, t1 = taskHead, t2, time = Infinity;
|
||||
while (t1) {
|
||||
if (t1._call) {
|
||||
if (time > t1._time) time = t1._time;
|
||||
t0 = t1, t1 = t1._next;
|
||||
} else {
|
||||
t2 = t1._next, t1._next = null;
|
||||
t1 = t0 ? t0._next = t2 : taskHead = t2;
|
||||
}
|
||||
}
|
||||
taskTail = t0;
|
||||
sleep(time);
|
||||
}
|
||||
|
||||
function sleep(time) {
|
||||
if (frame) return; // Soonest alarm already set, or will be.
|
||||
if (timeout$1) timeout$1 = clearTimeout(timeout$1);
|
||||
var delay = time - clockNow; // Strictly less than if we recomputed clockNow.
|
||||
if (delay > 24) {
|
||||
if (time < Infinity) timeout$1 = setTimeout(wake, time - clock.now() - clockSkew);
|
||||
if (interval$1) interval$1 = clearInterval(interval$1);
|
||||
} else {
|
||||
if (!interval$1) clockLast = clock.now(), interval$1 = setInterval(poke, pokeDelay);
|
||||
frame = 1, setFrame(wake);
|
||||
}
|
||||
}
|
||||
|
||||
function timeout(callback, delay, time) {
|
||||
var t = new Timer;
|
||||
delay = delay == null ? 0 : +delay;
|
||||
t.restart(elapsed => {
|
||||
t.stop();
|
||||
callback(elapsed + delay);
|
||||
}, delay, time);
|
||||
return t;
|
||||
}
|
||||
|
||||
function interval(callback, delay, time) {
|
||||
var t = new Timer, total = delay;
|
||||
if (delay == null) return t.restart(callback, delay, time), t;
|
||||
t._restart = t.restart;
|
||||
t.restart = function(callback, delay, time) {
|
||||
delay = +delay, time = time == null ? now() : +time;
|
||||
t._restart(function tick(elapsed) {
|
||||
elapsed += total;
|
||||
t._restart(tick, total += delay, time);
|
||||
callback(elapsed);
|
||||
}, delay, time);
|
||||
};
|
||||
t.restart(callback, delay, time);
|
||||
return t;
|
||||
}
|
||||
|
||||
exports.interval = interval;
|
||||
exports.now = now;
|
||||
exports.timeout = timeout;
|
||||
exports.timer = timer;
|
||||
exports.timerFlush = timerFlush;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
2
node_modules/d3-timer/dist/d3-timer.min.js
generated
vendored
Normal file
2
node_modules/d3-timer/dist/d3-timer.min.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
// https://d3js.org/d3-timer/ v3.0.1 Copyright 2010-2021 Mike Bostock
|
||||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).d3=t.d3||{})}(this,(function(t){"use strict";var n,e,o=0,i=0,r=0,l=0,u=0,a=0,s="object"==typeof performance&&performance.now?performance:Date,c="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function f(){return u||(c(_),u=s.now()+a)}function _(){u=0}function m(){this._call=this._time=this._next=null}function p(t,n,e){var o=new m;return o.restart(t,n,e),o}function w(){f(),++o;for(var t,e=n;e;)(t=u-e._time)>=0&&e._call.call(void 0,t),e=e._next;--o}function d(){u=(l=s.now())+a,o=i=0;try{w()}finally{o=0,function(){var t,o,i=n,r=1/0;for(;i;)i._call?(r>i._time&&(r=i._time),t=i,i=i._next):(o=i._next,i._next=null,i=t?t._next=o:n=o);e=t,y(r)}(),u=0}}function h(){var t=s.now(),n=t-l;n>1e3&&(a-=n,l=t)}function y(t){o||(i&&(i=clearTimeout(i)),t-u>24?(t<1/0&&(i=setTimeout(d,t-s.now()-a)),r&&(r=clearInterval(r))):(r||(l=s.now(),r=setInterval(h,1e3)),o=1,c(d)))}m.prototype=p.prototype={constructor:m,restart:function(t,o,i){if("function"!=typeof t)throw new TypeError("callback is not a function");i=(null==i?f():+i)+(null==o?0:+o),this._next||e===this||(e?e._next=this:n=this,e=this),this._call=t,this._time=i,y()},stop:function(){this._call&&(this._call=null,this._time=1/0,y())}},t.interval=function(t,n,e){var o=new m,i=n;return null==n?(o.restart(t,n,e),o):(o._restart=o.restart,o.restart=function(t,n,e){n=+n,e=null==e?f():+e,o._restart((function r(l){l+=i,o._restart(r,i+=n,e),t(l)}),n,e)},o.restart(t,n,e),o)},t.now=f,t.timeout=function(t,n,e){var o=new m;return n=null==n?0:+n,o.restart((e=>{o.stop(),t(e+n)}),n,e),o},t.timer=p,t.timerFlush=w,Object.defineProperty(t,"__esModule",{value:!0})}));
|
||||
53
node_modules/d3-timer/package.json
generated
vendored
Normal file
53
node_modules/d3-timer/package.json
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "d3-timer",
|
||||
"version": "3.0.1",
|
||||
"description": "An efficient queue capable of managing thousands of concurrent animations.",
|
||||
"homepage": "https://d3js.org/d3-timer/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/d3/d3-timer.git"
|
||||
},
|
||||
"keywords": [
|
||||
"d3",
|
||||
"d3-module",
|
||||
"timer",
|
||||
"transition",
|
||||
"animation",
|
||||
"requestAnimationFrame",
|
||||
"setTimeout",
|
||||
"setInterval"
|
||||
],
|
||||
"license": "ISC",
|
||||
"author": {
|
||||
"name": "Mike Bostock",
|
||||
"url": "http://bost.ocks.org/mike"
|
||||
},
|
||||
"type": "module",
|
||||
"files": [
|
||||
"dist/**/*.js",
|
||||
"src/**/*.js"
|
||||
],
|
||||
"module": "src/index.js",
|
||||
"main": "src/index.js",
|
||||
"jsdelivr": "dist/d3-timer.min.js",
|
||||
"unpkg": "dist/d3-timer.min.js",
|
||||
"exports": {
|
||||
"umd": "./dist/d3-timer.min.js",
|
||||
"default": "./src/index.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"devDependencies": {
|
||||
"eslint": "7",
|
||||
"mocha": "8",
|
||||
"rollup": "2",
|
||||
"rollup-plugin-terser": "7"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha 'test/**/*-test.js' && eslint src test",
|
||||
"prepublishOnly": "rm -rf dist && yarn test && rollup -c",
|
||||
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd -"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
}
|
||||
13
node_modules/d3-timer/src/index.js
generated
vendored
Normal file
13
node_modules/d3-timer/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
export {
|
||||
now,
|
||||
timer,
|
||||
timerFlush
|
||||
} from "./timer.js";
|
||||
|
||||
export {
|
||||
default as timeout
|
||||
} from "./timeout.js";
|
||||
|
||||
export {
|
||||
default as interval
|
||||
} from "./interval.js";
|
||||
17
node_modules/d3-timer/src/interval.js
generated
vendored
Normal file
17
node_modules/d3-timer/src/interval.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import {Timer, now} from "./timer.js";
|
||||
|
||||
export default function(callback, delay, time) {
|
||||
var t = new Timer, total = delay;
|
||||
if (delay == null) return t.restart(callback, delay, time), t;
|
||||
t._restart = t.restart;
|
||||
t.restart = function(callback, delay, time) {
|
||||
delay = +delay, time = time == null ? now() : +time;
|
||||
t._restart(function tick(elapsed) {
|
||||
elapsed += total;
|
||||
t._restart(tick, total += delay, time);
|
||||
callback(elapsed);
|
||||
}, delay, time);
|
||||
}
|
||||
t.restart(callback, delay, time);
|
||||
return t;
|
||||
}
|
||||
11
node_modules/d3-timer/src/timeout.js
generated
vendored
Normal file
11
node_modules/d3-timer/src/timeout.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import {Timer} from "./timer.js";
|
||||
|
||||
export default function(callback, delay, time) {
|
||||
var t = new Timer;
|
||||
delay = delay == null ? 0 : +delay;
|
||||
t.restart(elapsed => {
|
||||
t.stop();
|
||||
callback(elapsed + delay);
|
||||
}, delay, time);
|
||||
return t;
|
||||
}
|
||||
110
node_modules/d3-timer/src/timer.js
generated
vendored
Normal file
110
node_modules/d3-timer/src/timer.js
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
var frame = 0, // is an animation frame pending?
|
||||
timeout = 0, // is a timeout pending?
|
||||
interval = 0, // are any timers active?
|
||||
pokeDelay = 1000, // how frequently we check for clock skew
|
||||
taskHead,
|
||||
taskTail,
|
||||
clockLast = 0,
|
||||
clockNow = 0,
|
||||
clockSkew = 0,
|
||||
clock = typeof performance === "object" && performance.now ? performance : Date,
|
||||
setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); };
|
||||
|
||||
export function now() {
|
||||
return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
|
||||
}
|
||||
|
||||
function clearNow() {
|
||||
clockNow = 0;
|
||||
}
|
||||
|
||||
export function Timer() {
|
||||
this._call =
|
||||
this._time =
|
||||
this._next = null;
|
||||
}
|
||||
|
||||
Timer.prototype = timer.prototype = {
|
||||
constructor: Timer,
|
||||
restart: function(callback, delay, time) {
|
||||
if (typeof callback !== "function") throw new TypeError("callback is not a function");
|
||||
time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
|
||||
if (!this._next && taskTail !== this) {
|
||||
if (taskTail) taskTail._next = this;
|
||||
else taskHead = this;
|
||||
taskTail = this;
|
||||
}
|
||||
this._call = callback;
|
||||
this._time = time;
|
||||
sleep();
|
||||
},
|
||||
stop: function() {
|
||||
if (this._call) {
|
||||
this._call = null;
|
||||
this._time = Infinity;
|
||||
sleep();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export function timer(callback, delay, time) {
|
||||
var t = new Timer;
|
||||
t.restart(callback, delay, time);
|
||||
return t;
|
||||
}
|
||||
|
||||
export function timerFlush() {
|
||||
now(); // Get the current time, if not already set.
|
||||
++frame; // Pretend we’ve set an alarm, if we haven’t already.
|
||||
var t = taskHead, e;
|
||||
while (t) {
|
||||
if ((e = clockNow - t._time) >= 0) t._call.call(undefined, e);
|
||||
t = t._next;
|
||||
}
|
||||
--frame;
|
||||
}
|
||||
|
||||
function wake() {
|
||||
clockNow = (clockLast = clock.now()) + clockSkew;
|
||||
frame = timeout = 0;
|
||||
try {
|
||||
timerFlush();
|
||||
} finally {
|
||||
frame = 0;
|
||||
nap();
|
||||
clockNow = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function poke() {
|
||||
var now = clock.now(), delay = now - clockLast;
|
||||
if (delay > pokeDelay) clockSkew -= delay, clockLast = now;
|
||||
}
|
||||
|
||||
function nap() {
|
||||
var t0, t1 = taskHead, t2, time = Infinity;
|
||||
while (t1) {
|
||||
if (t1._call) {
|
||||
if (time > t1._time) time = t1._time;
|
||||
t0 = t1, t1 = t1._next;
|
||||
} else {
|
||||
t2 = t1._next, t1._next = null;
|
||||
t1 = t0 ? t0._next = t2 : taskHead = t2;
|
||||
}
|
||||
}
|
||||
taskTail = t0;
|
||||
sleep(time);
|
||||
}
|
||||
|
||||
function sleep(time) {
|
||||
if (frame) return; // Soonest alarm already set, or will be.
|
||||
if (timeout) timeout = clearTimeout(timeout);
|
||||
var delay = time - clockNow; // Strictly less than if we recomputed clockNow.
|
||||
if (delay > 24) {
|
||||
if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
|
||||
if (interval) interval = clearInterval(interval);
|
||||
} else {
|
||||
if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
|
||||
frame = 1, setFrame(wake);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user