izuzak / atom-pdf-view

Support for viewing PDF files in Atom.
https://atom.io/packages/pdf-view
MIT License
108 stars 30 forks source link

Autc04 mousepan #82

Closed autc04 closed 9 years ago

autc04 commented 9 years ago

Panning using the mouse and zooming using the mouse wheel.

izuzak commented 9 years ago

This looks good to me! Thanks for opening a new pull request for this :heart:

I did notice one strange thing, though:

pdf

If I start dragging and then the mouse pointer leaves the window area -- the PDF continues scrolling, but in the opposite direction.

I'm wondering if there's a way to make that experience better. Would it be possible and would there be a downside to allowing the dragging functionality provided in this PR even when the mouse pointer leaves the window area, but preventing the automatic scrolling behavior (perhaps by adding a e.preventDefault() to the mousedown event handler as well)? Wondering if you tried something like this and if you have any thoughts. :thought_balloon:

autc04 commented 9 years ago

I've hacked around a bit more and attached the mousemove/mouseup event handlers to $(document) now, giving nicer behaviour when the mouse leaves the pane.

I got stuck at one problem which makes everything worse for now: A preventDefault in the mousedown handler has the unfortunate side effect of also preventing the default behaviour of activating the pane. There's probably some way of triggering that by hand, but I don't know it.

izuzak commented 9 years ago

I've hacked around a bit more and attached the mousemove/mouseup event handlers to $(document) now, giving nicer behaviour when the mouse leaves the pane.

:sparkles: I think that looks much better.

I got stuck at one problem which makes everything worse for now: A preventDefault in the mousedown handler has the unfortunate side effect of also preventing the default behaviour of activating the pane. There's probably some way of triggering that by hand, but I don't know it.

I think atom.workspace.getActivePane()?.activate() might work. See:

https://atom.io/docs/api/v1.1.0-beta.0/Workspace#instance-getActivePane https://atom.io/docs/api/v1.1.0-beta.0/Pane#instance-activate

Does that allow you to trigger the desired behavior?

autc04 commented 9 years ago

Got it. atom.workspace.paneForItem(this).activate() is the magic word.

izuzak commented 9 years ago

atom.workspace.paneForItem(this).activate() is the magic word.

:zap: Yesss. Thanks again for this!