vanilla-touchwipe

Tiny <100LOC library to detect touch swipe gestures

Usage no npm install needed!

<script type="module">
  import vanillaTouchwipe from 'https://cdn.skypack.dev/vanilla-touchwipe';
</script>

README

vanilla-touchwipe Build Status NPM version

This is a vanilla js port of the touchwipe jQuery plgin, (originally written by Andreas Waltl), which is used to detect touch swipe gestures.

Features

  • Tiny footprint: < 100 LOC
  • Easy to use

Usage

var domNode = document.getElementById('container');

var touch = touchwipe(domNode, {
  wipeLeft: function() { alert('left'); },
  wipeRight: function() { alert('right'); },
  wipeUp: function() { alert('up'); },
  wipeDown: function() { alert('down'); },
  min_move_x: 20,
  min_move_y: 20,
  preventDefaultEvents: true
});

touch.unbind();

License

MIT