forked from Rob--W/grab-to-pan.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
59 lines (57 loc) · 1.49 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
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Grab-to-pan.js demo</title>
<link rel="stylesheet" href="grab-to-pan.css" type="text/css">
<style>
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.scrollable {
overflow: auto;
width: 100%;
height: 100%;
max-width: 300px;
max-height: 300px;
background-color: #EEE;
}
.filler {
width: 200%;
font-size: 100px; /* I don't want to type a huge wall of Lorem ipsum */
}
</style>
</head>
<body>
<label><input type="checkbox" id="activate-g2p" checked> Activate Grab to Pan</label>
<div class="scrollable" id="scrollable-container">
<div class="filler">
Grab to pan - Grab this section with your mouse, and move your mouse around to pan the content.
</div>
</div>
<script src="grab-to-pan.js"></script>
<script>
document.getElementById('activate-g2p').onchange = function() {
if (this.checked) g2p.activate();
else g2p.deactivate();
};
var scrollableContainer = document.getElementById('scrollable-container');
var g2p = new GrabToPan({
element: scrollableContainer, // required
onActiveChanged: function(isActive) { // optional
if (window.console) { // IE doesn't define console unless the devtools are open
console.log('Grab-to-pan is ' + (isActive ? 'activated' : 'deactivated'));
}
}
});
g2p.activate();
</script>
</body>
</html>