Skip to content

Commit

Permalink
Set map animation flag in FollowPuckViewportState (#2165)
Browse files Browse the repository at this point in the history
  • Loading branch information
evil159 authored Jun 5, 2024
1 parent d13b242 commit 594f875
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Mapbox welcomes participation and contributions from everyone.

## main
* Improve stability of symbol placement when using `FollowPuckViewportState`.

## 11.4.0 - 22 May, 2024

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ public final class FollowPuckViewportState {

private let impl: CameraViewportState
private let optionsSubject: CurrentValueSignalSubject<FollowPuckViewportStateOptions>
private let mapboxMap: MapboxMapProtocol

internal init(options: FollowPuckViewportStateOptions,
mapboxMap: MapboxMapProtocol,
onPuckRender: Signal<PuckRenderingData>,
safeAreaPadding: Signal<UIEdgeInsets?>) {
let optionsSubject = CurrentValueSignalSubject(options)
self.optionsSubject = optionsSubject
self.mapboxMap = mapboxMap

let resultCamera = Signal
.combineLatest(optionsSubject.signal.skipRepeats(), onPuckRender.map(\.followPuckState).skipRepeats())
Expand All @@ -48,13 +50,15 @@ extension FollowPuckViewportState: ViewportState {
/// :nodoc:
/// See ``ViewportState/startUpdatingCamera()``.
public func startUpdatingCamera() {
mapboxMap.beginAnimation()
impl.startUpdatingCamera()
}

/// :nodoc:
/// See ``ViewportState/stopUpdatingCamera()``.
public func stopUpdatingCamera() {
impl.stopUpdatingCamera()
mapboxMap.endAnimation()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,12 @@ final class FollowPuckViewportStateTest: XCTestCase {
$onPuckRender.send(puck)
XCTAssertEqual(mapboxMap.setCameraStub.invocations.count, 1)
}

func testAnimationInProgressFlag() throws {
state.startUpdatingCamera()
XCTAssertEqual(mapboxMap.beginAnimationStub.invocations.count, 1)

state.stopUpdatingCamera()
XCTAssertEqual(mapboxMap.endAnimationStub.invocations.count, 1)
}
}

0 comments on commit 594f875

Please sign in to comment.