Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

add a touch object to swipe callback arguments #634

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+8 −4
Split
View
@@ -66,8 +66,8 @@
(touch.y2 && Math.abs(touch.y1 - touch.y2) > 30))
swipeTimeout = setTimeout(function() {
- touch.el.trigger('swipe')
- touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)))
+ touch.el.trigger('swipe', touch)
+ touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)), touch)
touch = {}
}, 0)
View
@@ -213,10 +213,11 @@
},
testSwipe: function(t){
- var swipeCount = 0, element = $('#test').get(0)
+ var swipeCount = 0, element = $('#test').get(0), touchObject = {};
- $('#test').on('swipe', function(){
+ $('#test').on('swipe', function(e, touch){
swipeCount++
+ touchObject = touch
})
down(element, 10, 10)
@@ -232,6 +233,9 @@
setTimeout(function(){
t.resume(function(){
t.assertEqual(1, swipeCount)
+ t.assertEqual(
+ [10, 10, 70, 10].join(','),
+ [touchObject.x1, touchObject.y1, touchObject.x2, touchObject.y2].join(','))
})
}, 50)
})