event-gestures-debug.js revision 0e232b16e640a3801393ca223d42fd1e0e9e83c3
45e9809aff7304721fddb95654901b32195c9c7avboxsync * The gestures module provides gesture events such as "flick", which normalize user interactions
45e9809aff7304721fddb95654901b32195c9c7avboxsync * across touch and mouse or pointer based input devices. This layer can be used by application developers
45e9809aff7304721fddb95654901b32195c9c7avboxsync * to build input device agnostic components which behave the same in response to either touch or mouse based
45e9809aff7304721fddb95654901b32195c9c7avboxsync * interaction.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * <p>Documentation for events added by this module can be found in the event document for the <a href="YUI.html#events">YUI</event> global.</p>
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @module event-gestures
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Adds support for a "flick" event, which is fired at the end of a touch or mouse based flick gesture, and provides
45e9809aff7304721fddb95654901b32195c9c7avboxsync * velocity of the flick, along with distance and time information.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @module event-gestures
45e9809aff7304721fddb95654901b32195c9c7avboxsync * @submodule event-flick
45e9809aff7304721fddb95654901b32195c9c7avboxsyncvar EVENT = ("ontouchstart" in Y.config.win && !Y.UA.chrome) ? {
* which the event is to be fired. The subscriber can also specify if there is a particular axis which
* they are interested in - "x" or "y". If no axis is specified, the axis along which there was most distance
* @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.
* @param cfg {Object} Optional. An object which specifies the minimum distance and/or velocity (in px/ms)
* of the flick gesture for which the event is to be fired and an axis of interest. e.g. { minDistance:10, minVelocity:0.5, axis:"x" }.
this._onStart,
node,
ce);
if (startHandle) {
if (endHandle) {
Y.log("flick, processArgs : minDistance =" + params.minDistance + ", minVelocity =" + params.minVelocity);
return params;
doc,
origE = e;
if (e.touches) {
if (start) {
e.flick = {
if (!endHandle) {
endEvent = e,
time,
axis;
if (valid) {
if (e.changedTouches) {
valid = false;
if (valid) {
xyDistance = [
if (isFinite(velocity) && (Math.abs(distance) >= params.minDistance) && (Math.abs(velocity) >= params.minVelocity)) {
e.flick = {
* 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 touch input
* 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().
* @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 theshold which should be crossed before the gesturemovestart is fired</dd>
* <dd>The minimum time theshold 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>
this._onStart,
node,
ce);
var se = this;
filter);
if (handle) {
if (startHandle) {
return params;
e.preventDefault();
if (delegate) {
var origE = e,
start = true,
if (e.touches) {
Y.log("gesturemovestart: params = button:" + button + ", minTime = " + minTime + ", minDistance = " + minDistance, "event-gestures");
if (start) {
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) {
* 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>
* @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>
this._onMove,
node,
ce);
var se = this;
filter);
if (moveHandle) {
if (handle) {
if (delegate) {
origE = e;
if (move) {
if (e.touches) {
if (move) {
* 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>
* @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>
this._onEnd,
node,
ce);
var se = this;
filter);
if (handle) {
if (endHandle) {
if (delegate) {
origE = e;
if (moveEnd) {
if (e.changedTouches) {
moveEnd = false;
if (moveEnd) {