mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 10:20:19 +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 */
|
/* istanbul ignore next */
|
||||||
const global = isServer ? global : window;
|
const root = isServer ? global : window;
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
const iRaf =
|
const iRaf = root.requestAnimationFrame || root.webkitRequestAnimationFrame || fallback;
|
||||||
global.requestAnimationFrame ||
|
|
||||||
global.webkitRequestAnimationFrame ||
|
|
||||||
fallback;
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
const iCancel =
|
const iCancel = root.cancelAnimationFrame || root.webkitCancelAnimationFrame || root.clearTimeout;
|
||||||
global.cancelAnimationFrame ||
|
|
||||||
global.webkitCancelAnimationFrame ||
|
|
||||||
global.clearTimeout;
|
|
||||||
|
|
||||||
export function raf(fn) {
|
export function raf(fn) {
|
||||||
return iRaf.call(global, fn);
|
return iRaf.call(root, fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function cancel(id) {
|
export function cancel(id) {
|
||||||
iCancel.call(global, id);
|
iCancel.call(root, id);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user