mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-17 10:41:13 +08:00
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { defineCustomElements } from '@ionic/core/loader';
|
|
import { Config } from './providers/config';
|
|
import { IonicWindow } from './types/interfaces';
|
|
|
|
// Webpack import for ionicons
|
|
// @ts-ignore
|
|
// tslint:disable-next-line:no-import-side-effect
|
|
import '@ionic/core/dist/ionic/svg';
|
|
|
|
export function appInitialize(config: Config) {
|
|
return () => {
|
|
const win: IonicWindow = window as any;
|
|
if (typeof win !== 'undefined') {
|
|
const Ionic = win.Ionic = win.Ionic || {};
|
|
|
|
Ionic.config = config;
|
|
|
|
Ionic.ael = (elm, eventName, cb, opts) => {
|
|
if (elm.__zone_symbol__addEventListener) {
|
|
elm.__zone_symbol__addEventListener(eventName, cb, opts);
|
|
} else {
|
|
elm.addEventListener(eventName, cb, opts);
|
|
}
|
|
};
|
|
|
|
Ionic.rel = (elm, eventName, cb, opts) => {
|
|
if (elm.__zone_symbol__removeEventListener) {
|
|
elm.__zone_symbol__removeEventListener(eventName, cb, opts);
|
|
} else {
|
|
elm.removeEventListener(eventName, cb, opts);
|
|
}
|
|
};
|
|
|
|
Ionic.raf = (cb: any) => {
|
|
if (win.__zone_symbol__requestAnimationFrame) {
|
|
win.__zone_symbol__requestAnimationFrame(cb);
|
|
} else {
|
|
win.requestAnimationFrame(cb);
|
|
}
|
|
};
|
|
|
|
|
|
|
|
// define all of Ionic's custom elements
|
|
defineCustomElements(win);
|
|
}
|
|
};
|
|
}
|