diff options
author | Chris Rebert <code@rebertia.com> | 2015-01-04 10:13:37 +0300 |
---|---|---|
committer | Chris Rebert <code@rebertia.com> | 2015-01-04 10:17:47 +0300 |
commit | 4637bb9c87a4c0556ce83f1c0f953c7a4643f5f9 (patch) | |
tree | 29774c9ae6862f7e4fadd40d06cd17dfd107b1f5 /src | |
parent | 1c8a8a76fa4818dc9956ef0748e67a1317ef577f (diff) |
Fixes #5
Diffstat (limited to 'src')
-rw-r--r-- | src/browser/mq4-hover-hover-shim.js | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/browser/mq4-hover-hover-shim.js b/src/browser/mq4-hover-hover-shim.js index 1fe0528..5477d13 100644 --- a/src/browser/mq4-hover-hover-shim.js +++ b/src/browser/mq4-hover-hover-shim.js @@ -10,22 +10,19 @@ */ export function supportsTrueHover() { if (!window.matchMedia) { - // Opera Mini, IE<=9, or ancient; per http://caniuse.com/#feat=matchmedia - const ua = navigator.userAgent; - if (ua.indexOf("Opera Mini") > -1) { - // Opera Mini doesn't support true hovering - return false; - } - if ( - ua.indexOf('IEMobile') > -1 || ua.indexOf('Windows Phone') > -1 || - ua.indexOf('XBLWP7') > -1 || ua.indexOf('ZuneWP7') > -1 || // IE Mobile 9 in desktop view - ua.indexOf('Windows CE') > -1 // out of an abundance of caution - ) { - // IE Mobile <=9 - return false; - } - // UA is ancient enough to probably be a desktop computer or at least not attempt emulation of hover. - return true; + // Opera Mini, IE<=9, ancient, or obscure; per http://caniuse.com/#feat=matchmedia + + // Opera Mini and IE Mobile don't support true hovering, so they're what we'll check for. + // Other browsers are either: + // (a) obscure + // (b) touch-based but old enough not to attempt to emulate hovering + // (c) old desktop browsers that do support true hovering + + // Explanation of this UA regex: + // IE Mobile <9 seems to always have "Windows CE", "Windows Phone", or "IEMobile" in its UA string. + // IE Mobile 9 in desktop view doesn't include "IEMobile" or "Windows Phone" in the UA string, + // but it instead includes "XBLWP7" and/or "ZuneWP7". + return !/Opera Mini|IEMobile|Windows (Phone|CE)|(XBL|Zune)WP7/.test(navigator.userAgent); } // CSSWG Media Queries Level 4 draft |