Browse Source
* improve code style * move getRequestAnimationFrame to util * Fix ssr problem in BackTop, close #3343pull/3439/head
偏右
8 years ago
committed by
Benjy Cui
2 changed files with 15 additions and 10 deletions
@ -0,0 +1,12 @@ |
|||
export default function getRequestAnimationFrame() { |
|||
if (typeof window === 'undefined') { |
|||
return () => {}; |
|||
} |
|||
if (window.requestAnimationFrame) { |
|||
return window.requestAnimationFrame; |
|||
} |
|||
const prefix = ['moz', 'ms', 'webkit'].filter(key => `${key}RequestAnimationFrame` in window)[0]; |
|||
return prefix |
|||
? window[`${prefix}RequestAnimationFrame`] |
|||
: callback => setTimeout(callback, 1000 / 60); |
|||
} |
Loading…
Reference in new issue