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: adjust the zoom rate to increase with element size #643

Closed
folsze opened this issue Mar 20, 2023 · 9 comments
Closed

Feature: adjust the zoom rate to increase with element size #643

folsze opened this issue Mar 20, 2023 · 9 comments
Labels

Comments

@folsze
Copy link

folsze commented Mar 20, 2023

Hi,

I am not sure whether this is the correct way to do this (I wanted to ask in Discussion Tab but there was none for this github repo).

I am not sure whether this is a bug or just a trait of this library.

What problem does this feature solve?
basically with my svgs the pinch-zooming gets really slow when I get like 50% zoomed in.

Here is a GIF:
ezgif-3-12717332c1

Describe the solution you'd like

Here is a GIF:
ezgif-3-9e091e3756
It's from https://apps.apple.com/us/app/what-is-there/id660164295 and uses React Native

As you can see the zoom is really constantly fast (same speed) on this app, there is no "progressively slowing down more" like @panzoom/panzoom does it

I can provide a minimal reproducible example if this would be helpful. Let me know and I will upload it right away. But I thought I'd wait first since maybe this is just a known trait of this library? I can somewhat see it when testing https://timmywil.com/panzoom/ but not as much as in my video I guess

I just wanted to report this as I did not find any hints on this in the docs. So maybe it could be helpful for other people who have the same problem too.

@folsze folsze added the feature label Mar 20, 2023
@folsze
Copy link
Author

folsze commented Mar 21, 2023

I fixed the problem by using another library:
https://www.npmjs.com/package/panzoom

For anyone wanting to see the differences in how the two libraries behave see here:
https://github.com/folsze/panzoom-bug

I created two ionic pages:
panzoom (from this library)
anvaka-panzoom (another library, see package.json)

@folsze folsze closed this as completed Mar 21, 2023
@folsze
Copy link
Author

folsze commented Mar 21, 2023

@timmywil Feel free to view the difference in the repo. Maybe it would serve as a good comparison for you to make the zoom-speed behave faster in your panzoom as well

EDIT:
actually this other library has a weird thing where you have to do:
https://github.com/anvaka/panzoom#handling-touch-events
for click events. And then when I do that, the pan gets laggy in my application unfortunately.
BUG: anvaka/panzoom#299

THUS:
It would be amazing if we got the same zoom-speed behaviour as the other library since I think yours is otherwise superior in terms of other things.

@folsze folsze reopened this Mar 21, 2023
@timmywil timmywil changed the title Feature(/bug?): Don't slow down zoom speed when zoomed in ~50% Feature: adjust the zoom rate to increase with element size Mar 21, 2023
@timmywil
Copy link
Owner

Thanks for opening an issue. This has been debated a lot and I don't think any library gets it perfect for all cases. That said, I'm open to adjustments.

Before I make another change to zoom rate, though, I'd like to send this through voting.

Also, if you haven't already tried it, play with the step option.

@timmywil timmywil added the votes needed Feature requests are closed at first, but will be implemented with enough upvotes label Mar 21, 2023
@folsze
Copy link
Author

folsze commented Mar 22, 2023

Hey I don't know why I didn't try the 'step' option. It really helps my app.

I set it to 3 and limited the maxScale to 10, such that the user is never able to reach the awkward "slow-zoom" zoomed-in-point.

This is my code:

      minScale: 1,
      maxScale: 10,
      step: 2,

Maybe this could be documented in the library? That if users are experiencing slow zoom like in my repo above, then they could use the trick of upping the step and limting the maxScale to prevent users from ever reaching this weird slow-zoom point? I could make a PR, lmk

@folsze
Copy link
Author

folsze commented Mar 22, 2023

So I think you can close the 'Votes needed' as your library already provides a solution to the mentioned problem :)

beginner library-users like me are just not aware of it

EDIT:
this is somewhat of a workaround. I am still not satisfied with this solution, since now my zoom is awkwardly fast. The step(=the zoom speed) should not be the necessary change to get this working. Whoever wants to achieve this consider using the other famous panzoom library.

However with the other one I am having very weird performance problems on mobile when zooming (after attaching click listeners to paths)

@timmywil timmywil removed the votes needed Feature requests are closed at first, but will be implemented with enough upvotes label Mar 22, 2023
@folsze
Copy link
Author

folsze commented Apr 3, 2023

I don't know if this might pose itself as a solution, but the zoom with the mousewheel is actually not that slow when it gets zoomed in. It's really only the finger zoom that gets so slow when zoomed in.

Just dropping this here for anyone interested.

Is it possible to somehow reuse the mousewheel zoom mechanic for the finger-zoom-mechanic?

@folsze
Copy link
Author

folsze commented Jul 15, 2023

I might try to implement this in a fork this month or so, if it's not too hard. Do you think it would be very hard?

Maybe you could give me some pointers just on where in this repository to start working on this? And what I should look into first? Only if it's not a lot of work for you. Thanks for creating this amazing library
@timmywil

@folsze
Copy link
Author

folsze commented Apr 9, 2024

@timmywil gonna actually do a spike in a fork this April or May still. Do you have any advice or pointers right now already? Would be much appreciated :)

Basically I just wanna have this be the case:
"Feature: adjust the zoom rate to increase with element size"

@otaviogaiao
Copy link

@timmywil gonna actually do a spike in a fork this April or May still. Do you have any advice or pointers right now already? Would be much appreciated :)

Basically I just wanna have this be the case: "Feature: adjust the zoom rate to increase with element size"

Do you have any update on this? I'm facing the same issue right now.

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

No branches or pull requests

3 participants