datamaps icon indicating copy to clipboard operation
datamaps copied to clipboard

'click' events treated as 'hover' on mobile device

Open kenirwin opened this issue 7 years ago • 2 comments

I've working with Datamaps, and I just went to go test my code on an iPhone for the first time. I'm finding that clicking on a country on a mobile device is treated as a "hover" event -- highlighting the country but not triggering my on('click') jQuery events.

Example: http://www6.wittenberg.edu/lib/ken/datavis/datamaps/jquery.php

Clicking on a country in a desktop browser displays the country name in the "placeholder" div below the map. Doing so on my phone results only in highlighting the country and giving the mouseover text.

Is there some other event that has to be added to support mobile devices?

Thanks

kenirwin avatar Feb 26 '18 20:02 kenirwin

I used the following that worked for me:

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
    deviceEventType = 'touchstart'
  } else {
  //If its not a mobile device use 'click'
    deviceEventType = 'click'
  }

ghost avatar Aug 08 '18 03:08 ghost

Thank you for this! Just solved the same problem for me.

eveahe avatar Dec 09 '18 22:12 eveahe