From 0bd62985b9465a61728b70e644b963b68286e527 Mon Sep 17 00:00:00 2001 From: orangemug Date: Tue, 10 Apr 2018 12:45:44 +0100 Subject: [PATCH] Revert change to undo/redo --- src/components/App.jsx | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/components/App.jsx b/src/components/App.jsx index f757f1f..c7bf3fd 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -85,28 +85,17 @@ export default class App extends React.Component { this.layerWatcher = new LayerWatcher({ onVectorLayersChange: v => this.setState({ vectorLayers: v }) }) - - this.onKeyDown = this.onKeyDown.bind(this); - } - - onKeyDown(e) { - console.log("??? keyCode ctrlKey="+e.ctrlKey+", keyCode="+e.keyCode) - // Control + Z - if(e.ctrlKey && e.keyCode === 90) { - this.onUndo(e); - } - else if(e.ctrlKey && e.keyCode === 89) { - this.onRedo(e); - } } componentDidMount() { this.fetchSources(); - document.addEventListener("keydown", this.onKeyDown); + Mousetrap.bind(['ctrl+z'], this.onUndo.bind(this)); + Mousetrap.bind(['ctrl+y'], this.onRedo.bind(this)); } componentWillUnmount() { - document.removeEventListener("keydown", this.onKeyDown); + Mousetrap.unbind(['ctrl+z'], this.onUndo.bind(this)); + Mousetrap.unbind(['ctrl+y'], this.onRedo.bind(this)); } saveStyle(snapshotStyle) {