From d584eb2f9d0a123c46b272ef10736db585a4f46c Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Sat, 9 Feb 2013 17:56:22 -0500 Subject: [PATCH] Pan, fix initial loads --- js/id/behavior/hash.js | 6 ++---- js/id/id.js | 13 ++++++++----- js/id/ui.js | 16 +++++++++++++++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/js/id/behavior/hash.js b/js/id/behavior/hash.js index ced648e45..62f7e51b2 100644 --- a/js/id/behavior/hash.js +++ b/js/id/behavior/hash.js @@ -66,11 +66,9 @@ iD.behavior.Hash = function(context) { if (location.hash) { var q = iD.util.stringQs(location.hash.substring(1)); - if (q.id) { - willselect(q.id); - } + if (q.id) willselect(q.id); hashchange(); - hash.hadHash = true; + if (q.map) hash.hadHash = true; } } diff --git a/js/id/id.js b/js/id/id.js index 544c66a12..665e0b0a1 100644 --- a/js/id/id.js +++ b/js/id/id.js @@ -92,14 +92,17 @@ window.iD = function () { return context; }; - var q = iD.util.stringQs(location.hash.substring(1)); + var q = iD.util.stringQs(location.hash.substring(1)), detected = false; if (q.layer) { context.background() - .source(_.find(iD.layers, function(l) { - return l.data.sourcetag === q.layer; - })); + .source(_.find(iD.layers, function(l) { + if (l.data.sourcetag === q.layer) { + return (detected = true); + } + })); } - if (!context.background()) { + + if (!detected) { context.background() .source(_.find(iD.layers, function(l) { return l.data.name === 'Bing aerial imagery'; diff --git a/js/id/ui.js b/js/id/ui.js index 359a39dcb..8681c9a50 100644 --- a/js/id/ui.js +++ b/js/id/ui.js @@ -232,12 +232,26 @@ iD.ui = function(context) { map.size(m.size()); }); + function pan(d) { + return function() { + map.pan(d); + map.redraw(); + }; + } + + // pan amount + var pa = 5; + var keybinding = d3.keybinding('main') .on('⌘+Z', function() { history.undo(); }) .on('⌃+Z', function() { history.undo(); }) .on('⌘+⇧+Z', function() { history.redo(); }) .on('⌃+⇧+Z', function() { history.redo(); }) - .on('⌫', function() { d3.event.preventDefault(); }); + .on('⌫', function() { d3.event.preventDefault(); }) + .on('←', pan([pa, 0])) + .on('↑', pan([0, pa])) + .on('→', pan([-pa, 0])) + .on('↓', pan([0, -pa])); modes.forEach(function(m) { keybinding.on(m.key, function() { if (map.editable()) context.enter(m); });