lehitoskin/ivy

Zoom centered on mouse position

Closed this issue · 6 comments

When zooming in and out, grab the position of the mouse (if it on the canvas) and set the scrollbars to that position.

Should only have to mess with init-auto-scrollbars, but the tricky part might be getting the mouse position and determining whether the mouse is on the canvas. Perhaps 'wheel-up and 'wheel-down pass an additional argument (or set some parameter) so we know for sure the mouse is on the canvas?

+1 to this, big time.

On a mac, I'd actually want to pan around with vert and horizontal mouse wheel (actually a 2-finger drag) and handle zoom with a pinch gesture, but that's something I could hack in later.

Another note: canvas% does have on-event that will trigger when there's mouse activity.

So how accurate is this supposed to be? With the default zoom level and window size, the following image gives difficult-to-predict results. For instance, load image, place pointer on his thumb tip, and zoom in and out. You'll see it's a lot better than it was before; it's centered on the right general vicinity, but it doesn't stay centered on the place you're pointing at.

atheist vader

I see what you mean. I think it's because the image is small enough to still be considered centered for a few clicks of the wheel before the horizontal scrollbar is enabled. That being said, the same behavior is observed while using Eye of MATE --- where it doesn't center the viewable portions of the image on the mouse until the scrollbars are enabled.

Try zooming in so you have both bars, place the pointer on a landmark, and
then zoom in some more. Still isn't quite centered.
On Jun 10, 2016 2:42 PM, "Lehi Toskin" notifications@github.com wrote:

I see what you mean. I think it's because the image is small enough to
still be considered y-axis-centered for a few clicks of the wheel before
the horizontal scrollbar is enabled.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#35 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AHFAlLk27u6xkrKZKyYA0LgF2uGUl7wTks5qKa3AgaJpZM4IkHeR
.

Quite tricky... I've tried a few different things but they just seem to make it less accurate.