-
Notifications
You must be signed in to change notification settings - Fork 118
Conversation
Smaller VELOCITY_THRESHOLD_IGNORE_FLING allows small fling, which makes map pan appear smoother. Longer ANIMATION_DURATION_FLING_BASE makes small fling appear smoother.
@@ -426,8 +426,8 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve | |||
// tilt results in a bigger translation, limiting input for #5281 | |||
double tilt = transform.getTilt(); | |||
double tiltFactor = 1.5 + ((tilt != 0) ? (tilt / 10) : 0); | |||
double offsetX = velocityX / tiltFactor / screenDensity; | |||
double offsetY = velocityY / tiltFactor / screenDensity; | |||
double offsetX = velocityX / tiltFactor / 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, why actually 3? 🤔
Will it work OK on non low-density devices?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pixel ratio is usual 2 for low-density devices and 3 for others. Use 3 here the fling offset will be shorter on low-density devices. But let's make it more robust in case there are higher density devices.
I am afraid that 671f1cb will cause "slow fling issue on devices with high-density screen" in the future. As mentioned in #340 (comment), offsets will be further adjusted by NativeMapView.moveBy later. So the actual result offset will be "velocityX / tiltFactor / (screenDensity^2)". This will cause issues if the screenDensity increases to a higher value in the future. The number 3 can be considered as a special factor for tuning. Intuitively, setting it to 3 means to make all devices behave the same as how Mapbox behaves on devices with screen density of 3 currently. Setting it to a lower value will make fling faster on all devices. Setting it to a higher value will make fling slower on all devices. |
@ystsoi Thanks for your reminder. Can you try it by setting |
@Chaoba Do you mean setting a high value of mapbox:mapbox_pixelRatio, and see whether fling will be slower? I think that I will try to create an emulator of high-density to test first. |
@ystsoi Right. If you set this value, it will overwrite the device density and no need to create an emulator with high-density. |
But I remembered that a smaller mapbox:mapbox_pixelRatio will make all objects smaller, and a larger mapbox:mapbox_pixelRatio will make objects bigger. Although the result should be the same, this may be less convincing. |
I cannot create an emulator with screen density more than 4. For mapbox:mapbox_pixelRatio, as expected, a higher value will make fling slower, using the committed version. But it seems that it does not feel too bad even if fling is slow. But I found two other issues:
|
Test on xiaomi 2 pixel ratio 2
Before:
After: