This module provides unified touch event handlers by exporting press, move, release and cancel which can also run well on desktop. Based on http://dvcs.w3.org/hg/webevents/raw-file/tip/touchevents.html Also, if the dojoClick property is set to truthy on a DOM node, dojo/touch generates click events immediately for this node and its descendants (except for descendants that have a dojoClick property set to falsy), to avoid the delay before native browser click events, and regardless of whether evt.preventDefault() was called in a touch.press event listener.
See the dojo/touch reference documentation for more information.
Used with dojo/on
define(["dojo/on", "dojo/touch"], function(on, touch){
on(node, touch.press, function(e){});
on(node, touch.move, function(e){});
on(node, touch.release, function(e){});
on(node, touch.cancel, function(e){});
Used with touch.* directly
touch.press(node, function(e){});
touch.move(node, function(e){});
touch.release(node, function(e){});
touch.cancel(node, function(e){});
Have dojo/touch generate clicks without delay, with a default move threshold of 4 pixels
node.dojoClick = true;
Have dojo/touch generate clicks without delay, with a move threshold of 10 pixels horizontally and vertically
node.dojoClick = 10;
Have dojo/touch generate clicks without delay, with a move threshold of 50 pixels horizontally and 10 pixels vertically
node.dojoClick = {x:50, y:5};
Disable clicks without delay generated by dojo/touch on a node that has an ancestor with property dojoClick set to truthy
node.dojoClick = false;
cancel
(node,listener)
Defined by dojo/touch
Register a listener to 'touchcancel'|'mouseleave' for the given node
Parameter | Type | Description |
---|---|---|
node | Dom |
Target node to listen to |
listener | Function |
Callback function |
Returns: any
A handle which will be used to remove the listener by handle.remove()
enter
(node,listener)
Defined by dojo/touch
Register a listener to mouse.enter or touch equivalent for the given node
Parameter | Type | Description |
---|---|---|
node | Dom |
Target node to listen to |
listener | Function |
Callback function |
Returns: any
A handle which will be used to remove the listener by handle.remove()
leave
(node,listener)
Defined by dojo/touch
Register a listener to mouse.leave or touch equivalent for the given node
Parameter | Type | Description |
---|---|---|
node | Dom |
Target node to listen to |
listener | Function |
Callback function |
Returns: any
A handle which will be used to remove the listener by handle.remove()
move
(node,listener)
Defined by dojo/touch
Register a listener that fires when the mouse cursor or a finger is dragged over the given node.
Parameter | Type | Description |
---|---|---|
node | Dom |
Target node to listen to |
listener | Function |
Callback function |
Returns: any
A handle which will be used to remove the listener by handle.remove()
out
(node,listener)
Defined by dojo/touch
Register a listener to 'mouseout' or touch equivalent for the given node
Parameter | Type | Description |
---|---|---|
node | Dom |
Target node to listen to |
listener | Function |
Callback function |
Returns: any
A handle which will be used to remove the listener by handle.remove()
over
(node,listener)
Defined by dojo/touch
Register a listener to 'mouseover' or touch equivalent for the given node
Parameter | Type | Description |
---|---|---|
node | Dom |
Target node to listen to |
listener | Function |
Callback function |
Returns: any
A handle which will be used to remove the listener by handle.remove()
press
(node,listener)
Defined by dojo/touch
Register a listener to 'touchstart'|'mousedown' for the given node
Parameter | Type | Description |
---|---|---|
node | Dom |
Target node to listen to |
listener | Function |
Callback function |
Returns: any
A handle which will be used to remove the listener by handle.remove()
release
(node,listener)
Defined by dojo/touch
Register a listener to releasing the mouse button while the cursor is over the given node (i.e. "mouseup") or for removing the finger from the screen while touching the given node.
Parameter | Type | Description |
---|---|---|
node | Dom |
Target node to listen to |
listener | Function |
Callback function |
Returns: any
A handle which will be used to remove the listener by handle.remove()
© 2005–2017 JS Foundation
Licensed under the AFL 2.1 and BSD 3-Clause licenses.
http://dojotoolkit.org/api/1.10/dojo/touch.html