-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.html
133 lines (119 loc) · 2.9 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
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
<style>
* {
box-sizing: border-box;
}
body {
width: 100vw;
height: 100vh;
scrollbar-width: none;
font-family: Arial, Helvetica, sans-serif;
}
body::-webkit-scrollbar {
display: none;
}
#content {
background: white;
width: 500vw;
height: 500vh;
display: flex;
align-items: center;
justify-content: center;
user-select: none;
}
img {
pointer-events: none;
}
#toolbar {
position: fixed;
bottom: 20px;
background: #444;
color: white;
padding: 12px 20px;
display: flex;
left: 50%;
transform: translate(-50%);
width: max-length;
border-radius: 4px;
align-items: center;
}
#toolbar > * {
margin: 0 10px;
white-space: nowrap;
vertical-align: middle;
}
input {
vertical-align: middle;
}
input[type=number] {
width: 5em;
font-size: 14px;
}
#toolbar > button {
color: white;
background: #888;
border: none;
border-radius: 4px;
font-size: 14px;
padding: 4px 12px;
}
#toolbar .instructions {
position: absolute;
bottom: calc(100% + 20px);
left: 0;
right: 0;
color: #777;
white-space: normal;
text-align: center;
line-height: 1.4;
}
</style>
<div id="content">
<img src="tragopan.jpg">
</div>
<div id="toolbar">
<div class="instructions">
Pan with click-drag or two-finger-pan; zoom by ctrl/option-scroll or pinch!
</div>
<label><input onchange="toggleSpacePan(event)" type="checkbox">spacePan</label>
<label><input onchange="toggleScrollZoom(event)" type="checkbox">scrollZoom</label>
<label>scaleIncrement: <input onchange="setScaleIncrement(event)" type="number" step="0.01" value="0.04"></label>
<button onclick="reset(event)">reset</button>
<button onclick="zoomIn(event)">zoomIn</button>
<button onclick="zoomOut(event)">zoomOut</button>
</div>
<script src="tragopan.js"></script>
<script>
const panzoom = new Tragopan({
viewport: document.body,
content: document.getElementById('content'),
});
function toggleSpacePan(e) {
panzoom.configure({ spacePan: !panzoom.spacePan });
e.target.blur();
}
function toggleScrollZoom(e) {
panzoom.configure({ scrollZoom: !panzoom.scrollZoom });
e.target.blur();
}
function setScaleIncrement(e) {
panzoom.configure({ scaleIncrement: Number(e.target.value) });
e.target.blur();
}
function reset(e) {
panzoom.reset();
e.target.blur();
}
function zoomIn(e) {
panzoom.zoomIn();
e.target.blur();
}
function zoomOut(e) {
panzoom.zoomOut();
e.target.blur();
}
panzoom.on('panstart', (e) => { console.log('PAN START: ', e); });
panzoom.on('panmove', (e) => { console.log('PAN MOVE: ', e); });
panzoom.on('panend', (e) => { console.log('PAN END: ', e); });
panzoom.on('panzoom', (e) => { console.log('PAN ZOOM: ', e); });
panzoom.on('panchange', (e) => { console.log('PAN CHANGE: ', e); });
</script>