Permalink
Browse files

add a touch object to swipe callback arguments

  • Loading branch information...
1 parent dea8af9 commit 90ebd7995b40ac59e7b7ff0baa4f412b7dcb7459 lowol committed Nov 7, 2012
Showing with 8 additions and 4 deletions.
  1. +2 −2 src/touch.js
  2. +6 −2 test/touch.html
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)
})

0 comments on commit 90ebd79

Please sign in to comment.