Skip to content

Commit

Permalink
Remove rAF export from ReactDOMFrameScheduling (#10337)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
acdlite authored Aug 2, 2017
1 parent 81706ee commit 3724457
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions src/renderers/shared/ReactDOMFrameScheduling.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,10 @@ import type {Deadline} from 'ReactFiberReconciler';
var invariant = require('fbjs/lib/invariant');
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');

// TODO: There's no way to cancel these, because Fiber doesn't atm.
let rAF: (callback: (time: number) => void) => number;
// TODO: There's no way to cancel, because Fiber doesn't atm.
let rIC: (callback: (deadline: Deadline) => void) => number;

if (!ExecutionEnvironment.canUseDOM) {
rAF = function(frameCallback: (time: number) => void): number {
setTimeout(frameCallback, 16);
return 0;
};

rIC = function(frameCallback: (deadline: Deadline) => void): number {
setTimeout(() => {
frameCallback({
Expand All @@ -52,7 +46,7 @@ if (!ExecutionEnvironment.canUseDOM) {
'polyfill in older browsers.',
);
} else if (typeof requestIdleCallback !== 'function') {
// Wrap requestAnimationFrame and polyfill requestIdleCallback.
// Polyfill requestIdleCallback.

var scheduledRAFCallback = null;
var scheduledRICCallback = null;
Expand Down Expand Up @@ -90,7 +84,7 @@ if (!ExecutionEnvironment.canUseDOM) {
isIdleScheduled = false;
var callback = scheduledRICCallback;
scheduledRICCallback = null;
if (callback) {
if (callback !== null) {
callback(frameDeadlineObject);
}
};
Expand Down Expand Up @@ -130,23 +124,11 @@ if (!ExecutionEnvironment.canUseDOM) {
}
var callback = scheduledRAFCallback;
scheduledRAFCallback = null;
if (callback) {
if (callback !== null) {
callback(rafTime);
}
};

rAF = function(callback: (time: number) => void): number {
// This assumes that we only schedule one callback at a time because that's
// how Fiber uses it.
scheduledRAFCallback = callback;
if (!isAnimationFrameScheduled) {
// If rIC didn't already schedule one, we need to schedule a frame.
isAnimationFrameScheduled = true;
requestAnimationFrame(animationTick);
}
return 0;
};

rIC = function(callback: (deadline: Deadline) => void): number {
// This assumes that we only schedule one callback at a time because that's
// how Fiber uses it.
Expand All @@ -162,9 +144,7 @@ if (!ExecutionEnvironment.canUseDOM) {
return 0;
};
} else {
rAF = requestAnimationFrame;
rIC = requestIdleCallback;
}

exports.rAF = rAF;
exports.rIC = rIC;

0 comments on commit 3724457

Please sign in to comment.