[android] - Add touch velocity effects on scale gesture. Fine tune.
This commit is contained in:
@@ -419,7 +419,7 @@ final class MapGestureDetector {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tiltGestureOccurred) {
|
||||
if (tiltGestureOccurred || scaleGestureOccurred) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -476,9 +476,14 @@ final class MapGestureDetector {
|
||||
@Override
|
||||
public void onScaleEnd(ScaleGestureDetector detector) {
|
||||
double velocityXY = Math.abs(velocityTracker.getYVelocity()) + Math.abs(velocityTracker.getXVelocity());
|
||||
if (velocityXY > MapboxConstants.VELOCITY_THRESHOLD_IGNORE_FLING) {
|
||||
if (velocityXY > MapboxConstants.VELOCITY_THRESHOLD_IGNORE_FLING / 2) {
|
||||
long animationTime = (long)(Math.log(velocityXY) * 66);
|
||||
transform.zoom(wasZoomingIn, new PointF(detector.getFocusX(), detector.getFocusY()), animationTime);
|
||||
double zoomAddition = (float) (Math.log(velocityXY) / 7.7);
|
||||
if (!wasZoomingIn) {
|
||||
zoomAddition = -zoomAddition;
|
||||
}
|
||||
scaleGestureOccurred = true;
|
||||
transform.zoom(zoomAddition, new PointF(detector.getFocusX(), detector.getFocusY()), animationTime);
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -509,7 +514,7 @@ final class MapGestureDetector {
|
||||
// Also ignore small scales
|
||||
long time = detector.getEventTime();
|
||||
long interval = time - scaleBeginTime;
|
||||
if (!scaleGestureOccurred && (interval <= ViewConfiguration.getTapTimeout())) {
|
||||
if (!scaleGestureOccurred && (interval <= ViewConfiguration.getTapTimeout() / 3)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -221,10 +221,10 @@ final class Transform implements MapView.OnMapChangedListener {
|
||||
}
|
||||
}
|
||||
|
||||
void zoom(boolean zoomIn, @NonNull PointF focalPoint,long duration) {
|
||||
void zoom(double zoomAddition, @NonNull PointF focalPoint,long duration) {
|
||||
CameraPosition cameraPosition = invalidateCameraPosition();
|
||||
if (cameraPosition != null) {
|
||||
int newZoom = (int) Math.round(cameraPosition.zoom + (zoomIn ? 1 : -1));
|
||||
int newZoom = (int) Math.round(cameraPosition.zoom + zoomAddition);
|
||||
setZoom(newZoom, focalPoint, duration);
|
||||
} else {
|
||||
// we are not transforming, notify about being idle
|
||||
|
||||
Reference in New Issue
Block a user