Coder Guy
Coder Guy

Reputation: 97

How to support I.E. with Touchswipe.js

Does anyone know how to support I.E. with Touchswipe.js?

The script works fine for detecting swipe on most devices but not in IE ...

  $(this).swipe( { allowPageScroll:"vertical",
    swipe:function(event, direction, distance, duration, fingerCount, fingerData) {

    if(direction == 'right'){
     console.log('swiped right');
    }

    if(direction == 'left'){
      console.log('swiped left');
    }

  },

  threshold:0

});

Upvotes: 0

Views: 347

Answers (1)

Coder Guy
Coder Guy

Reputation: 97

I found a 2 step process to include touch support and its very simple.

First add to your CSS

  html {
    -ms-touch-action: none; /* Direct all pointer events to JavaScript code. */
  }

Then add to your script:

  var touchStart = window.navigator.msPointerEnabled ? "MSPointerDown" : "touchstart";
  var touchMove = window.navigator.msPointerEnabled ? "MSPointerMove" : "touchmove";
  var touchEnd = window.navigator.msPointerEnabled ? "MSPointerUp" : "touchend";

Upvotes: 0

Related Questions