event-gestures-debug.js revision 9b4b74ff446f59c1a9d2007b20beae1254e19138
377N/A * The gestures module provides gesture events such as "flick", which normalize user interactions
377N/A * across touch and mouse or pointer based input devices. This layer can be used by application developers
377N/A * to build input device agnostic components which behave the same in response to either touch or mouse based
377N/A * <p>Documentation for events added by this module can be found in the event document for the <a href="YUI.html#events">YUI</a> global.</p>
377N/A * Adds support for a "flick" event, which is fired at the end of a touch or mouse based flick gesture, and provides
377N/A * Sets up a "flick" event, that is fired whenever the user initiates a flick gesture on the node
377N/A * where the listener is attached. The subscriber can specify a minimum distance or velocity for
377N/A * which the event is to be fired. The subscriber can also specify if there is a particular axis which
377N/A * they are interested in - "x" or "y". If no axis is specified, the axis along which there was most distance
377N/A * <p>It is recommended that you use Y.bind to set up context and additional arguments for your event handler,
377N/A * however if you want to pass the context and arguments as additional signature arguments to "on",
377N/A * you need to provide a null value for the configuration object, e.g: <code>node.on("flick", fn, null, context, arg1, arg2, arg3)</code></p>
377N/A * @param fn {function} The method the event invokes. It receives an event facade with an e.flick object containing the flick related properties: e.flick.time, e.flick.distance, e.flick.velocity and e.flick.axis, e.flick.start.
377N/A * <dd>The minimum distance between start and end points, which would qualify the gesture as a flick.</dd>
377N/A * <dd>Can be set to true/false to prevent default behavior as soon as the touchstart/touchend or mousedown/mouseup is received so that things like scrolling or text selection can be
377N/A * prevented. This property can also be set to a function, which returns true or false, based on the event facade passed to it.</dd>
377N/A * <dd>Can be set to "x" or "y" if you want to constrain the flick velocity and distance to a single axis. If not
377N/A if (startHandle) {
1336N/A if (preventDefault) {
endEvent = e,
time,
axis;
if (valid) {
if (e.changedTouches) {
valid = false;
if (valid) {
if (preventDefault) {
xyDistance = [
if (isFinite(velocity) && (Math.abs(distance) >= params[MIN_DISTANCE]) && (Math.abs(velocity) >= params[MIN_VELOCITY])) {
e.flick = {
PREVENT_DEFAULT : false
* Adds lower level support for "gesturemovestart", "gesturemove" and "gesturemoveend" events, which can be used to create drag/drop
* interactions which work across touch and mouse input devices. They correspond to "touchstart", "touchmove" and "touchend" on a touch input
return config;
touchFacade[BUTTON] = (params && params[BUTTON]) || 1; // default to left (left as per vendors, not W3C which is 0)
if (preventDefault) {
e.preventDefault();
* Sets up a "gesturemovestart" event, that is fired on touch devices in response to a single finger "touchstart",
* and on mouse based devices in response to a "mousedown". The subscriber can specify the minimum time
* and distance thresholds which should be crossed before the "gesturemovestart" is fired and for the mouse,
* which button should initiate a "gesturemovestart". This event can also be listened for using node.delegate().
* <p>It is recommended that you use Y.bind to set up context and additional arguments for your event handler,
* however if you want to pass the context and arguments as additional signature arguments to on/delegate,
* you need to provide a null value for the configuration object, e.g: <code>node.on("gesturemovestart", fn, null, context, arg1, arg2, arg3)</code></p>
* @param fn {function} The method the event invokes. It receives the event facade of the underlying DOM event (mousedown or touchstart.touches[0]) which contains position co-ordinates.
* <dd>The minimum distance threshold which should be crossed before the gesturemovestart is fired</dd>
* <dd>The minimum time threshold for which the finger/mouse should be help down before the gesturemovestart is fired</dd>
* <dd>In the case of a mouse input device, if the event should only be fired for a specific mouse button.</dd>
* <dd>Can be set to true/false to prevent default behavior as soon as the touchstart or mousedown is received (that is before minTime or minDistance thresholds are crossed, and so before the gesturemovestart listener is notified) so that things like text selection and context popups (on touch devices) can be
* prevented. This property can also be set to a function, which returns true or false, based on the event facade passed to it (for example, DragDrop can determine if the target is a valid handle or not before preventing default).</dd>
this._onStart,
node,
ce);
var se = this;
filter);
if (handle) {
if (startHandle) {
return params;
if (delegate) {
fireStart = true,
if (e.touches) {
fireStart = false;
Y.log("gesturemovestart: params = button:" + button + ", minTime = " + minTime + ", minDistance = " + minDistance, "event-gestures");
if (fireStart) {
Y.log("gesturemovestart: minDistance specified. Setup native mouse/touchmove listener to measure distance.", "event-gestures");
if (Math.abs(em.pageX - startXY[0]) > minDistance || Math.abs(em.pageY - startXY[1]) > minDistance) {
if (params) {
PREVENT_DEFAULT : false
* Sets up a "gesturemove" event, that is fired on touch devices in response to a single finger "touchmove",
* has received a "gesturemovestart" event. The subscriber can set standAlone to true, in the configuration properties,
* <p>By default this event sets up it's internal "touchmove" and "mousemove" DOM listeners on the document element. The subscriber
* can set the root configuration property, to specify which node to attach DOM listeners to, if different from the document.</p>
* <p>It is recommended that you use Y.bind to set up context and additional arguments for your event handler,
* however if you want to pass the context and arguments as additional signature arguments to on/delegate,
* you need to provide a null value for the configuration object, e.g: <code>node.on("gesturemove", fn, null, context, arg1, arg2, arg3)</code></p>
* @param fn {function} The method the event invokes. It receives the event facade of the underlying DOM event (mousemove or touchmove.touches[0]) which contains position co-ordinates.
* <dd>true, if the subscriber should be notified even if a "gesturemovestart" has not occured on the same node.</dd>
* <dd>Can be set to true/false to prevent default behavior as soon as the touchmove or mousemove is received. As with gesturemovestart, can also be set to function which returns true/false based on the event facade passed to it.</dd>
this._onMove,
node,
ce);
var se = this;
filter);
if (moveHandle) {
if (handle) {
if (delegate) {
if (fireMove) {
if (e.touches) {
fireMove = false;
if (fireMove) {
PREVENT_DEFAULT : false
* Sets up a "gesturemoveend" event, that is fired on touch devices in response to a single finger "touchend",
* has received a "gesturemove" or "gesturemovestart" event. The subscriber can set standAlone to true, in the configuration properties,
* if they want to listen for this event without a preceding "gesturemovestart" or "gesturemove".</p>
* <p>By default this event sets up it's internal "touchend" and "mouseup" DOM listeners on the document element. The subscriber
* can set the root configuration property, to specify which node to attach DOM listeners to, if different from the document.</p>
* <p>It is recommended that you use Y.bind to set up context and additional arguments for your event handler,
* however if you want to pass the context and arguments as additional signature arguments to on/delegate,
* you need to provide a null value for the configuration object, e.g: <code>node.on("gesturemoveend", fn, null, context, arg1, arg2, arg3)</code></p>
* @param fn {function} The method the event invokes. It receives the event facade of the underlying DOM event (mouseup or touchend.changedTouches[0]).
* <dd>true, if the subscriber should be notified even if a "gesturemovestart" or "gesturemove" has not occured on the same node.</dd>
* <dd>Can be set to true/false to prevent default behavior as soon as the touchend or mouseup is received. As with gesturemovestart, can also be set to function which returns true/false based on the event facade passed to it.</dd>
this._onEnd,
node,
ce);
var se = this;
filter);
if (handle) {
if (endHandle) {
if (delegate) {
if (fireMoveEnd) {
if (e.changedTouches) {
fireMoveEnd = false;
if (fireMoveEnd) {
PREVENT_DEFAULT : false