From 57438c2a7e2f7da1db386faef846cdbf121928fa Mon Sep 17 00:00:00 2001 From: Felix Wehnert Date: Tue, 12 Feb 2019 02:28:44 +0100 Subject: [ios] Improve tilt gesture performance (#13902) --- platform/ios/CHANGELOG.md | 1 + platform/ios/src/MGLMapView.mm | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index 9b6f9da6e8..6a36e954c5 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -5,6 +5,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT ## 4.9.0 * Fixed a bug where setting `MGLMapView.userTrackingMode` to `MGLUserTrackingModeFollowWithHeading` or `MGLUserTrackingModeFollowWithCourse` would be ignored if the user’s location was not already available. ([#13849](https://github.com/mapbox/mapbox-gl-native/pull/13849)) +* Improved tilt gesture performance. ([#13902](https://github.com/mapbox/mapbox-gl-native/pull/13902)) ## 4.8.0 - January 30, 2019 diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 2c10a606c0..1483d72074 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1968,9 +1968,11 @@ public: [self cancelTransitions]; self.cameraChangeReasonBitmask |= MGLCameraChangeReasonGestureTilt; - + static CGFloat initialPitch; + if (twoFingerDrag.state == UIGestureRecognizerStateBegan) { + initialPitch = self.mbglMap.getPitch(); [self trackGestureEvent:MMEEventGesturePitchStart forRecognizer:twoFingerDrag]; [self notifyGestureDidBegin]; } @@ -1978,10 +1980,9 @@ public: if (twoFingerDrag.state == UIGestureRecognizerStateBegan || twoFingerDrag.state == UIGestureRecognizerStateChanged) { CGFloat gestureDistance = CGPoint([twoFingerDrag translationInView:twoFingerDrag.view]).y; - CGFloat currentPitch = self.mbglMap.getPitch(); - CGFloat slowdown = 20.0; + CGFloat slowdown = 2.0; - CGFloat pitchNew = currentPitch - (gestureDistance / slowdown); + CGFloat pitchNew = initialPitch - (gestureDistance / slowdown); CGPoint centerPoint = [self anchorPointForGesture:twoFingerDrag]; -- cgit v1.2.1