microsoft / reactxp

Library for cross-platform app development.
https://microsoft.github.io/reactxp/
Other
8.29k stars 491 forks source link

Web - Detect if touch device? #1138

Closed MovingGifts closed 5 years ago

MovingGifts commented 5 years ago

Is there is a built-in way to check if the current device accessing the reactxp app is a touch device?

deregtd commented 5 years ago

You have to unfortunately decide what this means for yourself, as there's a huge hybrid range between "fully touch" and "fully keyboard". What is a surface book? What is an iPad with a usb keyboard and mouse? etc.

FWIW, in my apps I have a simple mouse-detecting resub store where the root view has an onmousemove event, and if it ever gets the event, it flicks the store to "mouse available" mode and the UI updates appropriately, but by default it assumes touch-only until it gets a signal that a mouse exists.

MovingGifts commented 5 years ago

Thanks for the quick response! Sounds good, I just wanted a confirmation that it's not built in. That's a pretty cool way of doing it, thank you for sharing. Cheers!

deregtd commented 5 years ago

Yeah -- it's enough of a nuanced problem that we wanted to make people think about it a little bit, as there is really no one-size-fits-all approach here at all. :)