p-lr / MapCompose

A fast, memory efficient Jetpack Compose library to display tiled maps, with support for markers, paths, and rotation.
Apache License 2.0
224 stars 20 forks source link

Zoom fling when double tapping and sliding #77

Closed TimPushkin closed 2 years ago

TimPushkin commented 2 years ago

Currently zoom fling only happens when zooming with two fingers and not when zooming by double tapping and sliding up or down, which feels inconsistent. For example, Google Maps have the fling animation in both cases.

p-lr commented 2 years ago

@TimPushkin Before I publish a new version, I let you test on your side.

TimPushkin commented 2 years ago

Oh, I'm sorry, I missed the notification somehow. Tested it now on the master branch.

For me it behaves strangely half of the times: the fling starts in the right direction, goes like this for a few moments (approximately for the half of the animation duration), but then starts to go in the opposite direction until the animation stops. For example, if I zoom out with a fling, the animation zooms out for a few moments and then zooms back in, sometimes even closer than it was before the gesture.

This doesn't always happen, so, I assume, I just don't perform the gesture perfectly sometimes. But I never experience such behavior when doing the regular pinch zoom with a fling.

p-lr commented 2 years ago

I've seen that, but only when playing around with scrcpy, and never when interacting physically with the device.

TimPushkin commented 2 years ago

I've actually experienced this on a physical smartphone

p-lr commented 2 years ago

I could reproduce on a physical phone but through scrcpy. Not when using fingers. Did you?

TimPushkin commented 2 years ago

Yes, I interacted with the smartphone directly with my fingers

p-lr commented 2 years ago

Strange, I'll try something different.

p-lr commented 2 years ago

I believe I've fixed it. While I'm at it, don't you think that the zoom out is a bit too much? I'm thinking of limiting the fling at bit more.

TimPushkin commented 2 years ago

I don't really get what you are talking about, for me zooming in and out should behave the same. I haven't noticed any other issues with one finger zoom fling.

p-lr commented 2 years ago

Well don't worry about that then. You can try with my last changes on master branch. This is true that fling gesture should be symmetrical. I was actually thinking about another gesture.

TimPushkin commented 2 years ago

Yep, it's fixed now and works really smooth!

As a side note, since we are discussing zoom fling. It doesn't really belong to this issue, but I don't want to create a separate one as I'm not sure if it can (or should) be fixed. When I'm zooming with two fingers with the fling enabled the map frequently gets scrolled during fling even when only zooming is intended, for me this doesn't feel smooth enough, Google Maps seem to perform smoother, for example. I assume, this happens because I'm not taking my fingers off the screen at the same moment, but it's not easy to do perfectly. Maybe it would be better if MapCompose was less sensitive to scroll gestures that happen right after zooming ends.

p-lr commented 2 years ago

I believe I miss interpretated your last comment. Do you mean that during a fling you can see the map being scrolled? This shouldn't happen. If so, can you make sure you're not near the edge of the map. Because during a zoom fling the scroll should remain within the bounds and the map may get scrolled.

TimPushkin commented 2 years ago

I see, yes, this happens because map's edges are reached when I zoom out. Nothing should be done about it then.

p-lr commented 2 years ago

However, it seems you mention two different issues:

TimPushkin commented 2 years ago

Originally I only thought about the first issue you mentioned and tried to explain it with the delay in finger releasing. Maybe I experienced what you describe in the second issue (scroll is triggered when zoom with a fling was intended), but I cannot reproduce it now, so for me it works fine at the moment.

p-lr commented 2 years ago

I've pushed the change for the tolerance of finger release. You can test it, although it's not easy to execute the right gesture that fits into the tolerance. Anyway, as a user, you should feel that it's easy to do a zoom fling.

TimPushkin commented 2 years ago

Played around with the current zoom fling implementation, haven't noticed much difference, but overall it feels smooth enough for me

p-lr commented 2 years ago

Great, I'll make a version soon.