Skip to content

Commit 0c61c2a

Browse files
committed
perf(tapclick): tapPolyfill is only used in UIWebView!
- improves drastically the responsiveness in WK and iOS Safari
1 parent 0883f98 commit 0c61c2a

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

src/components/tap-click/tap-click.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export class TapClick {
3232
this.activator = new Activator(app, config);
3333
}
3434

35-
this.usePolyfill = (config.get('tapPolyfill') === true);
35+
this.usePolyfill = config.getBoolean('tapPolyfill');
36+
console.debug('Using usePolyfill:', this.usePolyfill);
3637

3738
this.events.listen(document, 'click', this.click.bind(this), true);
3839
this.pointerEvents = this.events.pointerEvents({
@@ -96,7 +97,7 @@ export class TapClick {
9697
if (!this.app.isEnabled()) {
9798
preventReason = 'appDisabled';
9899

99-
} else if (!ev.isIonicTap && this.isDisabledNativeClick()) {
100+
} else if (this.usePolyfill && !ev.isIonicTap && this.isDisabledNativeClick()) {
100101
preventReason = 'nativeClick';
101102
}
102103

src/platform/platform-registry.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,17 @@ export const PLATFORM_CONFIGS: {[key: string]: PlatformConfig} = {
101101
settings: {
102102
autoFocusAssist: 'delay',
103103
hoverCSS: false,
104-
inputBlurring: isIOSDevice,
105-
inputCloning: isIOSDevice,
104+
inputBlurring: isIOS,
105+
inputCloning: isIOS,
106106
keyboardHeight: 300,
107107
mode: 'ios',
108-
scrollAssist: isIOSDevice,
108+
scrollAssist: isIOS,
109109
statusbarPadding: !!((<any>window).cordova),
110-
swipeBackEnabled: isIOSDevice,
110+
swipeBackEnabled: isIOS,
111111
swipeBackThreshold: 40,
112-
tapPolyfill: isIOSDevice,
113-
virtualScrollEventAssist: !(window.indexedDB),
114-
disableScrollAssist: isIOSDevice,
112+
tapPolyfill: isIOSUI,
113+
virtualScrollEventAssist: isIOSUI,
114+
disableScrollAssist: isIOS,
115115
},
116116
isMatch(p: Platform) {
117117
return p.isPlatformMatch('ios', ['iphone', 'ipad', 'ipod'], ['windows phone']);
@@ -219,14 +219,33 @@ export const PLATFORM_CONFIGS: {[key: string]: PlatformConfig} = {
219219
};
220220

221221

222-
function isIOSDevice(p: Platform) {
222+
function isIOS(p: Platform): boolean {
223223
// shortcut function to be reused internally
224224
// checks navigator.platform to see if it's an actual iOS device
225225
// this does not use the user-agent string because it is often spoofed
226226
// an actual iPad will return true, a chrome dev tools iPad will return false
227227
return p.testNavigatorPlatform('iphone|ipad|ipod');
228228
}
229229

230+
function isSafari(p: Platform): boolean {
231+
return p.testUserAgent('Safari');
232+
}
233+
234+
235+
function isWK(): boolean {
236+
return !!window['webkit'];
237+
}
238+
239+
// Commented out becuase it is not used yet
240+
// function isIOSWK(p: Platform): boolean {
241+
// return isIOS(p) && isWK();
242+
// }
243+
244+
function isIOSUI(p: Platform): boolean {
245+
return isIOS(p) && !isWK() && !isSafari(p);
246+
}
247+
248+
230249

231250
export const PlatformConfigToken = new OpaqueToken('PLTCONFIG');
232251

src/platform/platform.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,13 @@ export class Platform {
560560
}
561561
}
562562

563+
testUserAgent(expression: string): boolean {
564+
if (this._ua) {
565+
return this._ua.indexOf(expression) >= 0;
566+
}
567+
return false;
568+
}
569+
563570
/**
564571
* @private
565572
*/

0 commit comments

Comments
 (0)