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

Commit

Permalink
Made pan gestures slipperier
Browse files Browse the repository at this point in the history
Replaced the complex formula for overpanning with a simple one that makes the map feel much slipperier than before. `MGLMapView` now overpans just a little more aggressively than `MKMapView` but still a lot less aggressively than Google Maps.

Fixes #1266.
  • Loading branch information
1ec5 committed Apr 17, 2015
1 parent 7827d49 commit 2bc63f7
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions platform/ios/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -677,22 +677,8 @@ - (void)handlePanGesture:(UIPanGestureRecognizer *)pan
else if (pan.state == UIGestureRecognizerStateEnded || pan.state == UIGestureRecognizerStateCancelled)
{
CGPoint velocity = [pan velocityInView:pan.view];
CGFloat duration = 0;

if ( ! CGPointEqualToPoint(velocity, CGPointZero))
{
CGFloat ease = 0.25;

velocity.x = velocity.x * ease;
velocity.y = velocity.y * ease;

CGFloat speed = sqrt(velocity.x * velocity.x + velocity.y * velocity.y);
CGFloat deceleration = 2500;
duration = speed / (deceleration * ease);
}

CGPoint offset = CGPointMake(velocity.x * duration / 2, velocity.y * duration / 2);

CGFloat duration = UIScrollViewDecelerationRateNormal;
CGPoint offset = CGPointMake(velocity.x * duration / 4, velocity.y * duration / 4);
mbglMap->moveBy(offset.x, offset.y, secondsAsDuration(duration));

mbglMap->setGestureInProgress(false);
Expand Down

0 comments on commit 2bc63f7

Please sign in to comment.