/* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html version: 3.3.0 build: 3167 */ YUI.add('event-touch', function(Y) { /** * Adds touch event facade normalization properties (touches, changedTouches, targetTouches etc.) to the DOM event facade * * @module event-touch */ var SCALE = "scale", ROTATION = "rotation", IDENTIFIER = "identifier"; /** * Adds touch event facade normalization properties to the DOM event facade * * @method _touch * @for DOMEventFacade * @private * @param ev {Event} the DOM event * @param currentTarget {HTMLElement} the element the listener was attached to * @param wrapper {Event.Custom} the custom event wrapper for this DOM event */ Y.DOMEventFacade.prototype._touch = function(e, currentTarget, wrapper) { var i,l, etCached, et,touchCache; if (e.touches) { this.touches = []; touchCache = {}; for (i = 0, l = e.touches.length; i < l; ++i) { et = e.touches[i]; touchCache[Y.stamp(et)] = this.touches[i] = new Y.DOMEventFacade(et, currentTarget, wrapper); } } if (e.targetTouches) { this.targetTouches = []; for (i = 0, l = e.targetTouches.length; i < l; ++i) { et = e.targetTouches[i]; etCached = touchCache && touchCache[Y.stamp(et, true)]; this.targetTouches[i] = etCached || new Y.DOMEventFacade(et, currentTarget, wrapper); } } if (e.changedTouches) { this.changedTouches = []; for (i = 0, l = e.changedTouches.length; i < l; ++i) { et = e.changedTouches[i]; etCached = touchCache && touchCache[Y.stamp(et, true)]; this.changedTouches[i] = etCached || new Y.DOMEventFacade(et, currentTarget, wrapper); } } if (SCALE in e) { this[SCALE] = e[SCALE]; } if (ROTATION in e) { this[ROTATION] = e[ROTATION]; } if (IDENTIFIER in e) { this[IDENTIFIER] = e[IDENTIFIER]; } }; if (Y.Node.DOM_EVENTS) { Y.mix(Y.Node.DOM_EVENTS, { touchstart:1, touchmove:1, touchend:1, touchcancel:1, gesturestart:1, gesturechange:1, gestureend:1 }); } }, '3.3.0' ,{requires:['node-base']});