Remove rAF export from ReactDOMFrameScheduling (#10337)
Fiber doesn't schedule animation callbacks anymore (though it does use the browser's requestAnimationFrame to polyfill requestIdleCallback). This removes the rAF export from ReactDOMFrameScheduling, since it's not being used.
Andrew Clark committed
Aug 2, 2017 at 19:56 UTC
372445735eda4d7960419947c49499019adb79db
1 file changed
+4
-24
src/renderers/shared/ReactDOMFrameScheduling.js
+4
-24
@@ -25,16 +25,10 @@ import type {Deadline} from 'ReactFiberReconciler';
25
var invariant = require('fbjs/lib/invariant');
26
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
27
28
-// TODO: There's no way to cancel these, because Fiber doesn't atm.
29
-let rAF: (callback: (time: number) => void) => number;
28
+// TODO: There's no way to cancel, because Fiber doesn't atm.
29
let rIC: (callback: (deadline: Deadline) => void) => number;
30
31
if (!ExecutionEnvironment.canUseDOM) {
33
- rAF = function(frameCallback: (time: number) => void): number {
34
- setTimeout(frameCallback, 16);
35
- return 0;
36
- };
37
-
32
rIC = function(frameCallback: (deadline: Deadline) => void): number {
33
setTimeout(() => {
34
frameCallback({
@@ -52,7 +46,7 @@ if (!ExecutionEnvironment.canUseDOM) {
46
'polyfill in older browsers.',
47
);
48
} else if (typeof requestIdleCallback !== 'function') {
55
- // Wrap requestAnimationFrame and polyfill requestIdleCallback.
49
+ // Polyfill requestIdleCallback.
50
51
var scheduledRAFCallback = null;
52
var scheduledRICCallback = null;
@@ -90,7 +84,7 @@ if (!ExecutionEnvironment.canUseDOM) {
84
isIdleScheduled = false;
85
var callback = scheduledRICCallback;
86
scheduledRICCallback = null;
93
- if (callback) {
87
+ if (callback !== null) {
88
callback(frameDeadlineObject);
89
}
90
};
@@ -130,23 +124,11 @@ if (!ExecutionEnvironment.canUseDOM) {
124
}
125
var callback = scheduledRAFCallback;
126
scheduledRAFCallback = null;
133
- if (callback) {
127
+ if (callback !== null) {
128
callback(rafTime);
129
}
130
};
131
138
- rAF = function(callback: (time: number) => void): number {
139
- // This assumes that we only schedule one callback at a time because that's
140
- // how Fiber uses it.
141
- scheduledRAFCallback = callback;
142
- if (!isAnimationFrameScheduled) {
143
- // If rIC didn't already schedule one, we need to schedule a frame.
144
- isAnimationFrameScheduled = true;
145
- requestAnimationFrame(animationTick);
146
- }
147
- return 0;
148
- };
149
-
132
rIC = function(callback: (deadline: Deadline) => void): number {
133
// This assumes that we only schedule one callback at a time because that's
134
// how Fiber uses it.
@@ -162,9 +144,7 @@ if (!ExecutionEnvironment.canUseDOM) {
144
return 0;
145
};
146
} else {
165
- rAF = requestAnimationFrame;
147
rIC = requestIdleCallback;
148
}
149
169
-exports.rAF = rAF;
150
exports.rIC = rIC;