-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
87 lines (78 loc) · 2.8 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Sphinx Scroller</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"/>
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3-theme-blue-grey.css"/>
<style>
.show {
display: block;
} .hidden {
display: none;
}
.frame {
width: 100%;
height: 100px;
overflow: auto;
padding: 0 5px 0 5px;
}
.phade {
opacity: 0;
display: none;
}
.spacer { /* This space has been left intentionally blank */ }
.halo {
background-image: url('https://content.halocdn.com/media/Default/games/halo-5-guardians/page/h5-guardians-facebook-1200x630-ba103624b3f34af79fe8cb2d340dce3f.jpg');
}
.roblox {
background-image: url('https://images.rbxcdn.com/d66ae37d46e00a1ecacfe9531986690a.jpg');
}
</style>
</head>
<body>
<div class="frame" id="page">
<div class="stage" id="stage"></div>
<div class="phade halo">qq</div>
<div class="phade roblox">ww</div>
<div class="spacer"></div>
</div>
<script>
var phadesTriggered = 0;
$(document).ready(function () {
$('.frame').css({height: new windowDimensions().height + 'px'});
$('.container').css({height: new windowDimensions().height + 1 + 'px'});
$('.spacer').css({height: new windowDimensions().height + 1 + 'px'});
$('.phade').css({height: new windowDimensions().height + 'px'});
});
function documentDimensions () {
this.height = $(document).height();
this.width = $(document).width();
}
function windowDimensions () {
this.height = $(window).height();
this.width = $(window).width();
}
function getScroll () {
return $('#page').scrollTop();
}
$('#page').scroll(function () {
var scroll = Math.floor(getScroll() / new windowDimensions().height) * new windowDimensions().height;
var scrollRaw = $('#page').scrollTop();
var currentPhade = document.getElementsByClassName('phade')[scroll / new windowDimensions().height];
var previousPhade = document.getElementsByClassName('phade')[phadesTriggered - 1];
$(currentPhade).offset({top: scrollRaw / new windowDimensions().height});
if ($(currentPhade).css('display') === 'none') {
$(currentPhade).css('display', 'block');
$('#page').scrollTop(scroll, 0);
$(currentPhade).animate({opacity: '1'}, 3000);
$('.spacer').css({height: new windowDimensions().height + new windowDimensions().height + 'px'});
phadesTriggered++;
if (phadesTriggered >= document.getElementsByClassName('phade').length) {
$('.spacer').css('display', 'none');
}
}
});
</script>
</body>
</html>