Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
190 lines (160 loc) · 3.66 KB
/
Copy pathindex.html
File metadata and controls
190 lines (160 loc) · 3.66 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
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
181
182
183
184
185
186
187
188
189
190
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Scrollama Demo: Basic</title>
<meta name="description" content="Scrollama Demo: Basic">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* default / demo page */
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
body {
min-height: 1280px;
font-weight: 300;
color: #2a2a2a;
}
p,
h1,
h2,
h3,
h4,
a {
margin: 0;
font-weight: 300;
}
a,
a:visited,
a:hover {
color: #f30;
text-decoration: none;
border-bottom: 1px solid currentColor;
}
#intro {
max-width: 40rem;
margin: 1rem auto;
text-align: center;
}
.intro__overline {
font-size: 1.4rem;
}
.intro__hed {
font-size: 1.4rem;
margin:
AB37
1.5rem auto;
text-transform: uppercase;
font-weight: 900;
letter-spacing: 0.05em;
}
.intro__dek {
font-size: 1.4rem;
}
/* demo */
#intro {
margin-bottom: 320px;
}
#outro {
height: 640px;
}
/* scrollama */
#scroll {
position: relative;
}
.scroll__text {
position: relative;
padding: 0 1rem;
margin: 0 auto;
width: 33%;
}
.step {
margin: 2rem auto 4rem auto;
border: 1px solid #333;
}
.step.is-active {
background-color: lightgoldenrodyellow;
}
.step p {
text-align: center;
padding: 1rem;
font-size: 1.5rem;
}
</style>
</head>
<body>
<section id='intro'>
<p class='intro__overline'>
<a href='https://github.com/russellgoldenberg/scrollama'>scrollama.js</a>
</p>
<h1 class='intro__hed'>Demo: Basic</h1>
<p class='intro__dek'>
Start scrolling to see how it works.
</p>
</section>
<section id='scroll'>
<div class='scroll__text'>
<div class='step' data-step='1'>
<p>STEP 1</p>
</div>
<div class='step' data-step='2'>
<p>STEP 2</p>
</div>
<div class='step' data-step='3'>
<p>STEP 3</p>
</div>
<div class='step' data-step='4'>
<p>STEP 4</p>
</div>
</div>
</section>
<section id='outro'></section>
<script src='https://unpkg.com/intersection-observer'></script>
<script src='../build/scrollama.js'></script>
<script>
var container = document.querySelector('#scroll');
var text = container.querySelector('.scroll__text');
var steps = text.querySelectorAll('.step');
// initialize the scrollama
var scroller = scrollama();
// scrollama event handlers
function handleStepEnter(response) {
// response = { element, direction, index }
console.log('enter', response);
// add to color to current step
response.element.classList.add('is-active');
}
function handleStepExit(response) {
// response = { element, direction, index }
console.log('exit', response);
// remove color from current step
response.element.classList.remove('is-active');
}
function init() {
// set random padding for different step heights (not required)
steps.forEach(function (step) {
var v = 100 + Math.floor(Math.random() * window.innerHeight / 4);
step.style.padding = v + 'px 0px';
});
// 1. setup the scroller with the bare-bones options
// this will also initialize trigger observations
// 3. bind scrollama event handlers (this can be chained like below)
scroller.setup({
step: '.scroll__text .step',
debug: false,
})
.onStepEnter(handleStepEnter)
.onStepExit(handleStepExit);
// setup resize event
window.addEventListener('resize', scroller.resize);
}
// kick things off
init();
</script>
</body>
</html>