Skip to content

Commit

Permalink
Fix mousewheel event; closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
mehcode committed Jul 11, 2017
1 parent 0071cba commit 3f3370a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
17 changes: 1 addition & 16 deletions lib/minimap-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ class MinimapElement {
this.subscriptions.add(this.subscribeTo(this, {
'mousewheel': (e) => {
if (!this.standAlone) {
this.relayMousewheelEvent(e)
this.minimap.onMouseWheel(e)
}
}
}))
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions lib/minimap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 3f3370a

Please sign in to comment.