Reliable touch detection in combination with iscroll4

I am using iscroll4 to create a slideshow. I have a fallback that provides previous and next buttons for devices without touch support. However, I would like to completely hide those buttons on devices that do not support touch since they get in the way. What would be the best method to go about this? I found the below snippet of code doing a simple search but just am not sure – perhaps iscroll4 has a publicly accessible method to detect it (I’ll maybe have to dig through the source to find out).


function isTouchDevice() {
   var el = document.createElement('div');
   el.setAttribute('ongesturestart', 'return;');
   if(typeof el.ongesturestart == "function"){
      return true;
   }else {
      return false
   }
}

source

off topic: I’m not one for promoting things but iscroll4 is by far the most reliable and efficient way to deal with the fixed footer problem and touch based scrolling in general fyi. Codos to The Build mobile book for providing such a valuable resource.

Thanks

If you take a look at the source for iScroll, it uses:

hasTouch = 'ontouchstart' in window

Which gets used later on:

START_EV = hasTouch ? 'touchstart' : 'mousedown',
MOVE_EV = hasTouch ? 'touchmove' : 'mousemove',
//... etc.

:slight_smile:

doh, lol thx