Skip to content

Commit

Permalink
🐛 Fix right click starting a drag gesture
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Feb 2, 2015
1 parent 2ffa507 commit c17a5dc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,15 @@ class MinimapElement extends HTMLElement
for config, callback of configs
@subscriptions.add atom.config.observe config, callback

mousePressedOverCanvas: ({pageY, target}) ->
mousePressedOverCanvas: ({which, pageY, target}) ->
return if which isnt 1

y = pageY - target.getBoundingClientRect().top
row = Math.floor(y / @minimap.getLineHeight()) + @minimap.getFirstVisibleScreenRow()

scrollTop = row * @minimap.textEditor.getLineHeightInPixels() - @minimap.textEditor.getHeight() / 2

@minimap.textEditor.setScrollTop(scrollTop)

relayMousewheelEvent: (e) =>
editorElement = atom.views.getView(@minimap.textEditor)

Expand All @@ -366,7 +367,8 @@ class MinimapElement extends HTMLElement
# ## ## ## ## ## ##
# ######## #### ## ########

startDrag: ({pageY}) ->
startDrag: ({which, pageY}) ->
return if which isnt 1
{top} = @visibleArea.getBoundingClientRect()
{top: offsetTop} = @getBoundingClientRect()

Expand All @@ -387,6 +389,7 @@ class MinimapElement extends HTMLElement
document.body.removeEventListener('mouseout', mouseupHandler)

drag: (e, initial) ->
return if e.which isnt 1
y = e.pageY - initial.offsetTop - initial.dragOffset

ratio = y / (@minimap.getVisibleHeight() - @minimap.getTextEditorScaledHeight())
Expand Down

0 comments on commit c17a5dc

Please sign in to comment.