forked from mdbootstrap/TW-Elements
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.html
118 lines (102 loc) · 2.83 KB
/
events.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
<!DOCTYPE html>
<html>
<head>
<link href="../css/perfect-scrollbar.css" rel="stylesheet">
<script src="../dist/perfect-scrollbar.js"></script>
<style>
#container {
position: relative;
margin: 0px auto;
padding: 0px;
width: 600px;
height: 400px;
overflow: auto;
}
#container .content {
background-image: url('./assets/azusa.jpg');
width: 1280px;
height: 720px;
}
table {
width: 600px;
margin: 30px auto;
}
table td:first-child {
width: 200px;
padding-right: 10px;
text-align: right;
font-weight: bold;
}
</style>
</head>
<body>
<div id="container">
<div class="content">
</div>
</div>
<table>
<tr>
<td>Axis:</td>
<td id="axis"></td>
</tr>
<tr>
<td>Direction:</td>
<td id="direction"></td>
</tr>
<tr>
<td>Reach event:</td>
<td id="reach-event"></td>
</tr>
<tr>
<td>Reach state (<code>ps.reach</code>):</td>
<td id="reach-state"></td>
</tr>
</table>
<script>
var $ = document.querySelector.bind(document);
var container = $('#container');
var axis = $('#axis');
var direction = $('#direction');
var reachEvent = $('#reach-event');
var reachState = $('#reach-state');
var ps = new PerfectScrollbar(container);
function showReachState() {
reachState.textContent = JSON.stringify(ps.reach);
}
showReachState();
container.addEventListener('scroll', showReachState);
container.addEventListener('ps-scroll-y', function () {
axis.textContent = 'ps-scroll-y';
reachEvent.textContent = '';
});
container.addEventListener('ps-scroll-x', function () {
axis.textContent = 'ps-scroll-x';
reachEvent.textContent = '';
});
container.addEventListener('ps-scroll-up', function () {
direction.textContent = 'ps-scroll-up';
});
container.addEventListener('ps-scroll-down', function () {
direction.textContent = 'ps-scroll-down';
});
container.addEventListener('ps-scroll-left', function () {
direction.textContent = 'ps-scroll-left';
});
container.addEventListener('ps-scroll-right', function () {
direction.textContent = 'ps-scroll-right';
});
container.addEventListener('ps-y-reach-start', function () {
reachEvent.textContent = 'ps-y-reach-start';
});
container.addEventListener('ps-y-reach-end', function () {
reachEvent.textContent = 'ps-y-reach-end';
});
container.addEventListener('ps-x-reach-start', function () {
reachEvent.textContent = 'ps-x-reach-start';
});
container.addEventListener('ps-x-reach-end', function () {
reachEvent.textContent = 'ps-x-reach-end';
});
</script>
</body>
</html>