Last active
July 9, 2018 13:13
-
-
Save jenox/1a64f711f66f6b0507115ef8a8cf49f6 to your computer and use it in GitHub Desktop.
Projection assuming an exponentially decreasing 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 UIGestureRecognizer { | |
public static func project(_ velocity: CGFloat, onto position: CGFloat, decelerationRate: UIScrollView.DecelerationRate = .normal) -> CGFloat { | |
let factor = -1 / (1000 * log(decelerationRate.rawValue)) | |
return position + factor * velocity | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment