Commit 5ef6d356 by Daniel Dahan Committed by GitHub

Merge pull request #696 from lazarte/master

Fixed issue with the spring animation views direction
parents b8004f05 37df3054
...@@ -286,11 +286,6 @@ extension SpringAnimation { ...@@ -286,11 +286,6 @@ extension SpringAnimation {
- Parameter completion: A completion block to execute on each view's animation. - Parameter completion: A completion block to execute on each view's animation.
*/ */
fileprivate func expandDown(duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions, animations: ((UIView) -> Void)?, completion: ((UIView) -> Void)?) { fileprivate func expandDown(duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions, animations: ((UIView) -> Void)?, completion: ((UIView) -> Void)?) {
guard let first = views.first else {
return
}
let h = baseSize.height
for i in 0..<views.count { for i in 0..<views.count {
let v = views[i] let v = views[i]
...@@ -301,9 +296,9 @@ extension SpringAnimation { ...@@ -301,9 +296,9 @@ extension SpringAnimation {
usingSpringWithDamping: usingSpringWithDamping, usingSpringWithDamping: usingSpringWithDamping,
initialSpringVelocity: initialSpringVelocity, initialSpringVelocity: initialSpringVelocity,
options: options, options: options,
animations: { [s = self, first = first, v = v] in animations: { [s = interimSpace, m = CGFloat(i + 1), v = v] in
v.alpha = 1 v.alpha = 1
v.y = first.y + h + CGFloat(i - 1) * s.itemSize.height + CGFloat(i) * s.interimSpace v.y = m * (v.height + s)
animations?(v) animations?(v)
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
...@@ -327,8 +322,6 @@ extension SpringAnimation { ...@@ -327,8 +322,6 @@ extension SpringAnimation {
return return
} }
let h = baseSize.height
for i in 0..<views.count { for i in 0..<views.count {
let v = views[i] let v = views[i]
...@@ -339,7 +332,7 @@ extension SpringAnimation { ...@@ -339,7 +332,7 @@ extension SpringAnimation {
options: options, options: options,
animations: { [first = first, v = v] in animations: { [first = first, v = v] in
v.alpha = 0 v.alpha = 0
v.y = first.y + h v.y = first.y
animations?(v) animations?(v)
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
...@@ -359,9 +352,6 @@ extension SpringAnimation { ...@@ -359,9 +352,6 @@ extension SpringAnimation {
- Parameter completion: A completion block to execute on each view's animation. - Parameter completion: A completion block to execute on each view's animation.
*/ */
fileprivate func expandLeft(duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions, animations: ((UIView) -> Void)?, completion: ((UIView) -> Void)?) { fileprivate func expandLeft(duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions, animations: ((UIView) -> Void)?, completion: ((UIView) -> Void)?) {
guard let first = views.first else {
return
}
for i in 0..<views.count { for i in 0..<views.count {
let v = views[i] let v = views[i]
...@@ -372,9 +362,9 @@ extension SpringAnimation { ...@@ -372,9 +362,9 @@ extension SpringAnimation {
usingSpringWithDamping: usingSpringWithDamping, usingSpringWithDamping: usingSpringWithDamping,
initialSpringVelocity: initialSpringVelocity, initialSpringVelocity: initialSpringVelocity,
options: options, options: options,
animations: { [s = self, first = first, v = v] in animations: { [s = interimSpace, m = CGFloat(i + 1), v = v] in
v.alpha = 1 v.alpha = 1
v.x = first.x - CGFloat(i) * s.itemSize.width - CGFloat(i) * s.interimSpace v.x = -m * (v.width + s)
animations?(v) animations?(v)
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
...@@ -428,11 +418,6 @@ extension SpringAnimation { ...@@ -428,11 +418,6 @@ extension SpringAnimation {
- Parameter completion: A completion block to execute on each view's animation. - Parameter completion: A completion block to execute on each view's animation.
*/ */
fileprivate func expandRight(duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions, animations: ((UIView) -> Void)?, completion: ((UIView) -> Void)?) { fileprivate func expandRight(duration: TimeInterval, delay: TimeInterval, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: UIViewAnimationOptions, animations: ((UIView) -> Void)?, completion: ((UIView) -> Void)?) {
guard let first = views.first else {
return
}
let h = baseSize.height
for i in 0..<views.count { for i in 0..<views.count {
let v = views[i] let v = views[i]
...@@ -443,9 +428,9 @@ extension SpringAnimation { ...@@ -443,9 +428,9 @@ extension SpringAnimation {
usingSpringWithDamping: usingSpringWithDamping, usingSpringWithDamping: usingSpringWithDamping,
initialSpringVelocity: initialSpringVelocity, initialSpringVelocity: initialSpringVelocity,
options: options, options: options,
animations: { [s = self, first = first, v = v] in animations: { [s = interimSpace, m = CGFloat(i + 1), v = v] in
v.alpha = 1 v.alpha = 1
v.x = first.x + h + CGFloat(i - 1) * s.itemSize.width + CGFloat(i) * s.interimSpace v.x = m * (v.width + s)
animations?(v) animations?(v)
}) { [weak self, v = v] _ in }) { [weak self, v = v] _ in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment