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

Fixed issue with the spring animation views direction #696

Merged
merged 1 commit into from
Mar 2, 2017
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
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