diff --git a/apps/image-editor/src/js/component/zoom.js b/apps/image-editor/src/js/component/zoom.js index fc91f1dd9..ad611b6f1 100644 --- a/apps/image-editor/src/js/component/zoom.js +++ b/apps/image-editor/src/js/component/zoom.js @@ -129,10 +129,24 @@ class Zoom extends Component { this.graphics.on(ADD_TEXT, this._startTextEditingHandler.bind(this)); this.graphics.on(TEXT_EDITING, this._startTextEditingHandler.bind(this)); this.graphics.on(OBJECT_MODIFIED, this._stopTextEditingHandler.bind(this)); + } + + /** + * Attach zoom keyboard events + */ + attachKeyboardZoomEvents() { fabric.util.addListener(document, KEY_DOWN, this._listeners.keydown); fabric.util.addListener(document, KEY_UP, this._listeners.keyup); } + /** + * Detach zoom keyboard events + */ + detachKeyboardZoomEvents() { + fabric.util.removeListener(document, KEY_DOWN, this._listeners.keydown); + fabric.util.removeListener(document, KEY_UP, this._listeners.keyup); + } + /** * Handler when you started editing text * @private diff --git a/apps/image-editor/src/js/graphics.js b/apps/image-editor/src/js/graphics.js index aee78e953..409f13e8a 100644 --- a/apps/image-editor/src/js/graphics.js +++ b/apps/image-editor/src/js/graphics.js @@ -162,6 +162,7 @@ class Graphics { this._createDrawingModeInstances(); this._createComponents(); this._attachCanvasEvents(); + this._attachZoomEvents(); } /** @@ -173,6 +174,26 @@ class Graphics { this._canvas.clear(); wrapperEl.parentNode.removeChild(wrapperEl); + + this._detachZoomEvents(); + } + + /** + * Attach zoom events + */ + _attachZoomEvents() { + const zoom = this.getComponent(components.ZOOM); + + zoom.attachKeyboardZoomEvents(); + } + + /** + * Detach zoom events + */ + _detachZoomEvents() { + const zoom = this.getComponent(components.ZOOM); + + zoom.detachKeyboardZoomEvents(); } /**