]>
git.proxmox.com Git - sencha-touch.git/blob - src/src/event/Dom.js
4 * DOM event. This class really extends {@link Ext.event.Event}, but for documentation
5 * purposes it's members are listed inside {@link Ext.event.Event}.
7 Ext
.define('Ext.event.Dom', {
8 extend
: 'Ext.event.Event',
10 constructor: function(event
) {
11 var target
= event
.target
,
14 if (target
&& target
.nodeType
!== 1) {
15 target
= target
.parentNode
;
17 touches
= event
.changedTouches
;
20 this.pageX
= touches
.pageX
;
21 this.pageY
= touches
.pageY
;
24 this.pageX
= event
.pageX
;
25 this.pageY
= event
.pageY
;
28 this.browserEvent
= this.event
= event
;
29 this.target
= this.delegatedTarget
= target
;
30 this.type
= event
.type
;
32 this.timeStamp
= this.time
= +event
.timeStamp
;
38 * @property {Number} distance
39 * The distance of the event.
41 * **This is only available when the event type is `swipe` and `pinch`.**
45 * @property {HTMLElement} target
46 * The target HTMLElement for this event. For example; if you are listening to a tap event and you tap on a `<div>` element,
47 * this will return that `<div>` element.
51 * @property {Number} pageX The browsers x coordinate of the event.
55 * @property {Number} pageY The browsers y coordinate of the event.
58 stopEvent: function() {
59 this.preventDefault();
61 return this.callParent();
65 * Prevents the browsers default handling of the event.
67 preventDefault: function() {
68 this.browserEvent
.preventDefault();
72 * Gets the x coordinate of the event.
73 * @deprecated 2.0 Please use {@link #pageX} property directly.
76 getPageX: function() {
77 return this.pageX
|| this.browserEvent
.pageX
;
81 * Gets the y coordinate of the event.
82 * @deprecated 2.0 Please use {@link #pageX} property directly.
85 getPageY: function() {
86 return this.pageY
|| this.browserEvent
.pageY
;
90 * Gets the X and Y coordinates of the event.
91 * @deprecated 2.0 Please use the {@link #pageX} and {@link #pageY} properties directly.
96 this.xy
= [this.getPageX(), this.getPageY()];
103 * Gets the target for the event. Unlike {@link #target}, this returns the main element for your event. So if you are
104 * listening to a tap event on Ext.Viewport.element, and you tap on an inner element of Ext.Viewport.element, this will
105 * return Ext.Viewport.element.
107 * If you want the element you tapped on, then use {@link #target}.
109 * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target
110 * @param {Number/Mixed} [maxDepth=10||document.body] (optional) The max depth to
111 * search as a number or element (defaults to 10 || document.body)
112 * @param {Boolean} returnEl (optional) `true` to return a Ext.Element object instead of DOM node.
113 * @return {HTMLElement}
115 getTarget: function(selector
, maxDepth
, returnEl
) {
116 if (arguments
.length
=== 0) {
117 return this.delegatedTarget
;
120 return selector
? Ext
.fly(this.target
).findParent(selector
, maxDepth
, returnEl
) : (returnEl
? Ext
.get(this.target
) : this.target
);
124 * Returns the time of the event.
127 getTime: function() {
131 setDelegatedTarget: function(target
) {
132 this.delegatedTarget
= target
;
135 makeUnpreventable: function() {
136 this.browserEvent
.preventDefault
= Ext
.emptyFn
;