Skip to content

Commit

Permalink
fix: Xcode 15 has broken the way we calculate the distance (#69)
Browse files Browse the repository at this point in the history
this seems to work and leaves us with similar results both in iOS 18 and pre iOS 18 so we'll go with that

Co-authored-by: Peter Bødskov <[email protected]>
  • Loading branch information
pbodsk and Peter Bødskov committed Sep 19, 2024
1 parent 190ec4f commit 14f552f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/SpringAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ class SpringAnimator: NSObject {

private extension SpringAnimator {
@objc func step(displayLink: CADisplayLink) {
// Get duration in a way that supports screens with variable refresh rates
let duration = displayLink.targetTimestamp - CACurrentMediaTime()
// Calculate new potision
// Get duration in a way that supports screens with variable refresh rates
let duration = displayLink.targetTimestamp - displayLink.timestamp
// Calculate new position
position += velocity * CGFloat(duration)
let acceleration = -velocity * damping - position * stiffness
velocity += acceleration * CGFloat(duration)
Expand Down

0 comments on commit 14f552f

Please sign in to comment.