Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix touch detection is not accurate #182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blackbing
Copy link

@blackbing blackbing commented Jan 5, 2024

("ontouchstart" in document.documentElement) will return false on Desktop Chrome even if it support touch.

Refer to other repo, they use navigator.maxTouchPoints > 0 to detect if the device supports touch.
https://github.com/microsoft/vscode/blob/f873eb102260dcbdd0c4068a59f21c1ef91697bd/src/vs/base/browser/touch.ts#L127C3-L127C3

the demo also does not work on Desktop Chrome with a touch device. I've tried it on other browsers, and this way is more accurate.

also check caniuse:
Screenshot 2024-01-05 at 9 40 47 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants