summaryrefslogtreecommitdiff
path: root/js/swipes.js
blob: d1b7ada7a5fa29f0f6141c69b71c2a5e399fc91d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var _swipe_attempts = 0;

function setup_swipes() {

	if (typeof $(window).swipe == "undefined") {
		console.log("swipes not yet available", _swipe_attempts);

		if (_swipe_attempts < 4) {
			_swipe_attempts++;

			window.setTimeout(function() {
				setup_swipes();
			}, 250);
		}

		return;
	}

	console.log("setting up swipe events");

	$(window).swipe({
		swipe:function(event, direction, distance, duration, fingerCount, fingerData) {
			console.log("swipe: ", direction);

			switch (direction) {
				case "right":
					parent.prev_page();
					break;
				case "left":
					parent.next_page();
					break;
			}
		},
		tap:function(event, target) {
			if (parent.$(".header").is(":visible")) {
				parent.show_ui(false);
				parent.request_fullscreen();
			} else {
				parent.show_ui(true);
				parent.disable_fullscreen();
			}
		},
	});
}

setup_swipes();