From 14f552fb5f60543faf930a0e7d2857644cc1b730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20B=C3=B8dskov?= Date: Thu, 19 Sep 2024 15:18:34 +0200 Subject: [PATCH] fix: Xcode 15 has broken the way we calculate the distance (#69) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- Sources/SpringAnimator.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/SpringAnimator.swift b/Sources/SpringAnimator.swift index e31f479..5f34813 100644 --- a/Sources/SpringAnimator.swift +++ b/Sources/SpringAnimator.swift @@ -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)