-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeline_test.html
348 lines (308 loc) · 10.7 KB
/
timeline_test.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* {
box-sizing: border-box;
}
body {
background-color: #474e5d;
font-family: Helvetica, sans-serif;
}
#elTest {
position: fixed;
top:0;
left:0;
height: 50%;
width: 100%;
background-color: aqua;
z-index: 2;
}
#Vieques {
position:absolute;
top:15%;
left: 10%;
z-index: 5;
}
.map {
z-index: 3;
width:100%;
height:100%;
position: absolute;
}
/* The actual timeline (the vertical ruler) */
.timeline {
position: relative;
max-width: 1200px;
margin: 0 auto;
margin-top: 60%;
}
/* The actual timeline (the vertical ruler) */
.timeline::after {
content: '';
position: absolute;
width: 6px;
background-color: white;
top: 0;
bottom: 0;
left: 50%;
margin-left: -3px;
}
/* Container around content */
.container {
padding: 10px 40px;
position: relative;
background-color: inherit;
width: 50%;
}
/* The circles on the timeline */
.container::after {
content: '';
position: absolute;
width: 25px;
height: 25px;
right: -17px;
background-color: white;
border: 4px solid #FF9F55;
top: 15px;
border-radius: 50%;
z-index: 1;
}
/* Place the container to the left */
.left {
left: 0;
}
/* Place the container to the right */
.right {
left: 50%;
}
/* Add arrows to the left container (pointing right) */
.left::before {
content: " ";
height: 0;
position: absolute;
top: 22px;
width: 0;
z-index: 1;
right: 30px;
border: medium solid white;
border-width: 10px 0 10px 10px;
border-color: transparent transparent transparent white;
}
/* Add arrows to the right container (pointing left) */
.right::before {
content: " ";
height: 0;
position: absolute;
top: 22px;
width: 0;
z-index: 1;
left: 30px;
border: medium solid white;
border-width: 10px 10px 10px 0;
border-color: transparent white transparent transparent;
}
/* Fix the circle for containers on the right side */
.right::after {
left: -16px;
}
/* The actual content */
.content {
padding: 20px 30px;
background-color: white;
position: relative;
border-radius: 6px;
}
/* Media queries - Responsive timeline on screens less than 600px wide */
@media screen and (max-width: 600px) {
/* Place the timelime to the left */
.timeline::after {
left: 31px;
}
/* Full-width containers */
.container {
width: 100%;
padding-left: 70px;
padding-right: 25px;
}
/* Make sure that all arrows are pointing leftwards */
.container::before {
left: 60px;
border: medium solid white;
border-width: 10px 10px 10px 0;
border-color: transparent white transparent transparent;
}
/* Make sure all circles are at the same spot */
.left::after, .right::after {
left: 15px;
}
/* Make all right containers behave like the left ones */
.right {
left: 0%;
}
}
.empty {
opacity: 0;
}
</style>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""></script>
<script src ="./js/L.Map.Sync.js"></script>
</head>
<body>
<div id="elTest">
<div id="map" class="map"></div>
<!-- <div id="m1937" class="map"></div>
<div id="m1977" class="map"></div>
<div id="m1983" class="map"></div>
<div id="m2009" class="map"></div>
<div id="m2020" class="map"></div>
<div id="osm" class="map"></div> -->
</div>
<div class="timeline">
<div class="container empty">
<div class="content">
<h2>Introduction</h2>
</div>
</div>
<div class="container left">
<div class="content">
<h2 class="map2020">t1854</h2>
<p>Lorem ipsum dolor sit amet, quo ei simul congue exerci, ad nec admodum perfecto mnesarchum, vim ea mazim fierent detracto. Ea quis iuvaret expetendis his, te elit voluptua dignissim per, habeo iusto primis ea eam.</p>
</div>
</div>
<div class="container right">
<div class="content">
<h2>t1883</h2>
<p>Lorem ipsum dolor sit amet, quo ei simul congue exerci, ad nec admodum perfecto mnesarchum, vim ea mazim fierent detracto. Ea quis iuvaret expetendis his, te elit voluptua dignissim per, habeo iusto primis ea eam.</p>
</div>
</div>
<div class="container left">
<div class="content">
<h2 class="map2020">t1937</h2>
<p>Lorem ipsum dolor sit amet, quo ei simul congue exerci, ad nec admodum perfecto mnesarchum, vim ea mazim fierent detracto. Ea quis iuvaret expetendis his, te elit voluptua dignissim per, habeo iusto primis ea eam.</p>
</div>
</div>
<div class="container right">
<div class="content">
<h2>t1977</h2>
<p>Lorem ipsum dolor sit amet, quo ei simul congue exerci, ad nec admodum perfecto mnesarchum, vim ea mazim fierent detracto. Ea quis iuvaret expetendis his, te elit voluptua dignissim per, habeo iusto primis ea eam.</p>
</div>
</div>
<div class="container left">
<div class="content">
<h2>t1983</h2>
<p>Lorem ipsum dolor sit amet, quo ei simul congue exerci, ad nec admodum perfecto mnesarchum, vim ea mazim fierent detracto. Ea quis iuvaret expetendis his, te elit voluptua dignissim per, habeo iusto primis ea eam.</p>
</div>
</div>
<div class="container right">
<div class="content">
<h2>t2009</h2>
<p>Lorem ipsum dolor sit amet, quo ei simul congue exerci, ad nec admodum perfecto mnesarchum, vim ea mazim fierent detracto. Ea quis iuvaret expetendis his, te elit voluptua dignissim per, habeo iusto primis ea eam.</p>
</div>
</div>
<div class="container left">
<div class="content">
<h2>t2020</h2>
<p>Lorem ipsum dolor sit amet, quo ei simul congue exerci, ad nec admodum perfecto mnesarchum, vim ea mazim fierent detracto. Ea quis iuvaret expetendis his, te elit voluptua dignissim per, habeo iusto primis ea eam.</p>
</div>
</div>
<div class="container right">
<div class="content">
<h2>tOSM</h2>
<p>Lorem ipsum dolor sit amet, quo ei simul congue exerci, ad nec admodum perfecto mnesarchum, vim ea mazim fierent detracto. Ea quis iuvaret expetendis his, te elit voluptua dignissim per, habeo iusto primis ea eam.</p>
</div>
</div>
<div class="container empty">
<div class="content">
<h2>END</h2>
</div>
</div>
</div>
<div id="Vieques">
<h1>Vieques Time Scrollama</h1>
<h2>Scroll me to see landscape change through time</h2>
</div>
<script>
const daZoom = 15;
const daCenter = [18.149365851907245, -65.44249892234804,];
var map = L.map('map', { zoomControl: false , attributionControl: false,}).setView(daCenter, daZoom);
const t1854 = L.tileLayer('https://cartocollective.blob.core.windows.net/vieques/v1854/{z}/{x}/{y}.png', {} ).addTo(map).setOpacity(0);
const t1883 = L.tileLayer('https://cartocollective.blob.core.windows.net/vieques/v1883/{z}/{x}/{y}.png', {} ).addTo(map).setOpacity(0);
const t1937 = L.tileLayer('https://cartocollective.blob.core.windows.net/vieques/v1937/{z}/{x}/{y}.png', {} ).addTo(map).setOpacity(0);
// var map1977 = L.map('m1977', { zoomControl: false, attributionControl: false, }).setView(daCenter, daZoom);
const t1977 = L.tileLayer('https://cartocollective.blob.core.windows.net/vieques/v1977/{z}/{x}/{y}.png', {} ).addTo(map).setOpacity(0);
// var map1983 = L.map('m1983', { zoomControl: false, attributionControl: false, }).setView(daCenter, daZoom);
const t1983 = L.tileLayer('https://cartocollective.blob.core.windows.net/vieques/v1983/{z}/{x}/{y}.png', {} ).addTo(map).setOpacity(0);
// var map2009 = L.map('m2009', { zoomControl: false, attributionControl: false, }).setView(daCenter, daZoom);
const t2009 = L.tileLayer('https://cartocollective.blob.core.windows.net/vieques/v2009/{z}/{x}/{y}.png', {} ).addTo(map).setOpacity(0);
//var map2020 = L.map('m2020', { zoomControl: false, attributionControl: false, }).setView(daCenter, daZoom);
const t2020 = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {} ).addTo(map).setOpacity(0);
// var mapOSM = L.map('osm', { zoomControl: false, attributionControl: false, }).setView(daCenter, daZoom);
const tOSM = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {} ).addTo(map).setOpacity(0)
</script>
<script src="https://unpkg.com/intersection-observer@0.5.1/intersection-observer.js"></script>
<script src="./js/scrollama/docs/scrollama.min.js"></script>
<script>
var scrolly = document.querySelector(".timeline");
// var article = scrolly.querySelector("article");
var step = scrolly.querySelectorAll(".container");
var scroller = scrollama();
var correntTile = tOSM;
function handleStepProgress(response) {
daResponse = response.element.getElementsByTagName("h2")[0].innerHTML
console.log(daResponse);
if (daResponse != "Introduction"){
eval(daResponse).addTo(map).setOpacity(response.progress)
if (daResponse != "t1937" & response.progress < .5){
map.dragging.enable()
map.scrollWheelZoom.enable()}
}
// document.getElementById(daResponse).style.zIndex = 4
// document.getElementById("elTest").innerText = response.element.getElementsByTagName("h2")[0].innerText
console.log(response.progress);
if (daResponse == "Introduction" ) {
map.dragging.disable()
map.scrollWheelZoom.disable()}
// var el = response.element;
// var val = el.getAttributeNS(null,"data-step");
// var rgba = "rgba(" + val + ", " + response.progress + ")";
// console.log(rgba)
// el.style.backgroundColor = rgba;
// el.innerText = response.progress*100 + " %";
}
function resize() {
var min = window.innerHeight * 0.5;
var h = min + Math.random() * window.innerHeight * 0.25;
// Este es un metodo util para mantener el tamaho de las columnas proporcional
for (i = 0; i < step.length; i++) {step[i].style.height = (Math.floor(h) + "px");}
scrolly.style.marginTop = min+"px"
scroller.resize();
console.log(window.innerHeight)
}
function init() {
// 1. setup the scroller with the bare-bones settings
// this will also initialize trigger observations
// 3. bind scrollama event handlers (this can be chained like below)
scroller
.setup({
step: ".timeline .container",
offset: .75,
progress: true,
debug: true
})
.onStepProgress(handleStepProgress);
// setup resize event
resize();
window.addEventListener("resize", resize);
}
// kick things off
init();
</script>
</body>
</html>