Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Scrollwheel zoom into point #12

Closed
MattyBalaam opened this issue Aug 22, 2018 · 12 comments
Closed

Feature Request: Scrollwheel zoom into point #12

MattyBalaam opened this issue Aug 22, 2018 · 12 comments

Comments

@MattyBalaam
Copy link
Contributor

As a user when I have my mouse cursor over a point on an image I would expect it to zoom into that point as the origin.

@ValentinH
Copy link
Owner

You are right, this would be nice. In the same idea, when zooming on mobile with 2 fingers, we should also use the center of the 2 points as the zoom origin.

This is more complex to compute but it's still doable. Would you like to implement this?

@MattyBalaam
Copy link
Contributor Author

I started to take a crack earlier, but it may take a while for me to find the time to implement it well.

@ValentinH
Copy link
Owner

I'll try to look into this when I have a bit of time 🙂

@ValentinH
Copy link
Owner

@MattyBalaam Here's a first try, could you tell me if it matches what you meant? (only wheel is handled in this demo):
https://codesandbox.io/s/mj61vp82xp

@ValentinH ValentinH mentioned this issue Aug 22, 2018
2 tasks
@MattyBalaam
Copy link
Contributor Author

MattyBalaam commented Aug 23, 2018

I gave the PR a try and it works great on my mousewheel. Very nice work.

@ValentinH
Copy link
Owner

OK, I'll need to clean the code a bit and at least ensure that the zoom with pinch is still working. I could add the same feature for pinch later. 🙂

@ValentinH
Copy link
Owner

Actually, I just noticed that my PR works well if you didn't move the image before. If you moved it, then it's not working perfectly. I guess the crop position should be taken in to account as well.

@MattyBalaam
Copy link
Contributor Author

Ah, yes. you shouldn’t rely on me as a tester that’s for sure.

@ValentinH
Copy link
Owner

No I think it's ready: https://codesandbox.io/s/mj61vp82xp.

It also handles mobile zoom too. :)

@MattyBalaam
Copy link
Contributor Author

Just tried it on desktop and on my Android phone and it works brilliantly. Brilliant job.

@ValentinH
Copy link
Owner

Ok I'll release this later today once I'm on the computer :)

ValentinH added a commit that referenced this issue Aug 27, 2018
Close #12

Todo:
- [x] handle wheel
- [x] handle pinch
@ValentinH
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants