forked from iamdustan/smoothscroll
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
49 lines (39 loc) · 1.61 KB
/
test.html
File metadata and controls
49 lines (39 loc) · 1.61 KB
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
<!doctype html>
<html>
<head>
</head>
<body>
<h1>Quick and dirty scrollTo(x, y, { behavior: 'smooth' }) testing</h1>
<p style='height: 500px'>For real. Really quick. Really dirty.</p>
<h2 id='scrollIntoView'>A second after pageload, you should be smoothly scrolled to my neighborhood</h2>
<p style='height: 500px'>Welcome to the neighborhood.</p>
<h2>Eventually this will be scrolled to</h2>
<p style='height: 500px'>Well, maybe I was lying.</p>
<script src="smoothscroll.js"></script>
<script>
var T = 2000;
document.addEventListener('DOMContentLoaded', function(e) { setTimeout(function() {
console.log('scrollTo 0, 300');
window.scrollTo(0, 300, { behavior: 'smooth' });
setTimeout(function() {
console.log('scrollTo 0, 600');
window.scrollTo(0, 1200, { behavior: 'smooth' });
}, 150);
setTimeout(function() {
console.log('#scrollIntoView toTop');
document.getElementById('scrollIntoView')
.scrollIntoView(true, { behavior: 'smooth' }); setTimeout(function() {
console.log('scrollTo 0, 0');
window.scrollTo(0, 0, { behavior: 'smooth' }); setTimeout(function() {
console.log('#scrollIntoView toBottom');
document.getElementById('scrollIntoView')
.scrollIntoView(false, { behavior: 'smooth' }); setTimeout(function() {
console.log('scrollBy 0 400');
window.scrollBy(0, 400, { behavior: 'smooth' }); setTimeout(function() {
console.log('scrollBy 0 -400');
window.scrollBy(0, -400, { behavior: 'smooth' });
}, T); }, T); }, T); }, T); }, T); }, T); }
, false);
</script>
</body>
</html>