aaac7fed
liuqimichale
add
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import { inBrowser } from './env'
const DEFAULT_INTERVAL = 100 / 60
function noop() {
}
export const requestAnimationFrame = (() => {
if (!inBrowser) {
/* istanbul ignore if */
return noop
}
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
// if all else fails, use setTimeout
function (callback) {
return window.setTimeout(callback, (callback.interval || DEFAULT_INTERVAL) / 2) // make interval as precise as possible.
}
})()
export const cancelAnimationFrame = (() => {
if (!inBrowser) {
/* istanbul ignore if */
return noop
}
return window.cancelAnimationFrame ||
window.webkitCancelAnimationFrame ||
window.mozCancelAnimationFrame ||
window.oCancelAnimationFrame ||
function (id) {
window.clearTimeout(id)
}
})()
|