Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nishant-karajgikar committed Apr 27, 2021
1 parent c3936e8 commit c7959d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Sources/MapboxMaps/Foundation/BaseMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ open class BaseMapView: UIView {

/// List of animators currently alive
public var cameraAnimators: [CameraAnimator] {
return cameraAnimatorsHashTable.allObjects.compactMap { $0 as? CameraAnimator }
return cameraAnimatorsHashTable.allObjects
}

/// Map of event types to subscribed event handlers
Expand Down
19 changes: 7 additions & 12 deletions Sources/MapboxMaps/Foundation/Camera/BasicCameraAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,27 @@ import CoreLocation
}

/// Internal-facing protocol to represent camera animators
@objc internal protocol CameraAnimatorInterface: AnyObject {
@objc internal protocol CameraAnimatorInterface: CameraAnimator {
func update()

func stopAnimation()

var state: UIViewAnimatingState { get }
}

// MARK: CameraAnimator Class
public class BasicCameraAnimator: NSObject, CameraAnimator, CameraAnimatorInterface {

/// Instance of the property animator that will run animations.
internal private(set) var propertyAnimator: UIViewPropertyAnimator
private let propertyAnimator: UIViewPropertyAnimator

/// Delegate that conforms to `CameraAnimatorDelegate`.
internal private(set) weak var delegate: CameraAnimatorDelegate?

/// The ID of the owner of this `CameraAnimator`.
public private(set) var owner: AnimationOwner
private let owner: AnimationOwner

/// The `CameraView` owned by this animator
private var cameraView: CameraView
private let cameraView: CameraView

/// Represents the animation that this animator is attempting to execute
internal private(set) var animation: ((inout CameraTransition) -> Void)?
private var animation: ((inout CameraTransition) -> Void)?

/// Defines the transition that will occur to the `CameraOptions` of the renderer due to this animator
public private(set) var transition: CameraTransition?
Expand Down Expand Up @@ -79,6 +75,7 @@ public class BasicCameraAnimator: NSObject, CameraAnimator, CameraAnimatorInterf
propertyAnimator.stopAnimation(false)
propertyAnimator.finishAnimation(at: .current)
cameraView.removeFromSuperview()
delayedAnimationTimer?.invalidate()
}

/// Starts the animation if this animator is in `inactive` state. Also used to resume a "paused" animation.
Expand Down Expand Up @@ -116,9 +113,7 @@ public class BasicCameraAnimator: NSObject, CameraAnimator, CameraAnimatorInterf
/// - Parameter delay: Delay (in seconds) after which the animation should start
public func startAnimation(afterDelay delay: TimeInterval) {
delayedAnimationTimer = Timer.scheduledTimer(withTimeInterval: delay, repeats: false, block: { [weak self] (timer) in
guard let self = self else { return }
self.startAnimation()
timer.invalidate()
self?.startAnimation()
})
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/MapboxMaps/Foundation/Camera/CameraManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ public class CameraManager {
}

// Nil out the `internalAnimator` once the "ease to" finishes
animator.addCompletion { [weak self] (_) in
animator.addCompletion { [weak self] (position) in
self?.internalAnimator = nil
animator.addCompletion(completion)
completion?(position)
}

animator.startAnimation()
Expand Down

0 comments on commit c7959d1

Please sign in to comment.