Skip to content

Commit cd3a5b4

Browse files
authored
Merge pull request #13 from offirgolan/swipe-fixes
[BUGFIX] Use originalEvent to access touches
2 parents 61a43c2 + 4160322 commit cd3a5b4

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

addon/mixins/swipe-support.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default Ember.Mixin.create({
1616
this._super(...arguments);
1717

1818
// jscs:disable
19-
let touch = e.touches[0];
19+
let touch = e.originalEvent.touches[0];
2020
// jscs:enable
2121

2222
meta = {
@@ -33,7 +33,7 @@ export default Ember.Mixin.create({
3333
this._super(...arguments);
3434

3535
// jscs:disable
36-
let touch = e.touches[0];
36+
let touch = e.originalEvent.touches[0];
3737
// jscs:enable
3838

3939
meta.differences = {
@@ -47,7 +47,7 @@ export default Ember.Mixin.create({
4747
}
4848

4949
// A valid swipe event uses only one finger
50-
if (e.touches.length > 1) {
50+
if (e.originalEvent.touches.length > 1) {
5151
meta.isInvalid = true;
5252
}
5353

tests/helpers/trigger-swipe-event.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,27 @@ export default function triggerSwipeEvent($el, direction, distance = 150) {
44
let endPos = swipeRight ? distance : 0;
55

66
$el.trigger($.Event('touchstart', {
7-
touches: [{
8-
pageX: startPos, pageY: 0,
9-
screenX: startPos, screenY: 0
10-
}]
7+
isSimulated: true,
8+
originalEvent: {
9+
touches: [{
10+
pageX: startPos,
11+
pageY: 0,
12+
screenX: startPos,
13+
screenY: 0
14+
}]
15+
}
1116
}));
1217

1318
$el.trigger($.Event('touchmove', {
14-
touches: [{
15-
pageX: endPos, pageY: 0,
16-
screenX: endPos, screenY: 0
17-
}]
19+
isSimulated: true,
20+
originalEvent: {
21+
touches: [{
22+
pageX: endPos,
23+
pageY: 0,
24+
screenX: endPos,
25+
screenY: 0
26+
}]
27+
}
1828
}));
1929

2030
$el.trigger($.Event('touchend'));

0 commit comments

Comments
 (0)