cheminfo / cheminfo/nmrium

Touch screen devices (code from Rainer Haessner)

Open
#1,161 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
80
Forks
34
Avg merge
2d 9h
Merged PRs (30d)
36

Description

Here comes what Rainer mentioned in our meeting from July 2nd:

```js

const hasTouchScreen = function () {

let hasTouchScreen = false;

if ("maxTouchPoints" in navigator) {

hasTouchScreen = navigator.maxTouchPoints > 0;

} else if ("msMaxTouchPoints" in navigator) {

hasTouchScreen = navigator.msMaxTouchPoints > 0;

} else {

let mQ = window.matchMedia && matchMedia("(pointer:coarse)");

if (mQ && mQ.media === "(pointer:coarse)") {

hasTouchScreen = !!mQ.matches;

} else if ("orientation" in window) {

hasTouchScreen = true; // deprecated, but good fallback

} else {

// Only as a last resort, fall back to user agent sniffing

let UA = navigator.userAgent;

hasTouchScreen =

/\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) || /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA);

}

}

return hasTouchScreen;

};

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.