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

Commit

Permalink
Enable fling handling code. #553
Browse files Browse the repository at this point in the history
  • Loading branch information
hollinger committed Nov 18, 2014
1 parent c02ea37 commit 1e8db0b
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions android/java/lib/src/main/java/com/mapbox/mapboxgl/lib/MapView.java
Original file line number Diff line number Diff line change
Expand Up @@ -679,25 +679,23 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,

// Fling the map
// TODO Google Maps also has a rotate and zoom fling
// TODO does not work
/*
* 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);
*
*
* // Cancel any animation mNativeMapView.cancelTransitions();
*
* mNativeMapView.moveBy(velocityX * duration / 2.0 / mScreenDensity, velocityY *
* duration / 2.0 / mScreenDensity, duration);
*
* return true;
*/
return false;

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);

// Cancel any animation
mNativeMapView.cancelTransitions();

mNativeMapView.moveBy(velocityX * duration / 2.0 / mScreenDensity, velocityY *
duration / 2.0 / mScreenDensity, duration);

return true;
}

// Called for drags
Expand Down

1 comment on commit 1e8db0b

@ljbade
Copy link
Contributor

@ljbade ljbade commented on 1e8db0b Nov 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet you got this working again!

Please sign in to comment.