From 2d305a8a9996ce8d1c658670b899107d9edce56e Mon Sep 17 00:00:00 2001 From: Stefan Andres Charsley Date: Sat, 14 Sep 2013 02:46:34 +1200 Subject: [PATCH] Added swipe event triggering when using MSGesture --- src/touch.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/touch.js b/src/touch.js index 5f5207770..06bd881aa 100644 --- a/src/touch.js +++ b/src/touch.js @@ -38,10 +38,23 @@ touch = {} } + var gesture; + if ('undefined' !== typeof(MSGesture)) { + gesture = new MSGesture(); + gesture.target = document.body; + } + $(document).ready(function(){ var now, delta $(document.body) + .bind('MSGestureEnd', function(e){ + var swipe_dir = e.velocityX > 1 ? 'Right' : e.velocityX < -1 ? 'Left' : e.velocityY > 1 ? 'Down' : e.velocityY < -1 ? 'Up' : null; + if (swipe_dir) { + touch.el.trigger('swipe') + touch.el.trigger('swipe'+ swipe_dir) + } + }) .on('touchstart MSPointerDown', function(e){ if(e.type == 'MSPointerDown' && (e.pointerType != e.MSPOINTER_TYPE_TOUCH || !e.isPrimary)) return; now = Date.now()