-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
executable file
·146 lines (130 loc) · 3.46 KB
/
test.html
File metadata and controls
executable file
·146 lines (130 loc) · 3.46 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<style>
html {
width: 100%;
height: 100%;
}
body {
font-family: sans-serif;
margin: 0;
width: 200%;
height: 200%;
}
#all {
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 100px;
background-color: green;
}
span.all { color: green; }
#up-down-drag {
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 100px;
background-color: orange;
}
span.up-down-drag { color: orange; }
#click-drag {
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 100px;
background-color: red;
}
span.click-drag { color: red; }
#drag-horizontal {
position: absolute;
top: 100px;
left: 0;
width: 100px;
height: 100px;
background-color: yellow;
}
span.drag-horizontal { color: yellow; }
#drag-vertical {
position: absolute;
top: 0;
left: 100px;
width: 100px;
height: 100px;
background-color: brown;
}
span.click-drag { color: brown; }
</style>
</head>
<body>
<div id="text"></div>
<div id="all">All</div>
<div id="up-down-drag">Up/Down/Drag</div>
<div id="click-drag">Click/Drag</div>
<div id="drag-horizontal">Horizontal Drag</div>
<div id="drag-vertical">Vertical Drag</div>
<script src="vztouch.js"></script>
<script>
var text = document.getElementById('text');
var log = function(type, name, e) {
text.innerHTML += '<span class="' + type + '">' + name + ' ' + e.absolute.x + ', ' + e.absolute.y + '</span><br>';
};
var bind = function(name, map) {
if (!map) map = {};
var start = {x: 50, y: 50};
var opts = map.opts || {}; delete map.opts;
var m = {
up: function(e) { log(name, 'Up', e) },
down: function(e) { log(name, 'Down', e) },
click: function(e) { log(name, 'Click', e) },
drag: function(e) {
var s = this.style;
s.WebkitTransform =
s.MozTransform =
s.msTransform =
s.OTransform =
s.transform = 'translate3d(' + (e.absolute.x - start.x) + 'px, '
+ (e.absolute.y - start.y) + 'px, 0)';
}
};
for (var i in map) if (map.hasOwnProperty(i))
m[i] = map[i];
vz.touch(document.getElementById(name), opts, m);
};
// Test binding all events
bind('all');
// Test binding up/down/drag
bind('up-down-drag', {
click: undefined
});
// Test binding click/drag
bind('click-drag', {
up: undefined,
down: undefined
});
// Test horizontal drag
bind('drag-horizontal', {
click: undefined,
up: undefined,
down: undefined,
opts: { dragDirection: 'horizontal' }
});
// Test vertical drag
bind('drag-vertical', {
click: undefined,
up: undefined,
down: undefined,
opts: { dragDirection: 'vertical' }
});
// TODO
// * Up/drag
// * Down/drag
// * Click
// * Up/down/click
</script>
</body>
</html>