From 3f3370ababf8b05e499be5397a329a783d6636ed Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Tue, 11 Jul 2017 10:41:42 -0700 Subject: [PATCH] Fix mousewheel event; closes #2 --- lib/minimap-element.js | 17 +---------------- lib/minimap.js | 7 +++++++ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/lib/minimap-element.js b/lib/minimap-element.js index e3e2662..405f4fc 100644 --- a/lib/minimap-element.js +++ b/lib/minimap-element.js @@ -489,7 +489,7 @@ class MinimapElement { this.subscriptions.add(this.subscribeTo(this, { 'mousewheel': (e) => { if (!this.standAlone) { - this.relayMousewheelEvent(e) + this.minimap.onMouseWheel(e) } } })) @@ -1124,21 +1124,6 @@ class MinimapElement { this.minimap.setTextEditorScrollTop(ratio * this.minimap.getTextEditorMaxScrollTop()) } - /** - * A method that relays the `mousewheel` events received by the MinimapElement - * to the `TextEditorElement`. - * - * @param {MouseEvent} e the mouse event object - * @access private - */ - relayMousewheelEvent (e) { - if (this.minimap.scrollIndependentlyOnMouseWheel()) { - this.minimap.onMouseWheel(e) - } else { - this.getTextEditorElement().component.onMouseWheel(e) - } - } - /** * A method that extracts data from a `MouseEvent` which can then be used to * process clicks and drags of the minimap. diff --git a/lib/minimap.js b/lib/minimap.js index d2d45de..b96e108 100644 --- a/lib/minimap.js +++ b/lib/minimap.js @@ -965,6 +965,13 @@ class Minimap { const updatedScrollTop = previousScrollTop - Math.round(wheelDeltaY * this.scrollSensitivity) event.preventDefault() + + if (this.scrollIndependentlyOnMouseWheel()) { + // Stop the mousewheel from propagating to the editor when + // this config is on + event.stopPropagation() + } + this.setScrollTop(updatedScrollTop) }