2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
8 YUI.add('event-touch', function(Y) {
11 * Adds touch event facade normalization properties (touches, changedTouches, targetTouches etc.) to the DOM event facade
17 ROTATION = "rotation",
18 IDENTIFIER = "identifier";
21 * Adds touch event facade normalization properties to the DOM event facade
26 * @param ev {Event} the DOM event
27 * @param currentTarget {HTMLElement} the element the listener was attached to
28 * @param wrapper {Event.Custom} the custom event wrapper for this DOM event
30 Y.DOMEventFacade.prototype._touch = function(e, currentTarget, wrapper) {
32 var i,l, etCached, et,touchCache;
40 for (i = 0, l = e.touches.length; i < l; ++i) {
42 touchCache[Y.stamp(et)] = this.touches[i] = new Y.DOMEventFacade(et, currentTarget, wrapper);
46 if (e.targetTouches) {
48 this.targetTouches = [];
50 for (i = 0, l = e.targetTouches.length; i < l; ++i) {
51 et = e.targetTouches[i];
52 etCached = touchCache && touchCache[Y.stamp(et, true)];
54 this.targetTouches[i] = etCached || new Y.DOMEventFacade(et, currentTarget, wrapper);
59 if (e.changedTouches) {
61 this.changedTouches = [];
63 for (i = 0, l = e.changedTouches.length; i < l; ++i) {
64 et = e.changedTouches[i];
65 etCached = touchCache && touchCache[Y.stamp(et, true)];
67 this.changedTouches[i] = etCached || new Y.DOMEventFacade(et, currentTarget, wrapper);
73 this[SCALE] = e[SCALE];
77 this[ROTATION] = e[ROTATION];
80 if (IDENTIFIER in e) {
81 this[IDENTIFIER] = e[IDENTIFIER];
85 if (Y.Node.DOM_EVENTS) {
86 Y.mix(Y.Node.DOM_EVENTS, {
98 }, '3.3.0' ,{requires:['node-base']});