forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp-initialize.ts
More file actions
43 lines (36 loc) · 1.21 KB
/
app-initialize.ts
File metadata and controls
43 lines (36 loc) · 1.21 KB
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
36
37
38
39
40
41
42
43
import { Config } from './providers/config';
// @ts-ignore
import { defineCustomElements } from '@ionic/core/dist/esm';
import { IonicWindow } from './types/interfaces';
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);
}
};
}