-
Notifications
You must be signed in to change notification settings - Fork 10
/
test.html
89 lines (79 loc) · 1.95 KB
/
test.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
<html>
<head>
<title>pinch component</title>
<meta name="viewport" content="width=device-width, initial-scale=0.5, maximum-scale=0.5, user-scalable=no" />
<style>
html, body {
margin: 0;
padding: 0;
}
h2 {
position: absolute;
color: #ccc;
top: 0;
left: 10px;
z-index: 1000;
}
#container {
height: 100%;
width: 100%;
overflow: auto;
position: relative;
}
#log {
top: 0;
right: 0;
height: 50px;
width: 150px;
text-align: right;
position: absolute;
}
#img {
background: no-repeat url('http://interfacelift.com/wallpaper/D47cd523/03325_valleyofthestars_2880x1800.jpg') center center;
width: 100%;
height: 100%;
position: relative;
-webkit-user-select: none;
}
@media only screen
and (max-width : 640px) {
#img {
background: no-repeat url('http://interfacelift.com/wallpaper/D47cd523/03325_valleyofthestars_640x1136.jpg') center center;
}
}
.dot {
position: absolute;
width: 10px;
height: 10px;
border-radius: 5px;
background: yellow;
top: 0;
right: 0;
}
</style>
</head>
<body>
<h2>place two fingers onto the image</h2>
<div id="container">
<div id="img"></div>
<div class="dot"></div>
</div>
<script src="../build/build.js" type="text/javascript"></script>
<script type="text/javascript">
var pinch = require('pinch');
var img = document.querySelector('#img');
var dot = document.querySelector('.dot');
pinch(img, function(e) {
dot.style.left = e.x + 'px';
dot.style.top = e.y + 'px';
dot.style['-webkit-transform'] = 'scale(' + e.scale + ')';
});
function log(str) {
var el = document.getElementById('log');
var div = document.createElement('div')
div.innerText = str;
el.insertBefore(div, el.firstChild);
}
</script>
</body>
</html>