diff --git a/src/js/controller/DrawingController.js b/src/js/controller/DrawingController.js index 8f758164..16ba5e0d 100644 --- a/src/js/controller/DrawingController.js +++ b/src/js/controller/DrawingController.js @@ -64,6 +64,10 @@ pskl.app.shortcutService.registerShortcut(shortcuts.MISC.RESET_ZOOM, this.resetZoom_.bind(this)); pskl.app.shortcutService.registerShortcut(shortcuts.MISC.INCREASE_ZOOM, this.updateZoom_.bind(this, 1)); pskl.app.shortcutService.registerShortcut(shortcuts.MISC.DECREASE_ZOOM, this.updateZoom_.bind(this, -1)); + pskl.app.shortcutService.registerShortcut(shortcuts.MISC.OFFSET_UP, this.updateOffset_.bind(this, 'up')); + pskl.app.shortcutService.registerShortcut(shortcuts.MISC.OFFSET_RIGHT, this.updateOffset_.bind(this, 'right')); + pskl.app.shortcutService.registerShortcut(shortcuts.MISC.OFFSET_DOWN, this.updateOffset_.bind(this, 'down')); + pskl.app.shortcutService.registerShortcut(shortcuts.MISC.OFFSET_LEFT, this.updateOffset_.bind(this, 'left')); window.setTimeout(function () { this.afterWindowResize_(); @@ -262,6 +266,29 @@ this.updateZoom_(modifier, coords); }; + /** + * Update the current viewport offset of 1 pixel in the provided direction. + * Direction can be one of 'up', 'right', 'down', 'left'. + * Callback for the OFFSET_${DIR} shortcuts. + */ + ns.DrawingController.prototype.updateOffset_ = function (direction) { + var off = this.getOffset(); + if (direction === 'up') { + off.y -= 1; + } else if (direction === 'right') { + off.x += 1; + } else if (direction === 'down') { + off.y += 1; + } else if (direction === 'left') { + off.x -= 1; + } + + this.setOffset( + off.x, + off.y + ); + }; + /** * Update the current zoom level by a given multiplier. * diff --git a/src/js/service/keyboard/Shortcuts.js b/src/js/service/keyboard/Shortcuts.js index 0b614805..0a27bca4 100644 --- a/src/js/service/keyboard/Shortcuts.js +++ b/src/js/service/keyboard/Shortcuts.js @@ -61,7 +61,11 @@ ONION_SKIN : createShortcut('onion-skin', 'Toggle onion skin', 'alt+O'), LAYER_PREVIEW : createShortcut('layer-preview', 'Toggle layer preview', 'alt+L'), MERGE_ANIMATION : createShortcut('import-animation', 'Open merge animation popup', 'ctrl+shift+M'), - CLOSE_POPUP : createShortcut('close-popup', 'Close an opened popup', 'ESC') + CLOSE_POPUP : createShortcut('close-popup', 'Close an opened popup', 'ESC'), + OFFSET_UP : createShortcut('move-up', 'Move viewport up', 'shift+up'), + OFFSET_RIGHT : createShortcut('move-right', 'Move viewport right', 'shift+right'), + OFFSET_DOWN : createShortcut('move-down', 'Move viewport down', 'shift+down'), + OFFSET_LEFT : createShortcut('move-left', 'Move viewport left', 'shift+left'), }, STORAGE : {