Skip to content

Commit

Permalink
Fixed issue with the spring animation views direction
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyndee Lazarte committed Mar 2, 2017
1 parent 56ecc29 commit 37df305
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions Sources/iOS/SpringAnimation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,6 @@ extension SpringAnimation {
- 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)?) {
guard let first = views.first else {
return
}

let h = baseSize.height

for i in 0..<views.count {
let v = views[i]
Expand All @@ -301,9 +296,9 @@ extension SpringAnimation {
usingSpringWithDamping: usingSpringWithDamping,
initialSpringVelocity: initialSpringVelocity,
options: options,
animations: { [s = self, first = first, v = v] in
animations: { [s = interimSpace, m = CGFloat(i + 1), v = v] in
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)
}) { [weak self, v = v] _ in
Expand All @@ -327,8 +322,6 @@ extension SpringAnimation {
return
}

let h = baseSize.height

for i in 0..<views.count {
let v = views[i]

Expand All @@ -339,7 +332,7 @@ extension SpringAnimation {
options: options,
animations: { [first = first, v = v] in
v.alpha = 0
v.y = first.y + h
v.y = first.y

animations?(v)
}) { [weak self, v = v] _ in
Expand All @@ -359,9 +352,6 @@ extension SpringAnimation {
- 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)?) {
guard let first = views.first else {
return
}

for i in 0..<views.count {
let v = views[i]
Expand All @@ -372,9 +362,9 @@ extension SpringAnimation {
usingSpringWithDamping: usingSpringWithDamping,
initialSpringVelocity: initialSpringVelocity,
options: options,
animations: { [s = self, first = first, v = v] in
animations: { [s = interimSpace, m = CGFloat(i + 1), v = v] in
v.alpha = 1
v.x = first.x - CGFloat(i) * s.itemSize.width - CGFloat(i) * s.interimSpace
v.x = -m * (v.width + s)

animations?(v)
}) { [weak self, v = v] _ in
Expand Down Expand Up @@ -428,11 +418,6 @@ extension SpringAnimation {
- 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)?) {
guard let first = views.first else {
return
}

let h = baseSize.height

for i in 0..<views.count {
let v = views[i]
Expand All @@ -443,9 +428,9 @@ extension SpringAnimation {
usingSpringWithDamping: usingSpringWithDamping,
initialSpringVelocity: initialSpringVelocity,
options: options,
animations: { [s = self, first = first, v = v] in
animations: { [s = interimSpace, m = CGFloat(i + 1), v = v] in
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)
}) { [weak self, v = v] _ in
Expand Down

0 comments on commit 37df305

Please sign in to comment.