mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 04:53:58 +08:00
chore(): use native raf/setTimeout
This commit is contained in:
@ -24,9 +24,12 @@
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
export const raf = window.requestAnimationFrame.bind(window);
|
// use native raf rather than the zone wrapped one
|
||||||
|
export const raf = (window[window['Zone']['__symbol__']('requestAnimationFrame')] || window[window['Zone']['__symbol__']('webkitRequestAnimationFrame')])['bind'](window);
|
||||||
export const cancelRaf = window.cancelAnimationFrame.bind(window);
|
export const cancelRaf = window.cancelAnimationFrame.bind(window);
|
||||||
|
|
||||||
|
export const nativeTimeout = window[window['Zone']['__symbol__']('setTimeout')]['bind'](window);
|
||||||
|
export const clearNativeTimeout = window[window['Zone']['__symbol__']('clearTimeout')]['bind'](window);
|
||||||
|
|
||||||
export function rafFrames(framesToWait, callback) {
|
export function rafFrames(framesToWait, callback) {
|
||||||
framesToWait = Math.ceil(framesToWait);
|
framesToWait = Math.ceil(framesToWait);
|
||||||
@ -35,9 +38,9 @@ export function rafFrames(framesToWait, callback) {
|
|||||||
raf(callback);
|
raf(callback);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
nativeTimeout(() => {
|
||||||
raf(callback);
|
raf(callback);
|
||||||
}, (framesToWait - 1) * 17);
|
}, (framesToWait - 1) * 16.6667);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user