1 | import getRequestAnimationFrame, { cancelRequestAnimationFrame as caf } from './getRequestAnimationFrame';
|
2 | var raf = getRequestAnimationFrame();
|
3 | export var cancelAnimationTimeout = function cancelAnimationTimeout(frame) {
|
4 | return caf(frame.id);
|
5 | };
|
6 | export var requestAnimationTimeout = function requestAnimationTimeout(callback, delay) {
|
7 | var start = Date.now();
|
8 |
|
9 | function timeout() {
|
10 | if (Date.now() - start >= delay) {
|
11 | callback.call();
|
12 | } else {
|
13 | frame.id = raf(timeout);
|
14 | }
|
15 | }
|
16 |
|
17 | var frame = {
|
18 | id: raf(timeout)
|
19 | };
|
20 | return frame;
|
21 | }; |
\ | No newline at end of file |