detect-it
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -107,2 +107,15 @@ 'use strict'; | ||
'mouse'; | ||
// issue with Windows Chrome on hybrid devices starting in version 59 where | ||
// media queries represent a touch only device, so if the browser is an | ||
// affected Windows Chrome version and hasTouch, | ||
// then assume it's a hybrid with primaryInput mouse | ||
// see https://github.com/rafrex/detect-it/issues/8 | ||
var isAffectedWindowsChromeVersion = /windows/.test(window.navigator.userAgent.toLowerCase()) && /chrome/.test(window.navigator.userAgent.toLowerCase()) && parseInt(/Chrome\/([0-9.]+)/.exec(navigator.userAgent)[1], 10) >= 59; | ||
if (isAffectedWindowsChromeVersion && detectIt.hasTouch) { | ||
detectIt.deviceType = 'hybrid'; | ||
detectIt.hasMouse = true; | ||
detectIt.primaryInput = 'mouse'; | ||
} | ||
} | ||
@@ -109,0 +122,0 @@ } |
{ | ||
"name": "detect-it", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Detect if a device is mouse only, touch only, or hybrid", | ||
@@ -8,4 +8,4 @@ "main": "lib/index.js", | ||
"build": "rm -rf lib && babel src -d lib --presets=env", | ||
"prepublish": "npm run build", | ||
"dev": "npm link && babel src -d lib --watch --presets=env" | ||
"prepublish": "yarn build", | ||
"dev": "yarn link && babel src -d lib --watch --presets=env" | ||
}, | ||
@@ -12,0 +12,0 @@ "files": [ |
@@ -37,2 +37,4 @@ # Detect It | ||
```terminal | ||
$ yarn add detect-it | ||
# OR | ||
$ npm install --save detect-it | ||
@@ -39,0 +41,0 @@ ``` |
@@ -90,2 +90,18 @@ import detectHover from 'detect-hover'; | ||
'mouse'; | ||
// issue with Windows Chrome on hybrid devices starting in version 59 where | ||
// media queries represent a touch only device, so if the browser is an | ||
// affected Windows Chrome version and hasTouch, | ||
// then assume it's a hybrid with primaryInput mouse | ||
// see https://github.com/rafrex/detect-it/issues/8 | ||
const isAffectedWindowsChromeVersion = | ||
/windows/.test(window.navigator.userAgent.toLowerCase()) && | ||
/chrome/.test(window.navigator.userAgent.toLowerCase()) && | ||
parseInt(/Chrome\/([0-9.]+)/.exec(navigator.userAgent)[1], 10) >= 59; | ||
if (isAffectedWindowsChromeVersion && detectIt.hasTouch) { | ||
detectIt.deviceType = 'hybrid'; | ||
detectIt.hasMouse = true; | ||
detectIt.primaryInput = 'mouse'; | ||
} | ||
} | ||
@@ -92,0 +108,0 @@ }, |
19874
201
187