mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 16:16:41 +08:00
perf(animation): avoid ngzone with requestAnimationFrame (#19457)
* add patched zone for animations * minify raf better
This commit is contained in:
@ -2,6 +2,23 @@ import { EventEmitter } from '@stencil/core';
|
||||
|
||||
import { Side } from '../interface';
|
||||
|
||||
declare const __zone_symbol__requestAnimationFrame: any;
|
||||
declare const requestAnimationFrame: any;
|
||||
|
||||
/**
|
||||
* Patched version of requestAnimationFrame that avoids ngzone
|
||||
* Use only when you know ngzone should not run
|
||||
*/
|
||||
export const raf = (h: any) => {
|
||||
if (typeof __zone_symbol__requestAnimationFrame === 'function') {
|
||||
return __zone_symbol__requestAnimationFrame(h);
|
||||
}
|
||||
if (typeof requestAnimationFrame === 'function') {
|
||||
return requestAnimationFrame(h);
|
||||
}
|
||||
return setTimeout(h);
|
||||
};
|
||||
|
||||
export const rIC = (callback: () => void) => {
|
||||
if ('requestIdleCallback' in window) {
|
||||
(window as any).requestIdleCallback(callback);
|
||||
|
||||
Reference in New Issue
Block a user