Skip to content

Commit

Permalink
🐛 Fix minimap dragging stopped at the end of the canvas
Browse files Browse the repository at this point in the history
Fixes #306
  • Loading branch information
abe33 committed Mar 31, 2015
1 parent 814a124 commit d4c02df
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -502,12 +502,12 @@ class MinimapElement extends HTMLElement

document.body.addEventListener('mousemove', mousemoveHandler)
document.body.addEventListener('mouseup', mouseupHandler)
document.body.addEventListener('mouseout', mouseupHandler)
document.body.addEventListener('mouseleave', mouseupHandler)

@dragSubscription = new Disposable =>
document.body.removeEventListener('mousemove', mousemoveHandler)
document.body.removeEventListener('mouseup', mouseupHandler)
document.body.removeEventListener('mouseout', mouseupHandler)
document.body.removeEventListener('mouseleave', mouseupHandler)

# Internal: The method called during the drag gesture.
#
Expand Down

3 comments on commit d4c02df

@ChaoticMind
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have this line at all? It seems more intuitive to not have it (more consistent with scroll bar behaviors in general)

@abe33
Copy link
Contributor Author

@abe33 abe33 commented on d4c02df Apr 9, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChaoticMind There's a good reason, if the mouse leaves the window when pressed and then released outside of it we don't receive the mouseup event, and so the dragging will stay active when the mouse comeback into the window. By stopping the drag gesture when the mouse leaves the body (the window that is) we can prevent this bug from happening.

@ChaoticMind
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abe33 Aha, ok. I tested this [on xfce] and it seems to actually work at first sight. However, after releasing the cursor outside atom a couple of times, some strange things indeed start happening. This is especially obvious with multiple panes (e.g. scrolling one minimap scrolls both) and weirdly enough, selecting text also starts calling endDrag().

So I was thinking if this is a common problem for js apps and after a quick search, I found this post. So I tested the current behavior of minimap when:

  1. dragging the minimap
  2. while having the mouse button still held, alt tab away from atom

Doing this a couple times hits the "strange behavior" I mentioned above on the current version of minimap. Easiest way to check it is to have multiple panes with files open, and trigger the alt-tab behavior mentioned above twice, then drag the second minimap - it will actually scroll both panes.

Maybe there's a clever solution that both solves the current bug with alttabbing and also allows for not triggering the mouseupHandler when the cursor leaves the window?

Please sign in to comment.