MooTools port of jQuery TouchW

MooSwipe

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.

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) { ... });

版权声明:

1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。
2、网站不提供资料下载,如需下载请到原作者页面进行下载。