-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
81 lines (71 loc) · 2.27 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
/>
<title>My Bootstrap Page</title>
</head>
<body>
<div class="container">
<div class="row">
<div id="touchArea" class="col-8 border" style="height: 50vh; background-color: lightblue">
<h1>Tocada</h1>
<p>Touch events with ease!</p>
<strong>Inspired by the wonderful Tocca.js library</strong>
<small>Written in Typescript with love</small>
<h2>Swipe around</h2>
<hr />
</div>
<div class="col-4">
<button id="destroy">Destroy</button>
<ol id="eventNames"></ol>
<div id="debug"></div>
</div>
</div>
</div>
<!-- <script type="module" src="/index.js"></script> -->
<script type="module">
import Tocada from "./dist/index.js";
console.log(Tocada);
const touchArea = document.getElementById("touchArea");
const debugEl = document.getElementById("debug");
const destroyBtn = document.getElementById("destroy");
const start = document.createElement("p");
start.textContent = new Date().toISOString();
debugEl.appendChild(start);
try {
const swipeHandler = new Tocada(touchArea);
const eventNames = [
"swipe",
"swipeleft",
"swiperight",
"swipeup",
"swipedown",
"pinch",
"spread",
"gesture",
];
console.log(swipeHandler);
destroyBtn.addEventListener("click", () => {
swipeHandler.destroy();
});
eventNames.forEach((eventName) => {
touchArea.addEventListener(eventName, (e) => {
console.log(e);
const eventLi = document.createElement("li");
eventLi.textContent = e.type;
debugEl.insertAdjacentElement("afterbegin", eventLi);
});
});
} catch (e) {
const errEl = document.createElement("p");
errEl.textContent = e.message;
debugEl.appendChild(errEl);
}
</script>
</body>
</html>