event-flick.js revision 0e232b16e640a3801393ca223d42fd1e0e9e83c3
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * The gestures module provides gesture events such as "flick", which normalize user interactions
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * across touch and mouse or pointer based input devices. This layer can be used by application developers
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * to build input device agnostic components which behave the same in response to either touch or mouse based
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * interaction.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * <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>
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @module event-gestures
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Adds support for a "flick" event, which is fired at the end of a touch or mouse based flick gesture, and provides
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * velocity of the flick, along with distance and time information.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @module event-gestures
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @submodule event-flick
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsyncvar EVENT = ("ontouchstart" in Y.config.win && !Y.UA.chrome) ? {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * Sets up a "flick" event, that is fired whenever the user initiates a flick gesture on the node
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * where the listener is attached. The subscriber can specify a minimum distance or velocity for
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * which the event is to be fired. The subscriber can also specify if there is a particular axis which
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * they are interested in - "x" or "y". If no axis is specified, the axis along which there was most distance
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * covered is used.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @event flick
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param type {string} "flick"
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @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.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @param cfg {Object} Optional. An object which specifies the minimum distance and/or velocity (in px/ms)
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * 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" }.
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync * @return {EventHandle} the detach handle
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync var params = (args[3] !== undefined) ? Y.merge(args.splice(3, 1)[0]) : {};
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync doc = (node.get(NODE_TYPE) === 9) ? node : node.get(OWNER_DOCUMENT);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync endHandle = doc.on(EVENT[END], Y.bind(this._onEnd, this), null, node, subscriber, ce);
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (e.changedTouches.length === 1 && e.touches.length === 0) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync axis = params.axis || (Math.abs(xyDistance[0]) >= Math.abs(xyDistance[1])) ? 'x' : 'y';
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync if (isFinite(velocity) && (Math.abs(distance) >= params.minDistance) && (Math.abs(velocity) >= params.minVelocity)) {
febf3f1de573e25fb134b8453a22b0732b4c52e2vboxsync}, '@VERSION@' ,{requires:['node-base','event-touch','event-synthetic']});