From 2bc63f76a4c3200c61902e7133898d7ba35fedc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Fri, 17 Apr 2015 12:31:49 -0700 Subject: [PATCH] Made pan gestures slipperier 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. --- platform/ios/MGLMapView.mm | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index 5acf04ef7..b73f2647d 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -677,22 +677,8 @@ mbgl::DefaultFileSource *mbglFileSource = nullptr; 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);