This repository has been archived by the owner on Feb 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
vertical-scroll.html
69 lines (61 loc) · 1.94 KB
/
vertical-scroll.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
<html lang="">
<head>
<title>Vertical Scroll Example</title>
</head>
<style>
.module {
margin: 20px auto;
width: 215%;
height: 300px;
}
.module-dummy {
background-color: lightgrey;
}
.red {
background-color: burlywood;
}
.blue {
background-color: cornflowerblue;
}
.pink {
background-color: lightpink;
}
.green {
background-color: darkseagreen;
}
.orange {
background-color: orange;
}
</style>
<body>
<p>
Click <button id="scroll-btn">here</button> and watch the page
scroll down 2000 pixels using an easing effect.
</p>
<div class="module module-dummy"></div>
<div class="module module-dummy red"></div>
<div class="module module-dummy"></div>
<div class="module module-dummy blue"></div>
<div class="module module-dummy"></div>
<div class="module module-dummy green"></div>
<div class="module module-dummy"></div>
<div class="module module-dummy pink"></div>
<div class="module module-dummy"></div>
<div class="module module-dummy orange"></div>
<!-- update the path to scroll script below -->
<script type="module">
import { scrollTo } from '../dist/scroll.min.js';
const scrollButton = document.getElementById('scroll-btn');
// when the scroll button is clicked, scroll down 2000 pixels
scrollButton.onclick = function () {
scrollTo(document.body, {
top: 2000,
duration: 1000,
easing: 'ease-out',
}).then(function () {
console.log('finished scrolling!');
});
};
</script>
</body>
</html>