lehitoskin / ivy

Ivy, the Taggable Image Viewer
GNU General Public License v3.0
16 stars 3 forks source link

Zoom centered on mouse position #35

Closed lehitoskin closed 8 years ago

lehitoskin commented 8 years ago

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?

IonoclastBrigham commented 8 years ago

+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.

lehitoskin commented 8 years ago

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

IonoclastBrigham commented 8 years ago

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

lehitoskin commented 8 years ago

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.

IonoclastBrigham commented 8 years ago

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 https://github.com/lehitoskin/ivy/issues/35#issuecomment-225260934, or mute the thread https://github.com/notifications/unsubscribe/AHFAlLk27u6xkrKZKyYA0LgF2uGUl7wTks5qKa3AgaJpZM4IkHeR .

lehitoskin commented 8 years ago

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