-
-
Notifications
You must be signed in to change notification settings - Fork 328
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
Improve fling animation #927
Comments
@Helium314 can you share a video of this? |
Two videos using a testing version of StreetComplete for migration from Tangram to MapLibre: In the first video you first see current behavior with Tangram (on the left), which I would like to have in MapLibre. Every move, unless very slow, leads to the map gliding a little bit. ml_acceptable_cut.mp4In the second video is MapLibre's default behavior. You can't see the taps, but basically either the move stops immediately when I take my finger off the screen, or there is this rather big "jump" with sudden acceleration and stop. ml_bad_cut.mp4As far as I understand, the fling ends up calling |
Assuming the UnitBezier in
|
I think it would look best if the camera velocity increased linearly from zero to a maximum value and then decreased linearly to zero again. People sometimes use a quaternion slerp to interpolate the angles. |
Wouldn't this make the fling animation even more awkward? I can't imagine how a fling would look better if the camera started at velocity 0. It's JS and not native, but also in ML JS the fling it not nice (imo actually worse than in native): |
Thanks @Helium314 ! Let me ask around a bit and gather community feedback based on your proposal. One thing that we can do is to keep old behaviour but also allow the behaviour you proposed. Are you willing to contribute with a PR that will enable this ˆˆˆ? |
GL JS gestures have been primarily optimized for non-touch input. I ran into something similar way back in mapbox/mapbox-gl-native#1266. It felt like the map had a lot of “friction” because you had to fling the map very hard to get it to move much. It used mbgl’s default animation curve but with a duration that was determined by an unnecessarily complex formula. The solution on iOS was to replace it with a much more straightforward, 1-second-long animation, matching the behavior of not only MapKit but also every standard UIKit control on the system (scroll views, menus, etc.). Applying this same duration to other gestures for zooming and rotation made the map feel a lot more fluid. The Android map SDK subsequently updated its gesture handling in mapbox/mapbox-gl-native#553, but I don’t know if it followed the iOS implementation precisely. In any case, platform parity is not as important as matching the user’s expectations based on common controls. |
I played quite a bit with different fling parameters.
- double offsetX = velocityX / tiltFactor / screenDensity;
- double offsetY = velocityY / tiltFactor / screenDensity;
+ double offsetX = velocityX * animationTime / 1000 * 0.28
+ double offsetY = velocityY * animationTime / 1000 * 0.28 The factor 1000 is because velocity is per second, animationTime in milliseconds. The factor 0.28 was found purely by testing what looks best, and may also depend on screenDensity and tiltFactor.
- animationOptions.easing.emplace(mbgl::util::UnitBezier {0.25, 0.46, 0.45, 0.94});
+ animationOptions.easing.emplace(mbgl::util::UnitBezier {0.1, 0.4, 0.35, 1.0});
I can try... |
@Helium314 I think the more flexible solution the better. But we can do this step by step maybe? |
@Helium314 Can this be closed now? |
Yes, done now. |
@Helium314 Thank YOU! 🙂 |
The current fling animation feels very awkward, and is different to basically all/most other map engines and online maps.
It appears more like an easeCamera animation than a slowly decelerating continuation of the previous movement. After some testing I think the issue mainly comes from
I tried using a custom move gesture detector (see below) to implement a slightly modified fling gesture. This feels much better than current behavior, but a) still a little awkward (due to the sudden stop) and b) requires re-implementing move and pinch-zoom gestures.
A first and simple step could be allowing to choose the fling velocity threshold and animation base time, but ideally the camera velocity behavior during the movement would be adjusted.
The text was updated successfully, but these errors were encountered: