Skip to content

Commit

Permalink
Merge pull request #9206 from manucorporat/disable-tapPolifyll-WK
Browse files Browse the repository at this point in the history
perf(tapclick): tapPolyfill is only used in UIWebView!
  • Loading branch information
manucorporat authored Nov 18, 2016
2 parents d81bd25 + 0c61c2a commit cfd9a90
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/components/tap-click/tap-click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export class TapClick {
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.pointerEvents = this.events.pointerEvents({
Expand Down Expand Up @@ -96,7 +97,7 @@ export class TapClick {
if (!this.app.isEnabled()) {
preventReason = 'appDisabled';

} else if (!ev.isIonicTap && this.isDisabledNativeClick()) {
} else if (this.usePolyfill && !ev.isIonicTap && this.isDisabledNativeClick()) {
preventReason = 'nativeClick';
}

Expand Down
35 changes: 27 additions & 8 deletions src/platform/platform-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@ export const PLATFORM_CONFIGS: {[key: string]: PlatformConfig} = {
settings: {
autoFocusAssist: 'delay',
hoverCSS: false,
inputBlurring: isIOSDevice,
inputCloning: isIOSDevice,
inputBlurring: isIOS,
inputCloning: isIOS,
keyboardHeight: 300,
mode: 'ios',
scrollAssist: isIOSDevice,
scrollAssist: isIOS,
statusbarPadding: !!((<any>window).cordova),
swipeBackEnabled: isIOSDevice,
swipeBackEnabled: isIOS,
swipeBackThreshold: 40,
tapPolyfill: isIOSDevice,
virtualScrollEventAssist: !(window.indexedDB),
disableScrollAssist: isIOSDevice,
tapPolyfill: isIOSUI,
virtualScrollEventAssist: isIOSUI,
disableScrollAssist: isIOS,
},
isMatch(p: Platform) {
return p.isPlatformMatch('ios', ['iphone', 'ipad', 'ipod'], ['windows phone']);
Expand Down Expand Up @@ -219,14 +219,33 @@ export const PLATFORM_CONFIGS: {[key: string]: PlatformConfig} = {
};


function isIOSDevice(p: Platform) {
function isIOS(p: Platform): boolean {
// shortcut function to be reused internally
// 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
// an actual iPad will return true, a chrome dev tools iPad will return false
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');

Expand Down
7 changes: 7 additions & 0 deletions src/platform/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,13 @@ export class Platform {
}
}

testUserAgent(expression: string): boolean {
if (this._ua) {
return this._ua.indexOf(expression) >= 0;
}
return false;
}

/**
* @private
*/
Expand Down

0 comments on commit cfd9a90

Please sign in to comment.