Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

Commit

Permalink
Fix strange animation
Browse files Browse the repository at this point in the history
  • Loading branch information
morizotter committed Sep 18, 2016
1 parent 5b1ddfc commit 51ec9ea
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions SwiftyDrop/Drop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,29 +167,33 @@ extension Drop {
drop.setup(status, state: state)
drop.action = action
drop.updateHeight()


guard let superview = drop.superview else { return }
superview.layoutIfNeeded()

topConstraint.constant = 0.0
UIView.animate(
withDuration: TimeInterval(0.25),
delay: TimeInterval(0.0),
options: [.allowUserInteraction, .curveEaseOut],
animations: { [weak drop] () -> Void in
if let drop = drop { drop.layoutIfNeeded() }
animations: { _ in
superview.layoutIfNeeded()
}, completion: nil
)
}

fileprivate class func up(_ drop: Drop, interval: TimeInterval) {
guard let heightConstant = drop.heightConstraint?.constant else { return }
drop.topConstraint?.constant = -heightConstant

guard let superview = drop.superview else { return }

UIView.animate(
withDuration: interval,
delay: TimeInterval(0.0),
options: [.allowUserInteraction, .curveEaseIn],
animations: { [weak drop] () -> Void in
if let drop = drop {
drop.layoutIfNeeded()
}
animations: { _ in
superview.layoutIfNeeded()
}) { [weak drop] finished -> Void in
if let drop = drop { drop.removeFromSuperview() }
}
Expand Down Expand Up @@ -304,13 +308,14 @@ extension Drop {
scheduleUpTimer(0.0, interval: 0.1)
} else {
scheduleUpTimer(duration)
guard let superview = superview else { return }
topConstraint.constant = 0.0
UIView.animate(
withDuration: TimeInterval(0.1),
delay: TimeInterval(0.0),
options: [.allowUserInteraction, .curveEaseOut],
animations: { [weak self] () -> Void in
if let s = self { s.layoutIfNeeded() }
animations: { _ in
superview.layoutIfNeeded()
}, completion: nil
)
}
Expand Down

0 comments on commit 51ec9ea

Please sign in to comment.