MooSwipe 0.1

A MooTools port of Andreas Waltl's jQuery TouchWipe. Gives easy access to left and right swipe events for iOS and other touch devices.

License: MIT-style.



Details

Author
Caleb Troughton
Current version
0.1
GitHub
imakewebthings/mooswipe
Downloads
4012
Category
Interface
Tags
Report
GitHub Issues

Releases


Dependencies

  • core/1.2.4:
    • Element.Event
    • Class
    • Class.Extras

How to use

new MooSwipe(el, options);
  • el: String id of the element, an element node, or any object with a toElement method.
  • options: Options and events.

Typical usage:

new MooSwipe('swipe-id', {
    onSwipeLeft: function() {
        // Code to execute on left swipe
    },
    onSwipeRight: function() {
        // Code to execute on right swipe
    },
    onSwipe: function(direction) {
        // Code to execute on any swipe
    }
});

Options

  • tolerance (int): The number of pixels your finger must move to trigger a swipe event. Defaults to 20.
  • preventDefaults (bool): Prevent the default action during the touchMove event? Defaults to true.

Example:

new MooSwipe('swipe-id', {
    tolerance: 50,
    preventDefaults: false,
    onSwipeLeft: ...,
    onSwipeRight: ...,
    onSwipe: ...
});

Events

  • swipeLeft
  • swipeRight
  • swipe: passed a string indicating the direction, 'left' or 'right'

Event functions can be included in the MooSwipe initialization:

new MooSwipe('swipe-id', {
    onSwipeLeft: function() { ... },
    onSwipeRight: function() { ... },
    onSwipe: function(direction) { ... }
});

Or added afterwards:

var swipe = new MooSwipe('swipe-id');
swipe.addEvent('swipeLeft', function() { ... });
swipe.addEvent('swipeRight', function() { ... });
swipe.addEvent('swipe', function(direction) { ... });

Discuss

A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.

Found a bug in this plugin? Please report it this repository's Github Issues.

blog comments powered by Disqus