Odo On Swipe

Provide event hook for swipes on an element.

Support

IE9+.

Dependencies

Odo Pointer

It defaults to using the x axis. This can be changed with the axis parameter.

Swipe me
function swiped(event) {
  element.textContent = 'Swiped ' + event.direction;
}
new OdoOnSwipe(element, swiped);

Y Axis (will block vertical scrolling on touch)

Swipe me

Markup

<div class="js-on-swipe" data-axis="y">…</div>
new OdoOnSwipe(element, swiped, OdoPointer.Axis.Y);

Both Axis (will block scrolling on touch)

Swipe me

Markup

<div class="js-on-swipe" data-axis="xy">…</div>
new OdoOnSwipe(element, swiped, OdoPointer.Axis.BOTH);