perf(tapclick): tapPolyfill is only used in UIWebView!

- improves drastically the responsiveness in WK and iOS Safari
This commit is contained in:
Manu Mtz.-Almeida
2016-11-17 17:27:45 +01:00
parent 0883f98b0f
commit 0c61c2a8c1
3 changed files with 37 additions and 10 deletions

View File

@ -32,7 +32,8 @@ export class TapClick {
this.activator = new Activator(app, config); this.activator = new Activator(app, config);
} }
this.usePolyfill = (config.get('tapPolyfill') === true); this.usePolyfill = config.getBoolean('tapPolyfill');
console.debug('Using usePolyfill:', this.usePolyfill);
this.events.listen(document, 'click', this.click.bind(this), true); this.events.listen(document, 'click', this.click.bind(this), true);
this.pointerEvents = this.events.pointerEvents({ this.pointerEvents = this.events.pointerEvents({
@ -96,7 +97,7 @@ export class TapClick {
if (!this.app.isEnabled()) { if (!this.app.isEnabled()) {
preventReason = 'appDisabled'; preventReason = 'appDisabled';
} else if (!ev.isIonicTap && this.isDisabledNativeClick()) { } else if (this.usePolyfill && !ev.isIonicTap && this.isDisabledNativeClick()) {
preventReason = 'nativeClick'; preventReason = 'nativeClick';
} }

View File

@ -101,17 +101,17 @@ export const PLATFORM_CONFIGS: {[key: string]: PlatformConfig} = {
settings: { settings: {
autoFocusAssist: 'delay', autoFocusAssist: 'delay',
hoverCSS: false, hoverCSS: false,
inputBlurring: isIOSDevice, inputBlurring: isIOS,
inputCloning: isIOSDevice, inputCloning: isIOS,
keyboardHeight: 300, keyboardHeight: 300,
mode: 'ios', mode: 'ios',
scrollAssist: isIOSDevice, scrollAssist: isIOS,
statusbarPadding: !!((<any>window).cordova), statusbarPadding: !!((<any>window).cordova),
swipeBackEnabled: isIOSDevice, swipeBackEnabled: isIOS,
swipeBackThreshold: 40, swipeBackThreshold: 40,
tapPolyfill: isIOSDevice, tapPolyfill: isIOSUI,
virtualScrollEventAssist: !(window.indexedDB), virtualScrollEventAssist: isIOSUI,
disableScrollAssist: isIOSDevice, disableScrollAssist: isIOS,
}, },
isMatch(p: Platform) { isMatch(p: Platform) {
return p.isPlatformMatch('ios', ['iphone', 'ipad', 'ipod'], ['windows phone']); return p.isPlatformMatch('ios', ['iphone', 'ipad', 'ipod'], ['windows phone']);
@ -219,7 +219,7 @@ export const PLATFORM_CONFIGS: {[key: string]: PlatformConfig} = {
}; };
function isIOSDevice(p: Platform) { function isIOS(p: Platform): boolean {
// shortcut function to be reused internally // shortcut function to be reused internally
// checks navigator.platform to see if it's an actual iOS device // checks navigator.platform to see if it's an actual iOS device
// this does not use the user-agent string because it is often spoofed // this does not use the user-agent string because it is often spoofed
@ -227,6 +227,25 @@ function isIOSDevice(p: Platform) {
return p.testNavigatorPlatform('iphone|ipad|ipod'); return p.testNavigatorPlatform('iphone|ipad|ipod');
} }
function isSafari(p: Platform): boolean {
return p.testUserAgent('Safari');
}
function isWK(): boolean {
return !!window['webkit'];
}
// Commented out becuase it is not used yet
// function isIOSWK(p: Platform): boolean {
// return isIOS(p) && isWK();
// }
function isIOSUI(p: Platform): boolean {
return isIOS(p) && !isWK() && !isSafari(p);
}
export const PlatformConfigToken = new OpaqueToken('PLTCONFIG'); export const PlatformConfigToken = new OpaqueToken('PLTCONFIG');

View File

@ -560,6 +560,13 @@ export class Platform {
} }
} }
testUserAgent(expression: string): boolean {
if (this._ua) {
return this._ua.indexOf(expression) >= 0;
}
return false;
}
/** /**
* @private * @private
*/ */