-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
46 lines (43 loc) · 1.11 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Swipe</title>
<link rel="stylesheet" type="text/css" href="project.css" />
<script src="swipe.js"></script>
</head>
<body>
<div id="swipeBox">
<h2 class="infoEl"></h2>
<h3>swipe anywhere</h3>
</div>
</body>
<script type="text/javascript">
(function () {
var swipeEl = document.body;
var infoEl = document.querySelector('.infoEl');
var curDir = '';
var count = 1;
var swipe = new Swipe(swipeEl, { doPreventScroll: true });
function handleSwipe (evt) {
var text = infoEl.innerHTML;
if (evt.type === curDir) {
count++;
if (count === 2) {
text += (' x' + count);
} else {
text = text.substring(0, text.length - (count - 1).toString().length) + count;
}
} else {
count = 1;
text = curDir = evt.type;
}
infoEl.innerHTML = text;
}
swipeEl.addEventListener(swipe.up, handleSwipe);
swipeEl.addEventListener(swipe.down, handleSwipe);
swipeEl.addEventListener(swipe.left, handleSwipe);
swipeEl.addEventListener(swipe.right, handleSwipe);
})();
</script>
</html>