forked from cutting-room-floor/tutorial-sherlock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestIndex2.html
296 lines (270 loc) · 9.99 KB
/
TestIndex2.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
<html>
<head>
<meta charset='UTF-8'/>
<script src='http://underscorejs.org/underscore-min.js'></script>
<script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.js'></script>
<link href='http://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;
left:-50%;
width:200%;
transition:opacity 250ms;
-moz-transition:opacity 250ms;
-webkit-transition:opacity 250ms;
}
.spot {
width:120px;
height:120px;
margin:-60px 0px 0px -60px;
border-radius:50%;
background:url(sprite.png) 120px 120px no-repeat;
position:absolute;
}
.spot-cover { display:none; }
.spot-StationRoadBridgeTrailhead { background-position:-130px 0px; }
.spot-StationRoadBridgeTrailhead.active { background-position:-130px -120px; }
.spot-BostonStore { background-position:-260px 0px; }
.spot-BostonStore.active { background-position:-260px -120px; }
.spot-MustilStore { background-position:-5200px 0px; }
.spot-MustilStore.active { background-position:-520px -120px; }
.spot-DowntownExit { background-position:-650px 0px; }
.spot-DowntownExit.active { background-position:-650px -120px; }
.spot-MainSt { background-position:-780px 0px; }
.spot-MainSt.active { background-position:-780px -120px; }
.spotLock3 { background-position:-910px 0px; }
.spot-Lock3.active { background-position:-910px -120px; }
.spot-TrailMix { background-position:-1040px 0px; }
.spot-TrailMix.active { background-position:-1040px -120px; }
.spot-Railway { background-position:-130px -0px; }
.spot-Railway.active { background-position:-130px -120px; }
.spot-Done { background-position:-260px 0px; }
.spot-Done.active { background-position:-260px -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; }
#pane { width:100%; }
#map { bottom:0%; width:100%; height:150%; left:0%; }
}
@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>Adventure on the Towpath</h1>
<p>just leaving this in</p>
<small>Scroll ▼</small>
</section>
<section id='StationRoadBridgeTrailhead'>
<h2>Station Road Bridge Trailhead</h2>
<p>10499 Riverview Rd., Brecksville, 44141 (about 1/8 mile south of St. Rte. 82)</p>
</section>
<section id='BostonStore'>
<h2>Boston Store Visitor Center</h2>
<p>Museum: The exhibits tell the story of canal-boat building in the valley.</p>
<p>1550 Boston Mills Road, east of Riverview Road, Peninsula 44264</p>
</section>
<section id='MustilStore'>
<h2>Mustil Store</h2>
<p>The Mustill Store and House are the Park's showcase pieces. Located in their original site at Lock 15, these canal-era buildings are believed to have been built in the 1850s, although the exact date is unknown. Three generations of Mustills serviced canal users until the late 1880s. Their story typifies that of many businesses that sprung up along the canal near the locks. Yet, the family's success and social popularity made this a special place to be.</p>
<p>248 Ferndale St, Akron, OH 44304</p>
<p>http://www.cascadelocks.org/store.html</p>
</section>
<section id='DowntownExit'>
<h2>Exit Towpath</h2>
<p>At the Richard Howe House, detour from the Towpath Trail for a quick break in Downtown Akron. </p>
</section>
<section id='MainSt'>
<h2>Main Street Eateries</h2>
<p>Take a breather and grab some a snack and a cold beverage from one of the many eateries on Main St.</p>
</section>
<section id='Lock3'>
<h2>Lock 3 Park</h2>
<p>Grab your snack and lounge on the grass at Lock 3 Park. Once you are rested, hop back onto the Towpath on the Trailhead towards the back of the park.</p>
</section>
<section id='TrailMix'>
<h2>Trail Mix</h2>
<p>Pit stop + Pick up some souviners</p>
</section>
<section id='Railway'>
<h2>Scenic Railway</h2>
<p>Board the Cuyahoga Valley Scenic Railroad at the Peninsula Depot (across from the Winking Lizard). Thanks to Bike Aboard, you can bring your bike!</p>
<p>1630 Mill Street, Peninsula, OH 44264</p>
<p>http://www.cvsr.com/bike-aboard</p>
</section>
<section id='Done'>
<h2>Done!</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 </p>
<p>13512 Station Rd., Brecksville, OH 44141</p>
</section>
</article>
<script>
var geojson = [
{ "geometry": { "type": "Point", "coordinates": [-81.592026, 41.191926] },
"properties": { "id": "cover", "zoom": 11 } },
{ "geometry": { "type": "Point", "coordinates": [-81.586018, 41.319817] },
"properties": { "id": "StationRoadBridgeTrailhead", "zoom": 17 } },
{ "geometry": { "type": "Point", "coordinates": [-81.559281, 41.263074] },
"properties": { "id": "BostonStore", "zoom": 15 } },
{ "geometry": { "type": "Point", "coordinates": [-81.518249, 41.091926] },
"properties": { "id": "MustilStore", "zoom": 15 } },
{ "geometry": { "type": "Point", "coordinates": [-81.523801, 41.077467] },
"properties": { "id": "DowntownExit", "zoom": 18 } },
{ "geometry": { "type": "Point", "coordinates": [-81.522031, 41.076642] },
"properties": { "id": "MainSt", "zoom": 18 } },
{ "geometry": { "type": "Point", "coordinates": [-81.519842, 41.080431] },
"properties": { "id": "Lock3", "zoom": 18 } },
{ "geometry": { "type": "Point", "coordinates": [-81.548660, 41.241691] },
"properties": { "id": "TrailMix", "zoom": 18 } },
{ "geometry": { "type": "Point", "coordinates": [-81.548579, 41.242774] },
"properties": { "id": "Railway", "zoom": 18 } },
{ "geometry": { "type": "Point", "coordinates": [-81.588508, 41.318627] },
"properties": { "id": "Done", "zoom": 18 } },
];
var tiles = mapbox.layer().tilejson({
tiles: [ "http://a.tiles.mapbox.com/v3/codeforamerica.map-ht6lb7bx/{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>