//
//  WheelAnimationHandler.swift
//  MobileFirstFramework
//
//  Created by Ryan on 10/29/19.
//  Copyright © 2019 Verizon Wireless. All rights reserved.
//

import UIKit

@objcMembers open class WheelAnimationHandler: NSObject {
    
    /// duration : CACurrentMediaTime()
    private var animations = [Double: Double]()
    
    static let shared = WheelAnimationHandler()
    
    open func storeAnimation(_ duration: Double, _ currentTime: CFTimeInterval) {
        guard animations[duration] == nil else {
            return
        }
        animations[duration] = currentTime
    }
    
    open func getAnimationStartAngle(_ duration: Double, _ currentTime: CFTimeInterval) -> Double {
        if let time = animations[duration] {
            return (currentTime - time) / duration * 360 + 90
        }
        return 0.0
    }
    
}
