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 20, 2016
1 parent 139c6bd commit 1ce997c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 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.updateHeight()

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

topConstraint.constant = 0.0
UIView.animateWithDuration(
NSTimeInterval(0.25),
delay: NSTimeInterval(0.0),
options: [.AllowUserInteraction, .CurveEaseOut],
animations: { [weak drop] () -> Void in
if let drop = drop { drop.layoutIfNeeded() }
animations: { _ in
superview.layoutIfNeeded()
}, completion: nil
)
}

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

guard let superview = drop.superview else { return }

UIView.animateWithDuration(
interval,
delay: NSTimeInterval(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,12 +308,15 @@ extension Drop {
} else {
scheduleUpTimer(duration)
topConstraint?.constant = 0.0

guard let superview = superview else { return }

UIView.animateWithDuration(
NSTimeInterval(0.1),
delay: NSTimeInterval(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 1ce997c

Please sign in to comment.