[hotfix] raf error in SSR (#405)

This commit is contained in:
neverland 2017-12-11 10:23:44 +08:00 committed by GitHub
parent 893393c6a6
commit beaac87760
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,24 +16,18 @@ function fallback(fn) {
}
/* istanbul ignore next */
const global = isServer ? global : window;
const root = isServer ? global : window;
/* istanbul ignore next */
const iRaf =
global.requestAnimationFrame ||
global.webkitRequestAnimationFrame ||
fallback;
const iRaf = root.requestAnimationFrame || root.webkitRequestAnimationFrame || fallback;
/* istanbul ignore next */
const iCancel =
global.cancelAnimationFrame ||
global.webkitCancelAnimationFrame ||
global.clearTimeout;
const iCancel = root.cancelAnimationFrame || root.webkitCancelAnimationFrame || root.clearTimeout;
export function raf(fn) {
return iRaf.call(global, fn);
return iRaf.call(root, fn);
}
export function cancel(id) {
iCancel.call(global, id);
iCancel.call(root, id);
}