Skip to content

Commit

Permalink
chore(hand-tool): make keyboard optional
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme authored and merge-me[bot] committed Jun 13, 2019
1 parent e7217b9 commit 93e7a3e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
9 changes: 5 additions & 4 deletions lib/features/hand-tool/HandTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ var HIGH_PRIORITY = 1500;
var HAND_CURSOR = 'grab';


export default function HandTool(eventBus, canvas, dragging, keyboard, toolManager) {
export default function HandTool(eventBus, canvas, dragging, injector, toolManager) {
this._dragging = dragging;

var self = this;
var self = this,
keyboard = injector.get('keyboard', false);

toolManager.registerTool('hand', {
tool: 'hand',
Expand All @@ -24,7 +25,7 @@ export default function HandTool(eventBus, canvas, dragging, keyboard, toolManag
}
}, this);

keyboard.addListener(HIGH_PRIORITY, function(e) {
keyboard && keyboard.addListener(HIGH_PRIORITY, function(e) {
if (!isSpace(e.keyEvent)) {
return;
}
Expand Down Expand Up @@ -103,7 +104,7 @@ HandTool.$inject = [
'eventBus',
'canvas',
'dragging',
'keyboard',
'injector',
'toolManager'
];

Expand Down
2 changes: 0 additions & 2 deletions lib/features/hand-tool/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import KeyboardModule from '../keyboard';
import ToolManagerModule from '../tool-manager';

import HandTool from './HandTool';

export default {
__depends__: [
KeyboardModule,
ToolManagerModule
],
__init__: [ 'handTool' ],
Expand Down
9 changes: 8 additions & 1 deletion test/spec/features/hand-tool/HandToolSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { createCanvasEvent as canvasEvent } from '../../../util/MockEvents';

import handToolModule from 'lib/features/hand-tool';
import draggingModule from 'lib/features/dragging';
import keyboardModule from 'lib/features/keyboard';

import { createKeyEvent } from 'test/util/KeyEvents';

Expand All @@ -17,7 +18,13 @@ var spy = sinon.spy;

describe('features/hand-tool', function() {

beforeEach(bootstrapDiagram({ modules: [ handToolModule, draggingModule ] }));
beforeEach(bootstrapDiagram({
modules: [
handToolModule,
draggingModule,
keyboardModule
]
}));

var rootShape, childShape;

Expand Down

0 comments on commit 93e7a3e

Please sign in to comment.