-
Notifications
You must be signed in to change notification settings - Fork 38
/
step5-responsive.html
308 lines (284 loc) · 11.4 KB
/
step5-responsive.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
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'/>
<!--[if lt IE 9]>
<script src="https://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src='underscore-min.js'></script>
<script src='https://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.css' rel='stylesheet' />
<style>
body {
margin:0px;
padding:0px;
font:normal 15px/20px Arial,sans-serif;
background:#fff;
}
article {
width:33.3333%;
min-width:320px;
position:relative;
padding-top:40px;
padding-bottom:33.3333%;
}
section {
padding:40px;
margin-left:40px;
position:relative;
transition:background 500ms, color 500ms;
-moz-transition:background 500ms, color 500ms;
-webkit-transition:background 500ms, color 500ms;
}
section,
section a {
color:#888;
color:rgba(128,128,128,0);
text-decoration:none;
text-shadow:rgba(64,64,64,1) 0px 0px 4px;
}
section.active {
background:#222;
color:#eee;
}
section.active a { color:#eee; }
section.active small { color:#aaa; }
h1 { font-size:2em; line-height:1em; }
h2 { font-size:1.3333em; }
h1,h2 { margin:0px 0px 10px; }
p { margin:0px; }
.scroll {
position:absolute;
right:0px; bottom:0px;
font-size:10px;
text-transform:uppercase;
padding:5px 10px;
}
.colophon {
display:block;
margin-top:10px;
}
.cover:before {
content:'';
display:block;
width:120px; height:120px;
margin:0px auto 20px;
}
.cover.active:before { background:url(sprite.png) 0px -120px no-repeat; }
#pane {
position:fixed;
top:0px;
bottom:0px;
right:0px;
width:66.6666%;
}
#map {
position:absolute;
top:0px;
bottom:0px;
width:200%;
left:-50%;
transition:opacity 250ms;
-moz-transition:opacity 250ms;
-webkit-transition:opacity 250ms;
}
.spot {
width:120px;
height:120px;
margin:-60px 0px 0px -60px;
background:url(sprite.png) 120px 120px no-repeat;
position:absolute;
}
.spot-cover { display:none; }
.spot-baker { background-position:-130px 0px; }
.spot-baker.active { background-position:-130px -120px; }
.spot-aldgate { background-position:-260px 0px; }
.spot-aldgate.active { background-position:-260px -120px; }
.spot-london-bridge { background-position:-390px 0px; }
.spot-london-bridge.active { background-position:-390px -120px; }
.spot-woolwich { background-position:-520px 0px; }
.spot-woolwich.active { background-position:-520px -120px; }
.spot-gloucester { background-position:-650px 0px; }
.spot-gloucester.active { background-position:-650px -120px; }
.spot-caulfield-gardens { background-position:-780px 0px; }
.spot-caulfield-gardens.active { background-position:-780px -120px; }
.spot-telegraph { background-position:-910px 0px; }
.spot-telegraph.active { background-position:-910px -120px; }
.spot-charing-cross { background-position:-1040px 0px; }
.spot-charing-cross.active { background-position:-1040px -120px; }
/* Distinguish the "cover page" visually other sections. */
body.section-0 #map { opacity:0.5; }
@media (max-width:640px) {
body {
font-size:12px;
line-height:16px;
}
article {
width:100%;
min-width:100%;
padding-top:0px;
padding-bottom:200%;
}
section {
text-shadow:none;
margin-left:0px;
padding:30px;
}
section.active {
position:fixed;
top:0px; left:0px; right:0px;
}
#pane { width:100%; }
#map {
bottom:0%;
left:0%;
width:100%;
height:150%;
}
}
@media (min-width:1280px) {
body {
font-size:18px;
line-height:24px;
}
}
</style>
</head>
<body class='section-0'>
<div id='pane'><div id='map'></div></div>
<article>
<section id='cover' class='cover active'>
<h1>The Adventure of the Bruce-Partington Plans</h1>
<p>by Sir Arthur Conan Doyle</p>
<small class='scroll'>Scroll ▼</small>
</section>
<section id='baker'>
<h2>221b Baker St.</h2>
<p>November 1895. London is shrouded in fog and Sherlock Holmes and Watson pass time restlessly awaiting a new case. "The London criminal is certainly a dull fellow," Sherlock bemoans. "There have been numerous petty thefts," Watson offers in response. Just then a telegram arrives from Sherlock's brother Mycroft with a mysterious case.</p>
</section>
<section id='aldgate'>
<h2>Aldgate Station</h2>
<p>Arthur Cadogan West was found dead, head crushed in on train tracks at Aldgate Station at 6AM Tuesday morning. West worked at Woolwich Arsenal on the Bruce-Partington submarine, a secret military project. Plans for the submarine had been stolen and seven of the ten missing papers were found in West's possession. Mycroft implores Sherlock to take the case and recover the three missing papers.</p>
</section>
<section id='london-bridge'>
<h2>London Bridge</h2>
<p>Holmes and Watson's investigations take them across London. Sherlock deduces that West was murdered elsewhere, then moved to Aldgate Station to create the illusion that he was crushed on the tracks by a train. On their way to Woolwich Sherlock dispatches a telegram to Mycroft at London Bridge: "Send list of all foreign spies known to be in England, with full address."</p>
</section>
<section id='woolwich'>
<h2>Woolwich Arsenal</h2>
<p>While investigating at Woolwich Arsenal Sherlock learns that West did not have the three keys—door, office, and safe—necessary to steal the papers. The train station clerk mentions seeing an agitated West boarding the 8:15 train to London Bridge. Sherlock suspects West of following someone who had access to the Woolwich chief's keyring with all three keys.</p>
</section>
<section id='gloucester'>
<h2>Gloucester Road</h2>
<p>Mycroft responds to Sherlock's telegram and mentions several spies. Hugo Oberstein of 13 Caulfield Gardens catches Sherlock's eye. He heads to the nearby Gloucester Road station to investigate and learns that the windows of Caulfield Gardens open over rail tracks where trains stop frequently.</p>
</section>
<section id='caulfield-gardens'>
<h2>13 Caulfield Gardens</h2>
<p>Holmes deduces that the murderer placed West atop a stopped train at Caulfield Gardens. The train traveled to Aldgate Station before West's body finally toppled off. Backtracking to the criminal's apartment, Holmes finds a series of classified ads from <em>The Daily Telegraph</em> stashed away. All are under the name Pierrot: "Monday night after nine. Two taps. Only ourselves. Do not be so suspicious. Payment in hard cash when goods delivered."</p>
</section>
<section id='telegraph'>
<h2>The Daily Telegraph</h2>
<p>Holmes and Watson head to The Daily Telegraph and place an ad to draw out the criminal. It reads: "To-night. Same hour. Same place. Two taps. Most vitally important. Your own safety at stake. Pierrot." The trap works and Holmes catches the criminal: Colonel Valentine Walter, the brother of Woolwich Arsenal's chief. He confesses to working for Hugo Oberstein to obtain the submarine plans in order to pay off his debts.</p>
</section>
<section id='charing-cross'>
<h2>Charing Cross Hotel</h2>
<p>Walter writes to Oberstein and convinces him to meet in the smoking room of the Charing Cross Hotel where he promises additional plans for the submarine in exchange for money. The plan works and Holmes and Watson catch both criminals.</p>
<small class='colophon'>
Adapted from <a href='http://www.gutenberg.org/files/2346/2346-h/2346-h.htm'>Project Gutenberg</a><br/>
Map data © <a href='http://openstreetmap.org/copyright'>OpenStreetMap Contributors</a><br/>
Map design © <a href='http://mapbox.com/about/maps/'>MapBox</a>
</small>
</section>
</article>
<script>
var geojson = [
{ "geometry": { "type": "Point", "coordinates": [-0.12960000, 51.50110000] },
"properties": { "id": "cover", "zoom": 13 } },
{ "geometry": { "type": "Point", "coordinates": [-0.15591514, 51.51830379] },
"properties": { "id": "baker" } },
{ "geometry": { "type": "Point", "coordinates": [-0.07571203, 51.51424049] },
"properties": { "id": "aldgate" } },
{ "geometry": { "type": "Point", "coordinates": [-0.08533793, 51.50438536] },
"properties": { "id": "london-bridge" } },
{ "geometry": { "type": "Point", "coordinates": [0.05991101, 51.48752939] },
"properties": { "id": "woolwich" } },
{ "geometry": { "type": "Point", "coordinates": [-0.18335806, 51.49439521] },
"properties": { "id": "gloucester" } },
{ "geometry": { "type": "Point", "coordinates": [-0.19684993, 51.5033856] },
"properties": { "id": "caulfield-gardens" } },
{ "geometry": { "type": "Point", "coordinates": [-0.10669358, 51.51433123] },
"properties": { "id": "telegraph" } },
{ "geometry": { "type": "Point", "coordinates": [-0.12416858, 51.50779757] },
"properties": { "id": "charing-cross" } }
];
var tiles = mapbox.layer().tilejson({
tiles: [ "http://a.tiles.mapbox.com/v3/examples.map-liczq28b/{z}/{x}/{y}.png" ]
});
var spots = mapbox.markers.layer()
// Load up markers from geojson data.
.features(geojson)
// Define a new factory function. Takes geojson input and returns a
// DOM element that represents the point.
.factory(function(f) {
var el = document.createElement('div');
el.className = 'spot spot-' + f.properties.id;
return el;
});
// Creates the map with tile and marker layers and
// no input handlers (mouse drag, scrollwheel, etc).
var map = mapbox.map('map', [tiles, spots], null, []);
// Array of story section elements.
var sections = document.getElementsByTagName('section');
// Array of marker elements with order matching section elements.
var markers = _(sections).map(function(section) {
return _(spots.markers()).find(function(m) {
return m.data.properties.id === section.id;
});
});
// Helper to set the active section.
var setActive = function(index, ease) {
// Set active class on sections, markers.
_(sections).each(function(s) { s.className = s.className.replace(' active', '') });
_(markers).each(function(m) { m.element.className = m.element.className.replace(' active', '') });
sections[index].className += ' active';
markers[index].element.className += ' active';
// Set a body class for the active section.
document.body.className = 'section-' + index;
// Ease map to active marker.
if (!ease) {
map.centerzoom(markers[index].location, markers[index].data.properties.zoom||14);
} else {
map.ease.location(markers[index].location).zoom(markers[index].data.properties.zoom||14).optimal(0.5, 1.00);
}
return true;
};
// Bind to scroll events to find the active section.
window.onscroll = _(function() {
// IE 8
if (window.pageYOffset === undefined) {
var y = document.documentElement.scrollTop;
var h = document.documentElement.clientHeight;
} else {
var y = window.pageYOffset;
var h = window.innerHeight;
}
// If scrolled to the very top of the page set the first section active.
if (y === 0) return setActive(0, true);
// Otherwise, conditionally determine the extent to which page must be
// scrolled for each section. The first section that matches the current
// scroll position wins and exits the loop early.
var memo = 0;
var buffer = (h * 0.3333);
var active = _(sections).any(function(el, index) {
memo += el.offsetHeight;
return y < (memo-buffer) ? setActive(index, true) : false;
});
// If no section was set active the user has scrolled past the last section.
// Set the last section active.
if (!active) setActive(sections.length - 1, true);
}).debounce(10);
// Set map to first section.
setActive(0, false);
</script>
</body>
</html>