]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/touch.js.uncompressed.js
1 define("dojo/touch", ["./_base/kernel", "./on", "./has", "./mouse"], function(dojo
, on
, has
, mouse
){
8 // This module provides unified touch event handlers by exporting
9 // press, move, release and cancel which can also run well on desktop.
10 // Based on http://dvcs.w3.org/hg/webevents/raw-file/tip/touchevents.html
13 // 1. Used with dojo.connect()
14 // | dojo.connect(node, dojo.touch.press, function(e){});
15 // | dojo.connect(node, dojo.touch.move, function(e){});
16 // | dojo.connect(node, dojo.touch.release, function(e){});
17 // | dojo.connect(node, dojo.touch.cancel, function(e){});
19 // 2. Used with dojo.on
20 // | define(["dojo/on", "dojo/touch"], function(on, touch){
21 // | on(node, touch.press, function(e){});
22 // | on(node, touch.move, function(e){});
23 // | on(node, touch.release, function(e){});
24 // | on(node, touch.cancel, function(e){});
26 // 3. Used with dojo.touch.* directly
27 // | dojo.touch.press(node, function(e){});
28 // | dojo.touch.move(node, function(e){});
29 // | dojo.touch.release(node, function(e){});
30 // | dojo.touch.cancel(node, function(e){});
32 press: function(node, listener){
34 // Register a listener to 'touchstart'|'mousedown' for the given node
36 // Target node to listen to
40 // A handle which will be used to remove the listener by handle.remove()
42 move: function(node, listener){
44 // Register a listener to 'touchmove'|'mousemove' for the given node
46 // Target node to listen to
50 // A handle which will be used to remove the listener by handle.remove()
52 release: function(node, listener){
54 // Register a listener to 'touchend'|'mouseup' for the given node
56 // Target node to listen to
60 // A handle which will be used to remove the listener by handle.remove()
62 cancel: function(node, listener){
64 // Register a listener to 'touchcancel'|'mouseleave' for the given node
66 // Target node to listen to
70 // A handle which will be used to remove the listener by handle.remove()
75 function _handle(/*String - press | move | release | cancel*/type
){
76 return function(node
, listener
){//called by on(), see dojo.on
77 return on(node
, type
, listener
);
80 var touch
= has("touch");
81 //device neutral events - dojo.touch.press|move|release|cancel
83 press
: _handle(touch
? "touchstart": "mousedown"),
84 move: _handle(touch
? "touchmove": "mousemove"),
85 release
: _handle(touch
? "touchend": "mouseup"),
86 cancel
: touch
? _handle("touchcancel") : mouse
.leave