summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-11-05 13:28:17 -0800
committerMinh Nguyễn <mxn@1ec5.org>2015-11-05 13:28:17 -0800
commit99211bc168c1db7302f6b71c603bb1c7b1b1bf0e (patch)
tree258d61383e1486f6bd27c8c4d2cc902d48ef4a91 /platform
parentff801dc2a8297f05cf3b33a08049606f959857c0 (diff)
downloadqtlocation-mapboxgl-99211bc168c1db7302f6b71c603bb1c7b1b1bf0e.tar.gz
[iOS] Defer didChange until after animation
Fixes #2436.
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/MGLMapView.mm57
1 files changed, 52 insertions, 5 deletions
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index 81b8fc886b..4caf043811 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -1650,6 +1650,7 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
- (void)_setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate zoomLevel:(double)zoomLevel direction:(CLLocationDirection)direction animated:(BOOL)animated
{
+ NSTimeInterval duration = animated ? MGLAnimationDuration : 0;
mbgl::CameraOptions options;
options.center = MGLLatLngFromLocationCoordinate2D(centerCoordinate);
options.zoom = fmaxf(zoomLevel, self.currentMinimumZoom);
@@ -1659,14 +1660,25 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
}
if (animated)
{
- options.duration = secondsAsDuration(MGLAnimationDuration);
+ options.duration = secondsAsDuration(duration);
options.easing = MGLUnitBezierForMediaTimingFunction(nil);
}
_mbglMap->easeTo(options);
[self unrotateIfNeededAnimated:animated];
- [self notifyMapChange:(animated ? mbgl::MapChangeRegionDidChangeAnimated : mbgl::MapChangeRegionDidChange)];
+ if (animated)
+ {
+ __weak MGLMapView *weakSelf = self;
+ [self animateWithDelay:duration animations:^
+ {
+ [weakSelf notifyMapChange:mbgl::MapChangeRegionDidChangeAnimated];
+ }];
+ }
+ else
+ {
+ [self notifyMapChange:mbgl::MapChangeRegionDidChange];
+ }
}
+ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingZoomLevel
@@ -1780,7 +1792,18 @@ mbgl::LatLngBounds MGLLatLngBoundsFromCoordinateBounds(MGLCoordinateBounds coord
[self unrotateIfNeededAnimated:duration > 0];
- [self notifyMapChange:(duration > 0 ? mbgl::MapChangeRegionDidChangeAnimated : mbgl::MapChangeRegionDidChange)];
+ if (duration > 0)
+ {
+ __weak MGLMapView *weakSelf = self;
+ [self animateWithDelay:duration animations:^
+ {
+ [weakSelf notifyMapChange:mbgl::MapChangeRegionDidChangeAnimated];
+ }];
+ }
+ else
+ {
+ [self notifyMapChange:mbgl::MapChangeRegionDidChange];
+ }
}
+ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingDirection
@@ -1805,8 +1828,19 @@ mbgl::LatLngBounds MGLLatLngBoundsFromCoordinateBounds(MGLCoordinateBounds coord
CGFloat duration = (animated ? MGLAnimationDuration : 0);
_mbglMap->setBearing(direction, secondsAsDuration(duration));
-
- [self notifyMapChange:(animated ? mbgl::MapChangeRegionDidChangeAnimated : mbgl::MapChangeRegionDidChange)];
+
+ if (animated)
+ {
+ __weak MGLMapView *weakSelf = self;
+ [self animateWithDelay:duration animations:^
+ {
+ [weakSelf notifyMapChange:mbgl::MapChangeRegionDidChangeAnimated];
+ }];
+ }
+ else
+ {
+ [self notifyMapChange:mbgl::MapChangeRegionDidChange];
+ }
}
- (void)setDirection:(CLLocationDirection)direction
@@ -1947,6 +1981,19 @@ mbgl::LatLngBounds MGLLatLngBoundsFromCoordinateBounds(MGLCoordinateBounds coord
options.easing = MGLUnitBezierForMediaTimingFunction(function);
}
_mbglMap->easeTo(options);
+
+ if (duration > 0)
+ {
+ __weak MGLMapView *weakSelf = self;
+ [self animateWithDelay:duration animations:^
+ {
+ [weakSelf notifyMapChange:mbgl::MapChangeRegionDidChangeAnimated];
+ }];
+ }
+ else
+ {
+ [self notifyMapChange:mbgl::MapChangeRegionDidChange];
+ }
}
- (CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(nullable UIView *)view