Skip to content

Commit

Permalink
애니메이션 여부에 따른 카메라 업데이트 방식 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
sunghyun-k committed Jul 19, 2022
1 parent b66ae91 commit 8232fa6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Sources/NaverMap.swift
Expand Up @@ -47,7 +47,11 @@ public struct NaverMap<MarkerItems>: UIViewRepresentable where MarkerItems: Rand

public func updateUIView(_ mapView: NMFMapView, context: Context) {
updateOptions(mapView)
updateCamera(mapView, isCameraMoving: context.coordinator.isCameraMoving)
updateCamera(
mapView,
isCameraMoving: context.coordinator.isCameraMoving,
animated: context.transaction.animation != nil
)
updateMarker(mapView, coordinator: context.coordinator)
updatePath(mapView, coordinator: context.coordinator)
}
Expand All @@ -57,13 +61,14 @@ public struct NaverMap<MarkerItems>: UIViewRepresentable where MarkerItems: Rand
mapView.isTiltGestureEnabled = isTiltGestureEnabled
}

private func updateCamera(_ mapView: NMFMapView, isCameraMoving: Bool) {
private func updateCamera(_ mapView: NMFMapView, isCameraMoving: Bool, animated: Bool) {
guard mapView.cameraPosition != cameraPosition,
!isCameraMoving
else { return }

let cameraUpdate = NMFCameraUpdate(position: cameraPosition)
cameraUpdate.animation = .easeIn
if animated {
cameraUpdate.animation = .easeIn
}
mapView.moveCamera(cameraUpdate)
}

Expand Down

0 comments on commit 8232fa6

Please sign in to comment.