vcc-ui
Version:
VCC UI is a collection of React UI Components that can be used for developing front-end applications at Volvo Car Corporation.
31 lines (24 loc) • 828 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isTouchDevice = void 0;
/**
* Detect type of device
* From stackoverflow: https://stackoverflow.com/a/4819886
*
* @returns bool
*/
var isTouchDevice = function isTouchDevice() {
var prefixes = " -webkit- -moz- -o- -ms- ".split(" ");
var matchedQueries = function matchedQueries(query) {
return window.matchMedia(query).matches;
};
if ("ontouchstart" in window || window.DocumentTouch && document instanceof window.DocumentTouch) {
return true;
} // include the 'heartz' as a way to have a non matching MQ to help terminate the join
// https://git.io/vznFH
var query = ["(", prefixes.join("touch-enabled),("), "heartz", ")"].join("");
return matchedQueries(query);
};
exports.isTouchDevice = isTouchDevice;