forked from jairajs89/Touchy.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi_demo.html
75 lines (66 loc) · 1.67 KB
/
multi_demo.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
<!doctype html>
<html>
<head>
<title>Touchy demo - Draw dots</title>
<meta content="yes" name="apple-mobile-web-app-capable">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<style>
#touch-me {
z-index: 1;
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
}
.point {
z-index: 2;
position: absolute;
margin: -12px 0 0 -12px;
height: 25px;
width: 25px;
background: #000;
border-radius: 12px;
}
</style>
</head>
<body>
<div id="touch-me"></div>
<script src="touchy.js"></script>
<script>
Touchy.stopWindowBounce();
var touchMe = document.getElementById('touch-me');
Touchy(touchMe, {
one: function (hand, finger) {
function drawPoints (points) {
points.forEach(function (point) {
var elem = document.createElement('div');
elem.className = 'point';
elem.style.top = point.y + 'px';
elem.style.left = point.x + 'px';
elem.style.background = 'red';
touchMe.appendChild(elem);
});
}
hand.on('start', drawPoints);
hand.on('move' , drawPoints);
hand.on('end' , drawPoints);
},
two: function (hand, finger1, finger2) {
function drawPoints (points) {
points.forEach(function (point) {
var elem = document.createElement('div');
elem.className = 'point';
elem.style.top = point.y + 'px';
elem.style.left = point.x + 'px';
touchMe.appendChild(elem);
});
}
hand.on('start', drawPoints);
hand.on('move' , drawPoints);
hand.on('end' , drawPoints);
}
});
</script>
</body>
</html>