Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the animation velocity's sign #354

Merged
merged 1 commit into from
May 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Framework/Sources/FloatingPanelCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ class FloatingPanelCore: NSObject, UIGestureRecognizerDelegate {

vc.delegate?.floatingPanelWillBeginDecelerating(vc)

let velocityVector = (distance != 0) ? CGVector(dx: 0, dy: abs(velocity.y)/distance) : .zero
let velocityVector = (distance != 0) ? CGVector(dx: 0, dy: velocity.y / distance) : .zero
let animator = behavior.interactionAnimator(vc, to: targetPosition, with: velocityVector)
animator.addAnimations { [weak self] in
guard let `self` = self, let vc = self.viewcontroller else { return }
Expand Down Expand Up @@ -809,7 +809,7 @@ class FloatingPanelCore: NSObject, UIGestureRecognizerDelegate {
private func distance(to targetPosition: FloatingPanelPosition) -> CGFloat {
let currentY = surfaceView.frame.minY
let targetY = layoutAdapter.positionY(for: targetPosition)
return CGFloat(abs(currentY - targetY))
return CGFloat(targetY - currentY)
}

// Distance travelled after decelerating to zero velocity at a constant rate.
Expand Down