aboutsummaryrefslogtreecommitdiff
path: root/js/touch.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/touch.js')
-rw-r--r--js/touch.js61
1 files changed, 0 insertions, 61 deletions
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 @@
1/* Touch events */
2(function(exports) {
3var PM_TOUCH_SENSITIVITY = 15;
4var touchDX;
5var touchDY;
6var touchStartX;
7var touchStartY;
8
9function TouchManager(deck) {
10 this.deck_ = deck;
11
12 /* Add swiping */
13 document.body.addEventListener('touchstart', this.handleTouchStart.bind(this), false);
14 document.body.addEventListener('touchmove', this.handleTouchMove.bind(this), false);
15 document.body.addEventListener('touchend', this.handleTouchEnd.bind(this), false);
16}
17
18TouchManager.prototype.handleTouchStart = function(e) {
19 if (e.touches.length == 1) {
20 touchDX = 0;
21 touchDY = 0;
22
23 touchStartX = e.touches[0].pageX;
24 touchStartY = e.touches[0].pageY;
25
26 }
27};
28
29TouchManager.prototype.handleTouchMove = function(e) {
30 if (e.touches.length > 1) {
31 //this.cancelTouch();
32 } else {
33 touchDX = e.touches[0].pageX - touchStartX;
34 touchDY = e.touches[0].pageY - touchStartY;
35 }
36};
37
38TouchManager.prototype.handleTouchEnd = function(e) {
39 var dx = Math.abs(touchDX);
40 var dy = Math.abs(touchDY);
41
42 if ((dx > PM_TOUCH_SENSITIVITY) && (dy < (dx * 2 / 3))) {
43 if (touchDX > 0) {
44 this.deck_.prevSlide();
45 } else {
46 this.deck_.nextSlide();
47 }
48 }
49
50 //this.cancelTouch();
51};
52
53// TouchManager.prototype.cancelTouch = function() {
54// console.log(touchDX)
55// document.body.removeEventListener('touchmove', this.handleTouchMove.bind(this), false);
56// document.body.removeEventListener('touchend', this.handleTouchMove.bind(this), false);
57// };
58
59exports.TouchManager = TouchManager;
60
61})(window);