- A framework and a collection for separate and simple implementation of touch gestures
- Momo can either be viewed as an independent library, or as a part of OzJS mirco-framework.
- It's wrapped as a number of mutually independent AMD (Asynchronous Module Definition) modules. You should use them with oz.js (or require.js or similar for handling dependencies).
- If you want to make them available for both other AMD code and traditional code based on global namespace. OzJS provides a mini define/require implementation to transform AMD module into traditional module pattern.
- See http://ozjs.org for details.
Add to your project as new dependency
Or download directly from Github
- A sample implementation for adapter
- A simple framework
- 'tap', 'doubletap', 'hold', 'tapstart', 'tapcancel'
- 'scrolldown', 'scrollup', 'scrollstart', 'scrollend'
- 'swipeup', 'swipedown', 'swiperight', 'swipeleft'
- 'drag', 'dragover', 'dragstart', 'dragend'
- Comming soon...
var momo = require('momo');
momo.init()
-momo.tap()
-momo.scroll()
-momo.swipe()
-momo.drag()
-
Defaults:
namespace
: ""
var momoBase = require('momo/base');
var MomoBase = momoBase.Class;
MomoBase.prototype.config
--MomoBase.prototype.enable
--MomoBase.prototype.disable
--MomoBase.prototype.once
--MomoBase.prototype.event
--MomoBase.prototype.SUPPORT_TOUCH
--MomoBase.prototype.bind
-- [adapter]MomoBase.prototype.unbind
-- [adapter]MomoBase.prototype.trigger
-- [adapter]MomoBase.prototype.press
-- [hook]MomoBase.prototype.move
-- [hook]MomoBase.prototype.release
-- [hook]MomoBase.prototype.cancel
-- [hook]
Defaults:
tapRadius
: 10doubleTimeout
: 300tapThreshold
: 0holdThreshold
: 500
var momoTap = require('momo/tap');
var tapGesture = momoTap(element, /* optional */ config, /* optional */ handler);
element.addEventListener('tap', handler)
element.addEventListener('doubletap', handler)
element.addEventListener('hold', handler)
element.addEventListener('tapstart', handler)
element.addEventListener('tapcancel', handler)
Defaults:
directThreshold
: 5scrollEndGap
: 5
var momoScroll = require('momo/scroll');
var scrollGesture = momoScroll(element, /* optional */ config, /* optional */ handler);
scrollGesture.watchScroll(element)
-element.addEventListener('scrolldown', handler)
element.addEventListener('scrollup', handler)
element.addEventListener('scrollstart', handler)
element.addEventListener('scrollend', handler)
Defaults:
timeThreshold
: 200distanceThreshold
: 20
var momoSwipe = require('momo/swipe');
var swipeGesture = momoSwipe(element, /* optional */ config, /* optional */ handler);
element.addEventListener('swipedown', handler)
element.addEventListener('swipeup', handler)
element.addEventListener('swipeleft', handler)
element.addEventListener('swiperight', handler)
- Comming soon...
Under construction...
Copyright (c) 2010 - 2013 dexteryy
Licensed under the MIT license.