Skip to content

Commit 8ba4ce3

Browse files
authored
Merge pull request #75 from SCENEE/fix-animation-wobbling
The default interaction animator should be uninterruptible
2 parents 4db648a + cf60b09 commit 8ba4ce3

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Framework/Sources/FloatingPanel.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class FloatingPanel: NSObject, UIGestureRecognizerDelegate, UIScrollViewDelegate
313313
return
314314
}
315315

316-
if let animator = self.animator {
316+
if let animator = self.animator, animator.isInterruptible {
317317
animator.stopAnimation(true)
318318
self.animator = nil
319319
}
@@ -491,6 +491,7 @@ class FloatingPanel: NSObject, UIGestureRecognizerDelegate, UIScrollViewDelegate
491491
}
492492

493493
private func startAnimation(to targetPosition: FloatingPanelPosition, at distance: CGFloat, with velocity: CGPoint) {
494+
log.debug("startAnimation", targetPosition, distance, velocity)
494495
let targetY = layoutAdapter.positionY(for: targetPosition)
495496
let velocityVector = (distance != 0) ? CGVector(dx: 0, dy: max(min(velocity.y/distance, 30.0), -30.0)) : .zero
496497
let animator = behavior.interactionAnimator(self.viewcontroller, to: targetPosition, with: velocityVector)
@@ -567,7 +568,7 @@ class FloatingPanel: NSObject, UIGestureRecognizerDelegate, UIScrollViewDelegate
567568
}
568569
return currentY > middleY ? .tip : .half
569570
case .half:
570-
return translation.y >= 0 ? .tip : .full
571+
return currentY > middleY ? .tip : .full
571572
case .tip:
572573
if translation.y >= 0 {
573574
return .tip

Framework/Sources/FloatingPanelBehavior.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ public extension FloatingPanelBehavior {
8585
class FloatingPanelDefaultBehavior: FloatingPanelBehavior {
8686
func interactionAnimator(_ fpc: FloatingPanelController, to targetPosition: FloatingPanelPosition, with velocity: CGVector) -> UIViewPropertyAnimator {
8787
let timing = timeingCurve(with: velocity)
88-
return UIViewPropertyAnimator(duration: 0, timingParameters: timing)
88+
let animator = UIViewPropertyAnimator(duration: 0, timingParameters: timing)
89+
animator.isInterruptible = false
90+
return animator
8991
}
9092

9193
private func timeingCurve(with velocity: CGVector) -> UITimingCurveProvider {

0 commit comments

Comments
 (0)