fix(platform): update ripple activator fn

Closes #671
This commit is contained in:
Adam Bradley
2015-12-02 10:34:29 -06:00
parent 6943ee6083
commit dbeb0f78ae
4 changed files with 120 additions and 13 deletions

View File

@@ -7,8 +7,8 @@
+*/
import * as util from '../util/util';
import * as dom from '../util/dom';
import {getQuerystring, extend} from '../util/util';
import {ready, windowDimensions, flushDimensionCache} from '../util/dom';
/**
@@ -162,7 +162,7 @@ export class Platform {
} else {
// there is no custom ready method from the engine
// use the default dom ready
dom.ready(resolve);
ready(resolve);
}
}
@@ -186,7 +186,7 @@ export class Platform {
url(val) {
if (arguments.length) {
this._url = val;
this._qs = util.getQuerystring(val);
this._qs = getQuerystring(val);
}
return this._url;
}
@@ -204,17 +204,17 @@ export class Platform {
navigatorPlatform(val) {
if (arguments.length) {
this._bPlt = (val || '').toLowerCase();
this._bPlt = val;
}
return this._bPlt || '';
}
width() {
return dom.windowDimensions().width;
return windowDimensions().width;
}
height() {
return dom.windowDimensions().height;
return windowDimensions().height;
}
isPortrait() {
@@ -230,7 +230,7 @@ export class Platform {
clearTimeout(self._resizeTimer);
self._resizeTimer = setTimeout(() => {
dom.flushDimensionCache();
flushDimensionCache();
for (let i = 0; i < self._onResizes.length; i++) {
try {
@@ -295,6 +295,16 @@ export class Platform {
return rgx.test(this._ua || '');
}
/**
* TODO
* @param {TODO} navigatorPlatformExpression TODO
* @returns {boolean} TODO
*/
testNavigatorPlatform(navigatorPlatformExpression) {
let rgx = new RegExp(navigatorPlatformExpression, 'i');
return rgx.test(this._bPlt || '');
}
/**
* TODO
* @param {TODO} userAgentExpression TODO
@@ -388,7 +398,7 @@ export class Platform {
let engineMethods = engineNode.methods();
engineMethods._engineReady = engineMethods.ready;
delete engineMethods.ready;
util.extend(this, engineMethods);
extend(this, engineMethods);
}
let platformNode = rootPlatformNode;

View File

@@ -48,7 +48,24 @@ Platform.register({
],
settings: {
activator: function(p) {
return (p.version().major < 5 && p.navigatorPlatform().indexOf('linux') > -1) ? 'none' : 'ripple';
// md mode defaults to use ripple activator
// however, under-powered devices shouldn't use ripple
// if this a linux device, and is using Android Chrome v36 (Android 5.0)
// or above then use ripple, otherwise do not use a ripple effect
if (p.testNavigatorPlatform('linux')) {
let chromeVersion = p.matchUserAgentVersion(/Chrome\/(\d+).(\d+)?/);
if (chromeVersion) {
// linux android device using modern android chrome browser gets ripple
return (parseInt(chromeVersion.major, 10) < 36 ? 'none' : 'ripple');
}
// linux android device not using chrome browser checks just android's version
if (p.version().major < 5) {
return 'none';
}
}
// fallback to always use ripple
return 'ripple';
},
hoverCSS: false,
keyboardHeight: 300,
@@ -158,5 +175,5 @@ function isIOSDevice(p) {
// 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 /iphone|ipad|ipod/i.test(p.navigatorPlatform());
return p.testNavigatorPlatform(/iphone|ipad|ipod/);
}