forked from OpeningData/single-issuer-districts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrolly_practice.html
449 lines (319 loc) · 10.6 KB
/
scrolly_practice.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Single Issuer Districts</title>
<meta name="description" content="Single Issuer Districts">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css" />
<style>
.scrolly {
position: relative;
background-color: #f3f3f3;
padding: 1rem;
}
article {
position: relative;
padding: 0;
max-width: 20rem;
margin: 0 auto;
}
#firstfigure {
position: -webkit-sticky;
position: sticky;
left: 12.5%;
width: 75%;
margin: 0;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
background-color: #8a8a8a;
}
#firstfigure text{
text-align: center;
padding: 1rem;
position: absolute;
top: 50%;
left: 50%;
-moz-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
font-size: 8rem;
font-weight: 900;
color: #fff;
}
figure{
position: -webkit-sticky;
position: sticky;
left: 12.5%;
width: 75%;
margin: 0;
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
background-color: #8a8a8a;
}
figure p {
text-align: center;
padding: 1rem;
position: absolute;
top: 50%;
left: 50%;
-moz-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
font-size: 8rem;
font-weight: 900;
color: #fff;
}
.step {
margin: 0 auto
2rem auto;
color: #fff;
background-color: rgba(0,0,0,0.1)
}
.step:last-child {
margin-bottom: 10;
}
.step.is-active p {
background-color: goldenrod;
color: #3b3b3b;
}
.step.is-inactive p {
background-color: #3b3b3b;
color: #fff;
}
.step p {
text-align: center;
padding: 1rem;
font-size: 1.5rem;
background-color: #3b3b3b;
}
</style>
</head>
<body>
<!-- Header -->
<header id="header" style="background-color: rgb(252,252,252);">
<!-- <img src="./images/logo.png" style="height: 70%; width:auto; margin-top: 20%" alt=""> </a> -->
<a href="index.html" class="logo" style="color: #1c1c1c;"><strong>Opening Data</strong> - Making Open Data Accessible</a>
<!-- <nav>
<a href="#menu">Menu</a>
</nav> -->
</header>
<section id="main">
<div class="inner">
<header>
<h1 style="color: black;">The Issue with Single Issuer Districts </h1>
<p class="info">September 24, 2019 <a href="github.com/sapowers"> Sam Powers </a></p>
</header>
<p>
Start talking about health care here. It is important to get this narrative right.
<br>
Include some more cool stuff in this portion
<br>
and make sure to finish it off well
</p>
</div>
</section>
<main id = 'main1'>
<section class='scrolly' id = 'scrolly1'>
<figure id = 'figure1'>
<p> 0 </p>
</figure>
<article id = 'article1'>
<div class='step' id = 'step1' data-step='1'>
<p>STEP 1: I need this to say alittle bit more so I can understand </p>
</div>
<div class='step' id = 'step1' data-step='2'>
<p>STEP 2</p>
</div>
<div class='step' id = 'step1' data-step='3'>
<p>STEP 3</p>
</div>
<div class='step' id = 'step1' data-step='4'>
<p>STEP 4</p>
</div>
</article>
</section>
<section id="main">
<div class="inner">
<p>
<br>
add some text here<br>
we can talk about some important things <br>
before me move onto the next section
<br> <br>
</p>
</div>
</section>
</main>
<main id = 'main2'>
<section class='scrolly' id = 'scrolly2'>
<figure id ='figure2'>
<p> 0 </p>
</figure>
<article id = 'article2'>
<div class='step' id = 'step2' datastep='1'>
<p>STEP 1</p>
</div>
<div class='step' id = 'step2' data-step='2'>
<p>STEP 2</p>
</div>
<div class='step' id = 'step2' data-step='3'>
<p>STEP 3</p>
</div>
<div class='step' id = 'step2' data-step='4'>
<p>STEP 4</p>
</div>
</article>
</section>
<section id="main">
<div class="inner">
<p>
<br>
add some text here<br>
we can talk about some important things <br>
before me move onto the next section
<br> <br>
</p>
</div>
</section>
</main>
<script src='https://unpkg.com/[email protected]/dist/d3.min.js'></script>
<script src='https://unpkg.com/[email protected]/intersection-observer.js'></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/stickyfill/2.1.0/stickyfill.js"></script>
<script src="https://unpkg.com/scrollama"></script>
<script>
// using d3 for convenience
var main = d3.select('#main1');
var scrolly = main.select('#scrolly1');
var figure = scrolly.select('#figure1');
var article = scrolly.select('#article1');
var step = article.selectAll('#step1');
// initialize the scrollama
var scroller = scrollama();
// generic window resize listener event
function handleResize() {
// 1. update height of step elements
var stepH = Math.floor(window.innerHeight * 0.75);
step.style('height', stepH + 'px');
var figureHeight = window.innerHeight / 2
var figureMarginTop = (window.innerHeight - figureHeight) / 2
figure
.style('height', figureHeight + 'px')
.style('top', figureMarginTop + 'px');
// 3. tell scrollama to update new element dimensions
scroller.resize();
};
// scrollama event handlers
function setupStickyfill() {
d3.selectAll('.sticky').each(function () {
Stickyfill.add(this);
});
};
function handleProgress(resp) {
console.log('progress', resp)
step.classed('is-active', function(d,i) {
return resp.progress > 0 & resp.index === i
});
if (resp.progress == 0 & resp.index == 0 ) {
figure.select('p').text(0);
}
else{
figure.select('p').text(resp.index + 1) }
step.classed('is-inactive', function(d,i) {
return resp.index > i
})
};
function init() {
setupStickyfill();
// 1. force a resize on load to ensure proper dimensions are sent to scrollama
handleResize();
// 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: '#scrolly1 #article1 #step1',
offset: 0.5,
debug: false,
progress: true
})
//.onStepEnter(handleStepEnter)
.onStepProgress(handleProgress);
// setup resize event
window.addEventListener('resize', handleResize);
};
// kick things off
// init();
// using d3 for convenience
var main2 = d3.select('#main2')
var scrolly2 = main2.select('#scrolly2');
var figure2 = scrolly2.select('#figure2');
var article2 = scrolly2.select('#article2');
var step2 = article2.selectAll('#step2');
// initialize the scrollama
var scroller2 = scrollama();
// generic window resize listener event
function handleResize2() {
// 1. update height of step elements
var stepH = Math.floor(window.innerHeight * 0.75);
step2.style('height', stepH + 'px');
var figureHeight = window.innerHeight / 2;
var figureMarginTop = (window.innerHeight - figureHeight) / 2;
figure2
.style('height', figureHeight + 'px')
.style('top', figureMarginTop + 'px');
// 3. tell scrollama to update new element dimensions
scroller2.resize();
};
// scrollama event handlers
function setupStickyfill() {
d3.selectAll('.sticky').each(function () {
Stickyfill.add(this);
});
};
function handleProgress2(resp) {
console.log('progress', resp)
step2.classed('is-active', function(d,i) {
return resp.progress > 0 & resp.index === i
});
if (resp.progress == 0 & resp.index == 0 ) {
figure2.select('p').text(0);
}
else{
figure2.select('p').text(resp.index + 1) }
step2.classed('is-inactive', function(d,i) {
return resp.index > i
})
};
function init2() {
init();
setupStickyfill();
// 1. force a resize on load to ensure proper dimensions are sent to scrollama
handleResize2();
// 2. setup the scroller passing options
// this will also initialize trigger observations
// 3. bind scrollama event handlers (this can be chained like below)
scroller2.setup({
step: '#scrolly2 #article2 #step2',
offset: 0.5,
debug: false,
progress: true
})
///.onStepEnter(handleStepEnter2)
.onStepProgress(handleProgress2)
// setup resize event
window.addEventListener('resize', handleResize2);
};
// kick things off
init2();
</script>
<!-- Footer -->
<footer id="footer">
<div class="copyright">
Opening Data, Original Design: <a href="https://templated.co">TEMPLATED</a>
</div>
</footer>
</body>
</html>