/simple-swipe

:point_up_2: Basic one-finger swiping for your website

Primary LanguageJavaScript

simple-swipe.js

SimpleSwipe provides a JavaScript interface for handling basic one-finger swiping on touch screens. The code, which began as a refactoring of padilicious.com's swipe code, is short and (hopefully) easy to understand. It was written for projects that don't need things like pinch zoom or multi-finger swiping, and don't necessarily want large libraries like jQuery mobile or TouchSwipe.

Usage

Attach swipe listeners:

var s = new SimpleSwipe(element,
    function (swipe, element) {
        console.log('swipe move', swipe);
    }, function (swipe, element) {
        console.log('swipe end', swipe);
    });

The callbacks fire on the touchmove and touchend events respectively. Note that the context for the this keyword inside the callbacks is the SimpleSwipe object

Remove swipe listeners:

s.removeListeners();

That's it!

For more details take a look at the code or view an example.

Build Tools

A makefile-based build system is provided to ease development. It requires node.js, npm, and (of course) GNU Make. Once those are installed, run make in your shell to install node packages and then lint and minify the code. See the makefile for details.