Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Optimise fling animation #503

Merged
merged 4 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public class MapboxConstants {
/**
* Animation time of a fling gesture
*/
public static final long ANIMATION_DURATION_FLING_BASE = ANIMATION_DURATION_SHORT;
public static final long ANIMATION_DURATION_FLING_BASE = 500;

/**
* Velocity threshold for a fling gesture
*/
public static final long VELOCITY_THRESHOLD_IGNORE_FLING = 1000;
public static final long VELOCITY_THRESHOLD_IGNORE_FLING = 300;

/**
* Vertical angle threshold for a horizontal disabled fling gesture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
import android.content.res.Resources;
import android.graphics.PointF;
import android.os.Handler;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import android.view.InputDevice;
import android.view.MotionEvent;
import android.view.animation.DecelerateInterpolator;
Expand All @@ -32,6 +28,9 @@
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import static com.mapbox.mapboxsdk.constants.MapboxConstants.MAXIMUM_ANGULAR_VELOCITY;
import static com.mapbox.mapboxsdk.constants.MapboxConstants.MAX_ABSOLUTE_SCALE_VELOCITY_CHANGE;
import static com.mapbox.mapboxsdk.constants.MapboxConstants.QUICK_ZOOM_MAX_ZOOM_CHANGE;
Expand Down Expand Up @@ -415,7 +414,7 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve
}

float screenDensity = uiSettings.getPixelRatio();

screenDensity = screenDensity < 3 ? 3 : screenDensity;
// calculate velocity vector for xy dimensions, independent from screen size
double velocityXY = Math.hypot(velocityX / screenDensity, velocityY / screenDensity);
if (velocityXY < MapboxConstants.VELOCITY_THRESHOLD_IGNORE_FLING) {
Expand Down