mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-18 22:48:10 +02:00
use iD.ui.cmd for fast pan and zoom shortcuts
This commit is contained in:
+9
-4
@@ -163,6 +163,7 @@ iD.ui = function(context) {
|
||||
|
||||
function pan(d) {
|
||||
return function() {
|
||||
d3.event.preventDefault();
|
||||
context.pan(d);
|
||||
};
|
||||
}
|
||||
@@ -176,10 +177,14 @@ iD.ui = function(context) {
|
||||
.on('↑', pan([0, pa]))
|
||||
.on('→', pan([-pa, 0]))
|
||||
.on('↓', pan([0, -pa]))
|
||||
.on('shift+←', pan([mapDimensions[0], 0]))
|
||||
.on('shift+↑', pan([0, mapDimensions[1]]))
|
||||
.on('shift+→', pan([-mapDimensions[0], 0]))
|
||||
.on('shift+↓', pan([0, -mapDimensions[1]]));
|
||||
.on('⇧←', pan([mapDimensions[0], 0]))
|
||||
.on('⇧↑', pan([0, mapDimensions[1]]))
|
||||
.on('⇧→', pan([-mapDimensions[0], 0]))
|
||||
.on('⇧↓', pan([0, -mapDimensions[1]]))
|
||||
.on(iD.ui.cmd('⌘←'), pan([mapDimensions[0], 0]))
|
||||
.on(iD.ui.cmd('⌘↑'), pan([0, mapDimensions[1]]))
|
||||
.on(iD.ui.cmd('⌘→'), pan([-mapDimensions[0], 0]))
|
||||
.on(iD.ui.cmd('⌘↓'), pan([0, -mapDimensions[1]]));
|
||||
|
||||
d3.select(document)
|
||||
.call(keybinding);
|
||||
|
||||
+29
-9
@@ -11,6 +11,27 @@ iD.ui.Zoom = function(context) {
|
||||
key: '-'
|
||||
}];
|
||||
|
||||
function zoomIn() {
|
||||
d3.event.preventDefault();
|
||||
context.zoomIn();
|
||||
}
|
||||
|
||||
function zoomOut() {
|
||||
d3.event.preventDefault();
|
||||
context.zoomOut();
|
||||
}
|
||||
|
||||
function zoomInFurther() {
|
||||
d3.event.preventDefault();
|
||||
context.zoomInFurther();
|
||||
}
|
||||
|
||||
function zoomOutFurther() {
|
||||
d3.event.preventDefault();
|
||||
context.zoomOutFurther();
|
||||
}
|
||||
|
||||
|
||||
return function(selection) {
|
||||
var button = selection.selectAll('button')
|
||||
.data(zooms)
|
||||
@@ -31,17 +52,16 @@ iD.ui.Zoom = function(context) {
|
||||
var keybinding = d3.keybinding('zoom');
|
||||
|
||||
_.each(['=','ffequals','plus','ffplus'], function(key) {
|
||||
keybinding.on(key, function() { context.zoomIn(); });
|
||||
keybinding.on('⇧' + key, function() { context.zoomIn(); });
|
||||
keybinding.on('ctrl+' + key, function() { context.zoomInFurther(); });
|
||||
keybinding.on('ctrl+⇧' + key, function() { context.zoomInFurther(); });
|
||||
keybinding.on(key, zoomIn);
|
||||
keybinding.on('⇧' + key, zoomIn);
|
||||
keybinding.on(iD.ui.cmd('⌘' + key), zoomInFurther);
|
||||
keybinding.on(iD.ui.cmd('⌘⇧' + key), zoomInFurther);
|
||||
});
|
||||
|
||||
_.each(['-','ffminus','_','dash'], function(key) {
|
||||
keybinding.on(key, function() { context.zoomOut(); });
|
||||
keybinding.on('⇧' + key, function() { context.zoomOut(); });
|
||||
keybinding.on('ctrl+' + key, function() { context.zoomOutFurther(); });
|
||||
keybinding.on('ctrl+⇧' + key, function() { context.zoomOutFurther(); });
|
||||
keybinding.on(key, zoomOut);
|
||||
keybinding.on('⇧' + key, zoomOut);
|
||||
keybinding.on(iD.ui.cmd('⌘' + key), zoomOutFurther);
|
||||
keybinding.on(iD.ui.cmd('⌘⇧' + key), zoomOutFurther);
|
||||
});
|
||||
|
||||
d3.select(document)
|
||||
|
||||
Reference in New Issue
Block a user