mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 01:17:15 +00:00
[hotfix] raf error in SSR (#405)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user