-
Notifications
You must be signed in to change notification settings - Fork 13.5k
/
app-initialize.ts
55 lines (44 loc) · 1.32 KB
/
app-initialize.ts
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
44
45
46
47
48
49
50
51
52
53
54
55
import { defineCustomElements } from '@ionic/core/loader';
import { Config } from './providers/config';
import { IonicWindow } from './types/interfaces';
export function appInitialize(config: Config, doc: Document) {
return (): any => {
const win: IonicWindow | undefined = doc.defaultView as any;
if (win) {
const Ionic = win.Ionic = win.Ionic || {};
Ionic.config = config;
Ionic.asyncQueue = false;
Ionic.ael = (elm, eventName, cb, opts) => {
if (elm.__zone_symbol__addEventListener && skipZone(eventName)) {
elm.__zone_symbol__addEventListener(eventName, cb, opts);
} else {
elm.addEventListener(eventName, cb, opts);
}
};
Ionic.rel = (elm, eventName, cb, opts) => {
if (elm.__zone_symbol__removeEventListener && skipZone(eventName)) {
elm.__zone_symbol__removeEventListener(eventName, cb, opts);
} else {
elm.removeEventListener(eventName, cb, opts);
}
};
return defineCustomElements(win, {
exclude: ['ion-tabs', 'ion-tab']
});
}
};
}
const SKIP_ZONE = [
'scroll',
'resize',
'touchstart',
'touchmove',
'touchend',
'mousedown',
'mousemove',
'mouseup',
'ionStyle',
];
function skipZone(eventName: string) {
return SKIP_ZONE.indexOf(eventName) >= 0;
}