]>
git.proxmox.com Git - sencha-touch.git/blob - src/src/event/recognizer/HorizontalSwipe.js
2 * A event recognizer created to recognize horizontal swipe movements.
6 Ext
.define('Ext.event.recognizer.HorizontalSwipe', {
7 extend
: 'Ext.event.recognizer.Swipe',
9 handledEvents
: ['swipe'],
11 onTouchStart: function(e
) {
12 if (this.callParent(arguments
) === false) {
16 var touch
= e
.changedTouches
[0];
18 this.startTime
= e
.time
;
20 this.startX
= touch
.pageX
;
21 this.startY
= touch
.pageY
;
24 onTouchMove: function(e
) {
25 var touch
= e
.changedTouches
[0],
27 absDeltaY
= Math
.abs(y
- this.startY
),
29 maxDuration
= this.getMaxDuration(),
30 maxOffset
= this.getMaxOffset();
32 if (time
- this.startTime
> maxDuration
) {
33 return this.fail(this.self
.MAX_DURATION_EXCEEDED
);
36 if (absDeltaY
> maxOffset
) {
37 return this.fail(this.self
.MAX_OFFSET_EXCEEDED
);
41 onTouchEnd: function(e
) {
42 if (this.onTouchMove(e
) !== false) {
43 var touch
= e
.changedTouches
[0],
45 deltaX
= x
- this.startX
,
46 distance
= Math
.abs(deltaX
),
47 duration
= e
.time
- this.startTime
,
48 minDistance
= this.getMinDistance(),
51 if (distance
< minDistance
) {
52 return this.fail(this.self
.DISTANCE_NOT_ENOUGH
);
55 direction
= (deltaX
< 0) ? 'left' : 'right';
57 this.fire('swipe', e
, [touch
], {