1 | import { extendComponent } from './extendComponent';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export var safeRequestAnimationFrame = function (component) {
|
9 | var activeTimeouts;
|
10 | return function (cb) {
|
11 | if (!activeTimeouts) {
|
12 | activeTimeouts = new Set();
|
13 | extendComponent(component, {
|
14 | componentWillUnmount: function () {
|
15 | activeTimeouts.forEach(function (id) { return cancelAnimationFrame(id); });
|
16 | },
|
17 | });
|
18 | }
|
19 | var timeoutId = requestAnimationFrame(function () {
|
20 | activeTimeouts.delete(timeoutId);
|
21 | cb();
|
22 | });
|
23 | activeTimeouts.add(timeoutId);
|
24 | };
|
25 | };
|
26 |
|
\ | No newline at end of file |