mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[hotfix] raf error in SSR (#405)
This commit is contained in:
parent
893393c6a6
commit
beaac87760
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user