-
Notifications
You must be signed in to change notification settings - Fork 38
/
example.html
51 lines (45 loc) · 999 Bytes
/
example.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
<html>
<head>
<title>scroll-to - smooth javascript window scrolling with requestAnimationFrame</title>
<style>
body {
padding: 50px;
}
ul {
min-width: 1500px;
}
ul li {
margin: 10px;
padding: 5px;
list-style: none;
display: block;
float: left;
width: 100px;
height: 100px;
border: 1px solid #eee;
text-align: center;
line-height: 100px;
}
</style>
</head>
<body>
<ul></ul>
<script src="build/build.js"></script>
<script>
var scroll = require('scroll-to');
var events = require('event');
var ul = document.querySelector('ul');
for (var i = 0; i < 500; i++) {
var li = document.createElement('li');
li.textContent = 'item ' + i;
ul.appendChild(li);
}
events.bind(window, 'click', function(e){
var x = e.pageX;
var y = e.pageY;
console.log('scrolling to (%s, %s)', x, y);
scroll(x, y);
});
</script>
</body>
</html>