-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
129 lines (119 loc) · 4.26 KB
/
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
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
<!DOCTYPE html>
<html>
<head>
<script src="touch-transform.js"></script>
<style>
html, body {
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
font-size: 1.1em;
}
body {
padding: 1vh 10vw;
}
pre {
border: 1px solid black;
width: 100%;
padding: 1vw;
box-sizing: border-box;
}
.demo-area {
width: 100%;
height: 80vh;
background: #aaa;
overflow: hidden;
position:relative;
text-align: center;
padding: 1vh
}
.demo-element {
margin: -16vw 0 0 -16vw;
width: 32vw;
height: 32vw;
background: greenyellow;
position:absolute;
top: 50%;
left: 50%;
line-height: 32vw;
text-align: center;
user-select: none;
}
.demo-element div {
display: inline-block;
line-height:30px;
}
</style>
</head>
<body>
<div class="demo">
<h2>Basic Usage</h2>
<div class="demo-area">
<div class="demo-element" id="basicExample">Drag me!</div>
</div>
<pre class="code">
TouchTransform.attach(document.querySelector('#basicExample'));</pre>
<script>
TouchTransform.attach(document.querySelector('#basicExample'));
</script>
</div>
<div class="demo">
<h2>Single touch mode</h2>
<div class="demo-area">
<div class="demo-element" id="oneFingerExample">Drag me with one finger!</div>
</div>
<pre class="code">
TouchTransform.attach(document.querySelector('#oneFingerExample'),{
singleTouch: true,
});</pre>
<script>
TouchTransform.attach(document.querySelector('#oneFingerExample'),{
singleTouch: true,
minScale: 1,
maxScale: 2
});
</script>
</div>
<div class="demo">
<h2>Custom target</h2>
<div class="demo-area" id="area">
<div class="demo-element" id="customTarget"><div>Drag me or the area around me!</div></div>
</div>
<pre class="code">
TouchTransform.attach(document.querySelector('#area'),{
target: document.querySelector('#customTarget')
});</pre>
<script>
TouchTransform.attach(document.querySelector('#area'),{
target: document.querySelector('#customTarget')
});
</script>
</div>
<div class="demo">
<h2>Using onUpdate and no target</h2>
<div class="demo-area">
<div class="demo-element" id="updateExample">
<div>
Drag me!
</div>
</div>
<span class="debug" id="debugOutput"></span>
</div>
<pre class="code">
TouchTransform.attach(document.querySelector('#updateExample'),{
target: false,
onUpdate: function(cssTransform, transformData){
document.querySelector('#debugOutput').innerText = cssTransform;
console.log(transformData);
}
});</pre>
<script>
TouchTransform.attach(document.querySelector('#updateExample'),{
target: false,
onUpdate: function(cssTransform, transformData, touches){
document.querySelector('#debugOutput').innerText = cssTransform;
console.log(transformData);
}
});
</script>
</div>
</body>
</html>