Pan, fix initial loads

This commit is contained in:
Tom MacWright
2013-02-09 17:56:22 -05:00
parent d9b5816530
commit d584eb2f9d
3 changed files with 25 additions and 10 deletions
+2 -4
View File
@@ -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;
}
}
+8 -5
View File
@@ -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';
+15 -1
View File
@@ -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); });