Created
February 17, 2021 16:36
-
-
Save okla/9e0bdadbc2decf72c5eef8e83e1cccba to your computer and use it in GitHub Desktop.
SwiftUI DragGesture velocity
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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment