-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
180 lines (155 loc) · 5.94 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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Scrollytelling Example</title>
<meta name="description" content="Scrollama: Example" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="style.css" />
<style>
#scrolly {
position: relative;
background-color: #fffff;
padding: 1rem;
}
article {
position: relative;
padding: 1rem;
max-width: 50rem;
margin: 0 auto;
line-height: 40px;
}
.sticky-thing {
position: -webkit-sticky;
position: sticky;
left: 0;
width: 100%;
margin: 0;
background-color: #8a8a8a;
z-index: 0;
top: 12.5vh;
height: 75vh;
/* Center everything inside */
display: flex;
align-items: center;
justify-content: center;
background-image: url('./images/background.jpg');
background-size: cover;
background-position: center center;
border-radius: 10px;
}
.sticky-thing p {
font-size: 8rem;
font-weight: 900;
color: rgb(255, 255, 255);
}
.step {
margin: 0 auto 2rem auto;
margin-bottom: 15rem;
color: rgb(212, 212, 212);
background-color: rgba(0, 0, 0, 0.1);
border-radius: 10px;
}
.step:last-child {
margin-bottom: 0;
}
.step.is-active p {
background-color:rgba(48, 48, 47, 0.753);
color: #ffffff;
border-radius: 10px;
text-align: left;
}
.step p {
text-align: left;
padding: 1rem;
font-size: 1.5rem;
}
</style>
</head>
<body>
<main>
<!-- <nav>
<a href="https://github.com/russellgoldenberg/scrollama">scrollama.js</a>
<div class="nav__examples">
<p>Examples:</p>
<a href="basic.html">Basic</a>
<a href="progress.html">Progress</a>
<a href="sticky-side.html">Sticky Side</a>
<a href="sticky-overlay.html">Sticky Overlay</a>
</div>
</nav> -->
<section id="intro">
<h1 class="intro__hed">Scrollytelling Example</i></h1>
<p class="intro__dek">
Online demonstration with scrollama
</p>
</section>
<section id="scrolly">
<div class="sticky-thing">
<!-- something pinned -->
<p>Welcome</p>
</div>
<article>
<div class="step" data-step="Section 1" data-color="#FFFFFF" data-image="url('./images/background.jpg')">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div class="step" data-step="Section 2" data-color="#FFFFFF" data-image="url('./images/background2.jpg')">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div class="step" data-step="Section 3" data-color="#FFFFFF" data-image="url('./images/background3.jpg')">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div class="step" data-step="Section 4" data-color="#FFFFFF" data-image="url('./images/background4.jpg')">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</article>
</section>
<section id="outro">
</section>
</main>
<!-- <div class='debug'></div> -->
<script src="https://unpkg.com/intersection-observer@0.5.1/intersection-observer.js"></script>
<script src="https://unpkg.com/scrollama"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
// using d3 for convenience
var main = document.querySelector("main");
var scrolly = main.querySelector("#scrolly");
var sticky = scrolly.querySelector(".sticky-thing");
var article = scrolly.querySelector("article");
var steps = article.querySelectorAll(".step");
// initialize the scrollama
var scroller = scrollama();
// scrollama event handlers
function handleStepEnter(response) {
// response = { element, direction, index }
var el = response.element;
// remove is-active from all steps
// then add is-active to this step
steps.forEach(step => step.classList.remove('is-active'));
el.classList.add('is-active');
// update graphic based on step
sticky.querySelector("p").innerText = el.dataset.step;
// sticky.style.backgroundColor = el.dataset.color;
sticky.style.backgroundImage = el.dataset.image;
}
function init() {
// 2. setup the scroller passing options
// this will also initialize trigger observations
// 3. bind scrollama event handlers (this can be chained like below)
scroller
.setup({
step: "#scrolly article .step",
offset: 0.5,
debug: false
})
.onStepEnter(handleStepEnter);
// setup resize event
window.addEventListener("resize", scroller.resize);
}
// kick things off
init();
</script>
</body>
</html>