Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modernizr.touch returns true on firefox browser

I have written a peace of code to get the event based on touch and non-touch. Its working all other browsers and devices, but Firefox. Default FF return the true.

var thumbsEvent, isTouch = Modernizr.touch; // detect the touch
if(isTouch){
   thumbsEvent = 'click';//on touch surface, click
}
else {
   thumbsEvent = 'mouseover';//on non touch surface, mouseover
}

Is there a way to manage this issue.

Example fiddle

like image 823
Sameera Thilakasiri Avatar asked Feb 28 '14 04:02

Sameera Thilakasiri


People also ask

What is modernizr custom JS?

Modernizr is a JavaScript library that detects the features available in a user's browser. This lets web pages avoid unsupported features by informing the user their browser isn't supported or loading a polyfill.


2 Answers

On behalf of Modernizr - We're really sorry about this.

Modernizr.touch has been renamed Modernizr.touchevents in the yet-to-be-released version 3.0, as it is a far more accurate description of the detect. Basically, all this detect is doing is checking for the existence of touch events, and returning true if they are found. Desktop chrome does the same thing if you enable developer tools. It just means that your version of firefox on your laptop is reporting support of touch events, for several possible reasons.

like image 67
Patrick Avatar answered Sep 28 '22 09:09

Patrick


i had the same issue, this fixed it for me: in firefox go to "about:config", then search for the setting "dom.w3c_touch_events.enabled" and reset that one. i then had to restart firefox and afterwards "Modernizr.touch" correctly returned "false" for me.

source: https://github.com/Modernizr/Modernizr/issues/1225

like image 35
sashn Avatar answered Sep 28 '22 08:09

sashn