This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension DragGesture.Value { | |
var velocity: CGPoint { | |
let decelerationRate = UIScrollView.DecelerationRate.normal.rawValue, | |
d = decelerationRate/(1000.0*(1.0 - decelerationRate)) | |
return CGPoint(x: (location.x - predictedEndLocation.x)/d, | |
y: (location.y - predictedEndLocation.y)/d) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension RawRepresentable { | |
init?(rawValue optionalRawValue: RawValue?) { | |
guard let rawValue = optionalRawValue, value = Self(rawValue: rawValue) else { return nil } | |
self = value | |
} | |
} |