Skip to content

Commit

Permalink
Merge branch 'windows-hybrid-chrome-patch'
Browse files Browse the repository at this point in the history
  • Loading branch information
rafgraph committed Aug 15, 2017
2 parents abcd2f3 + 0166a4f commit 0ae20eb
Show file tree
Hide file tree
Showing 4 changed files with 2,405 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const detectIt = {

### Installing `detect-it`
```terminal
$ yarn add detect-it
# OR
$ npm install --save detect-it
```

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "lib/index.js",
"scripts": {
"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"
},
"files": [
"lib",
Expand Down
16 changes: 16 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ const detectIt = {
// if there's no support for hover media queries but detectIt determined it's
// a hybrid device, then assume it's a mouse first device
'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';
}
}
},
};
Expand Down
Loading

0 comments on commit 0ae20eb

Please sign in to comment.