Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 197 additions and 9 deletions.
  1. +197 −9 index.html
View
206 index.html
@@ -2,6 +2,10 @@
<html>
<head>
<meta charset='UTF-8'/>
+<!--[if lt IE 9]>
+<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+<![endif]-->
+<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>
@@ -12,13 +16,77 @@
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:0px;
- width:100%;
+ width:200%;
+ left:-50%;
+ transition:opacity 250ms;
+ -moz-transition:opacity 250ms;
+ -webkit-transition:opacity 250ms;
}
+
.spot {
width:120px;
height:120px;
@@ -26,22 +94,81 @@
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; }
</style>
</head>
-<body>
+<body class='section-0'>
+
+<div id='pane'><div id='map'></div></div>
-<div id='map'></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&mdash;door, office, and safe&mdash;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 &copy; <a href='http://openstreetmap.org/copyright'>OpenStreetMap Contributors</a><br/>
+ Map design &copy; <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] },
@@ -73,11 +200,72 @@
return el;
});
-var map = mapbox
- // Creates the map with tile and spots layers.
- .map('map', [tiles, spots])
- // Sets the initial map view to 0.1296E, 51.5011N @ Z14.
- .centerzoom({ lon:-0.1296, lat:51.5011 }, 14);
+// 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>

No commit comments for this range

Something went wrong with that request. Please try again.