Feature Detection

148 views
Skip to first unread message

Marteijn Nouwens

unread,
Jun 21, 2016, 1:45:26 AM6/21/16
to GWT Users
Hello,

I question on doing 2 things. I was wondering what works best. So please feel to offer any advice you may think apropiate.

1e
Feature detection.:

We want to know wheter a device is touch enabled. 

Some feedback should work different when handled with a mouse. 
Title and such do not add value on a tablet but can save space on a desktop when using a mouse. 

Anybody doing this.

2e
Form Factor detection. 
We want to do some things different when on a phone or tablet than for instance on a desktop. Mostly disable thing of breakup flows.

For the form factor we where using  mgwt but it just adds to much overhead and stuff. 

Thanks

Frank

unread,
Jun 21, 2016, 3:44:00 AM6/21/16
to GWT Users

Gilberto

unread,
Jun 21, 2016, 1:25:32 PM6/21/16
to GWT Users
This is what I do:

public static native boolean isOnTouchDevice()/*-{
    return 'ontouchstart' in window || navigator.maxTouchPoints;
}-*/
;

Thomas Broyer

unread,
Jun 21, 2016, 2:38:44 PM6/21/16
to GWT Users
What about laptops with touch screens? (Surface, Chrome Pixel, etc.) Maybe the user will use the mouse primarily in those? Maybe not?

I seem to remember that touch-enabled couldn't be detected, because one could also just plug a touch screen to the device while the browser is open (and a page loaded!)
So this is likely to generate a lot of false positives.

Frank

unread,
Jun 22, 2016, 5:03:08 AM6/22/16
to GWT Users


Op dinsdag 21 juni 2016 20:38:44 UTC+2 schreef Thomas Broyer:
What about laptops with touch screens? (Surface, Chrome Pixel, etc.) Maybe the user will use the mouse primarily in those? Maybe not?

I seem to remember that touch-enabled couldn't be detected, because one could also just plug a touch screen to the device while the browser is open (and a page loaded!)
So this is likely to generate a lot of false positives.


I indeed forgot to mention.
What I posted just detects if it is a mobile device or not. Detecing a touch screen is impossible. Like thomas said, touch screens with mouse, or dual screens with 1 touch and 1 normal screen, ....

If some of your users are using a touch screen, than design your webapp in such a way that all information is available, also when using a touch screen.

Frank

unread,
Jun 22, 2016, 5:06:33 AM6/22/16
to GWT Users
Also... You should probably read the first line on  in the readme.md of the library I posted : "You probably shouldn't use this library unless you absolutely have to."

Op woensdag 22 juni 2016 11:03:08 UTC+2 schreef Frank:

Jens

unread,
Jun 22, 2016, 5:35:15 AM6/22/16
to GWT Users
Thats how Modernizr does it:


However read the comments in that file and especially the linked articles.

-- J.
Reply all
Reply to author
Forward
0 new messages