[android] fixed horizontal panning going the opposite direction

This commit is contained in:
Fredrik Karlsson
2016-11-17 13:25:14 +01:00
parent 97288cae96
commit d959fe1522
2 changed files with 8 additions and 12 deletions

View File

@@ -1651,20 +1651,17 @@ public class MapView extends FrameLayout {
resetTrackingModesIfRequired(true, false);
// Fling the map
float ease = 0.25f;
velocityX = velocityX * ease;
velocityY = velocityY * ease;
double speed = Math.sqrt(velocityX * velocityX + velocityY * velocityY);
double deceleration = 2500;
double duration = speed / (deceleration * ease);
double decelerationRate = 1;
// Cancel any animation
cancelTransitions();
nativeMapView.moveBy(velocityX * duration / 2.0 / screenDensity, velocityY * duration / 2.0 / screenDensity, (long) (duration * 1000.0f));
double offsetX = velocityX * decelerationRate / 4 / screenDensity;
double offsetY = velocityY * decelerationRate / 4 / screenDensity;
nativeMapView.setGestureInProgress(true);
nativeMapView.moveBy(offsetX, offsetY, (long) (decelerationRate * 1000.0f));
nativeMapView.setGestureInProgress(false);
MapboxMap.OnFlingListener listener = mapboxMap.getOnFlingListener();
if (listener != null) {