mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-15 09:34:19 +08:00
perf(events): bypass ngzone
This commit is contained in:
@ -29,3 +29,40 @@ export { PopoverController, PopoverProxy } from './providers/popover-controller'
|
||||
export { ToastController, ToastProxy } from './providers/toast-controller';
|
||||
|
||||
export * from './types/interfaces';
|
||||
|
||||
|
||||
import { IonicWindow } from './types/interfaces';
|
||||
|
||||
const win = (window as IonicWindow);
|
||||
const Ionic = win.Ionic;
|
||||
|
||||
if (!Ionic) {
|
||||
throw new Error(`ionic.js script missing from index.html`);
|
||||
|
||||
} else {
|
||||
|
||||
Ionic.ael = function ngAddEventListener(elm, eventName, cb, opts) {
|
||||
if (elm.__zone_symbol__addEventListener) {
|
||||
elm.__zone_symbol__addEventListener(eventName, cb, opts);
|
||||
} else {
|
||||
elm.addEventListener(eventName, cb, opts);
|
||||
}
|
||||
};
|
||||
|
||||
Ionic.rel = function ngRemoveEventListener(elm, eventName, cb, opts) {
|
||||
if (elm.__zone_symbol__removeEventListener) {
|
||||
elm.__zone_symbol__removeEventListener(eventName, cb, opts);
|
||||
} else {
|
||||
elm.removeEventListener(eventName, cb, opts);
|
||||
}
|
||||
};
|
||||
|
||||
Ionic.raf = function ngRequestAnimationFrame(cb: any) {
|
||||
if (win.__zone_symbol__requestAnimationFrame) {
|
||||
win.__zone_symbol__requestAnimationFrame(cb);
|
||||
} else {
|
||||
win.requestAnimationFrame(cb);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -24,13 +24,12 @@ export interface AngularEscapeHatch extends EscapeHatch {
|
||||
|
||||
export interface IonicGlobal {
|
||||
config: any;
|
||||
Events: {
|
||||
subscribe: (topic: string, ...handlers: Function[]) => void;
|
||||
unsubscribe: (topic: string, handler: Function) => void;
|
||||
publish: (topic: string, ...args: any[]) => any[];
|
||||
};
|
||||
ael: (elm: any, eventName: string, cb: Function, opts: any) => void;
|
||||
raf: Function;
|
||||
rel: (elm: any, eventName: string, cb: Function, opts: any) => void;
|
||||
}
|
||||
|
||||
export interface IonicWindow extends Window {
|
||||
Ionic: IonicGlobal;
|
||||
__zone_symbol__requestAnimationFrame: Function;
|
||||
}
|
||||
|
Reference in New Issue
Block a user