SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,051
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)

    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).

    Code:
    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
    The only code I hate more than my own is everyone else's.

  2. #2
    Under Construction silver trophybronze trophy AussieJohn's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    776
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    If you take a look at the source for iScroll, it uses:
    Code JavaScript:
    hasTouch = 'ontouchstart' in window

    Which gets used later on:
    Code JavaScript:
    START_EV = hasTouch ? 'touchstart' : 'mousedown',
    MOVE_EV = hasTouch ? 'touchmove' : 'mousemove',
    //... etc.

    var details = {
    . . web: "afterlight.com.au",
    . . photos: "jvdl.id.au",
    . . psa: "usethelatestversion.com"
    }

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,051
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    doh, lol thx
    The only code I hate more than my own is everyone else's.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •