From 32f207b326a2138c14e0502fcd58c5c3457cde35 Mon Sep 17 00:00:00 2001 From: Eric Bidelman Date: Mon, 16 Apr 2012 12:04:03 -0700 Subject: mobile tweaks. Modernizr touch detection --- js/touch.js | 61 ------------------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 js/touch.js (limited to 'js/touch.js') diff --git a/js/touch.js b/js/touch.js deleted file mode 100644 index e0519e6..0000000 --- a/js/touch.js +++ /dev/null @@ -1,61 +0,0 @@ -/* Touch events */ -(function(exports) { -var PM_TOUCH_SENSITIVITY = 15; -var touchDX; -var touchDY; -var touchStartX; -var touchStartY; - -function TouchManager(deck) { - this.deck_ = deck; - - /* Add swiping */ - document.body.addEventListener('touchstart', this.handleTouchStart.bind(this), false); - document.body.addEventListener('touchmove', this.handleTouchMove.bind(this), false); - document.body.addEventListener('touchend', this.handleTouchEnd.bind(this), false); -} - -TouchManager.prototype.handleTouchStart = function(e) { - if (e.touches.length == 1) { - touchDX = 0; - touchDY = 0; - - touchStartX = e.touches[0].pageX; - touchStartY = e.touches[0].pageY; - - } -}; - -TouchManager.prototype.handleTouchMove = function(e) { - if (e.touches.length > 1) { - //this.cancelTouch(); - } else { - touchDX = e.touches[0].pageX - touchStartX; - touchDY = e.touches[0].pageY - touchStartY; - } -}; - -TouchManager.prototype.handleTouchEnd = function(e) { - var dx = Math.abs(touchDX); - var dy = Math.abs(touchDY); - - if ((dx > PM_TOUCH_SENSITIVITY) && (dy < (dx * 2 / 3))) { - if (touchDX > 0) { - this.deck_.prevSlide(); - } else { - this.deck_.nextSlide(); - } - } - - //this.cancelTouch(); -}; - -// TouchManager.prototype.cancelTouch = function() { -// console.log(touchDX) -// document.body.removeEventListener('touchmove', this.handleTouchMove.bind(this), false); -// document.body.removeEventListener('touchend', this.handleTouchMove.bind(this), false); -// }; - -exports.TouchManager = TouchManager; - -})(window); -- cgit v1.2.3