Skip to content

Commit

Permalink
Better explanatory text
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcw committed Apr 17, 2012
1 parent 2a2005e commit dc7cf27
Show file tree
Hide file tree
Showing 3 changed files with 2,642 additions and 7 deletions.
5 changes: 4 additions & 1 deletion braid.html
Expand Up @@ -15,7 +15,10 @@
<body>
<div id='map'></div>
<div id='right'>
<p>browse the map. shift-mousewheel is history.</p>
<p style='padding:10px;'>browse the map. hold down shift and use your mousewheel
or trackpad scroll to move forwards and backwards in time.
inspired by the unusual scrolling behavior of the esri javascript api,
and especially by <a href='http://braid-game.com/'>braid</a>.</p>
</div>
<script src='braid.js' type='text/javascript'></script>
<script type="text/javascript">
Expand Down
15 changes: 12 additions & 3 deletions experimental/braidhandler.js
Expand Up @@ -6,6 +6,7 @@ easey.BraidHandler = function() {
ea = easey(),
prevTime,
history = [],
historyidx = 0,
precise = false;

function toggle(e) {
Expand Down Expand Up @@ -34,12 +35,16 @@ easey.BraidHandler = function() {
map.zoomByAbout(delta > 0 ? 1 : -1, point);
}
}
if (t && history.length && (timeSince > 50)) {
map.coordinate = history.pop();

if (t && (timeSince > 50)) {
if (delta > 0 && historyidx < history.length - 1) {
map.coordinate = history[++historyidx];
} else if (historyidx > 0) {
map.coordinate = history[--historyidx];
}
map.draw();
}

// Cancel the event so that the page doesn't scroll
return MM.cancelEvent(e);
}

Expand All @@ -54,10 +59,14 @@ easey.BraidHandler = function() {
MM.addEvent(document, 'keyup', toggle);

function addhistory(m) {
if (historyidx < history.length - 1) {
history = history.slice(0, historyidx);
}
history.push(m.coordinate.copy());
if (history.length > 10000) {
history.shift();
}
historyidx = history.length - 1;
}

map.addCallback('panned', addhistory);
Expand Down
2,629 changes: 2,626 additions & 3 deletions ext/modestmaps.js

Large diffs are not rendered by default.

0 comments on commit dc7cf27

Please sign in to comment.