From d9ef7c7b43104d5678d693da4d1043357e99cd5b Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Wed, 12 Sep 2018 23:15:26 -0400 Subject: Update user puck center position immediately if duration is 0. --- platform/ios/src/MGLMapView.mm | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 216464a7d4..da94e46d16 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -5955,12 +5955,8 @@ public: { // Smoothly move the user location annotation view and callout view to // the new location. - [UIView animateWithDuration:duration - delay:0 - options:(UIViewAnimationOptionCurveLinear | - UIViewAnimationOptionAllowUserInteraction | - UIViewAnimationOptionBeginFromCurrentState) - animations:^{ + + dispatch_block_t animation = ^{ if (self.selectedAnnotation == self.userLocation) { UIView *calloutView = self.calloutViewForSelectedAnnotation; @@ -5969,7 +5965,20 @@ public: userPoint.y - annotationView.center.y); } annotationView.center = userPoint; - } completion:NULL]; + }; + + if (duration > 0) { + [UIView animateWithDuration:duration + delay:0 + options:(UIViewAnimationOptionCurveLinear | + UIViewAnimationOptionAllowUserInteraction | + UIViewAnimationOptionBeginFromCurrentState) + animations:animation + completion:NULL]; + } + else { + animation(); + } _userLocationAnimationCompletionDate = [NSDate dateWithTimeIntervalSinceNow:duration]; annotationView.hidden = NO; -- cgit v1.2.1