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

Commit

Permalink
[ios] Delay zoom announcement
Browse files Browse the repository at this point in the history
A 100-millisecond delay is enough for the post-zooming announcement to reflect the new zoom level rather than the previous zoom level.
  • Loading branch information
1ec5 committed Oct 27, 2017
1 parent 10a7f71 commit 8c7956d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ @implementation MGLMapView
NS_ARRAY_OF(id <MGLFeature>) *_visiblePlaceFeatures;
NS_ARRAY_OF(id <MGLFeature>) *_visibleRoadFeatures;
NS_MUTABLE_SET_OF(MGLFeatureAccessibilityElement *) *_featureAccessibilityElements;
BOOL _accessibilityValueAnnouncementIsPending;

MGLReachability *_reachability;
}
Expand Down Expand Up @@ -2819,10 +2820,11 @@ - (void)accessibilityScaleBy:(double)scaleFactor
{
centerPoint = self.userLocationAnnotationViewCenter;
}
_mbglMap->setZoom(_mbglMap->getZoom() + log2(scaleFactor), mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y });
double newZoom = round(self.zoomLevel) + log2(scaleFactor);
_mbglMap->setZoom(newZoom, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y });
[self unrotateIfNeededForGesture];

UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, self.accessibilityValue);
_accessibilityValueAnnouncementIsPending = YES;
}

#pragma mark - Geography -
Expand Down Expand Up @@ -5370,12 +5372,23 @@ - (void)cameraDidChangeAnimated:(BOOL)animated {
_featureAccessibilityElements = nil;
_visiblePlaceFeatures = nil;
_visibleRoadFeatures = nil;
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
if (_accessibilityValueAnnouncementIsPending) {
_accessibilityValueAnnouncementIsPending = NO;
[self performSelector:@selector(announceAccessibilityValue) withObject:nil afterDelay:0.1];
} else {
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
}
}
[self.delegate mapView:self regionDidChangeAnimated:animated];
}
}

- (void)announceAccessibilityValue
{
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, self.accessibilityValue);
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
}

- (void)mapViewWillStartLoadingMap {
if (!_mbglMap) {
return;
Expand Down

0 comments on commit 8c7956d

Please sign in to comment.