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

Fix M_PI_2 migration which was breaking transitions #441

Merged
merged 2 commits into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ All notable changes to this project will be documented in this file.
[#394](https://github.com/IBAnimatable/IBAnimatable/issues/394) by [@mmadjer](https://github.com/mmadjer)
- Frame is converted to window coordinate space to fix miscalculations in computed values (used with `slideOut`, ...) [#412](https://github.com/IBAnimatable/IBAnimatable/issues/412) by [@redent](https://github.com/redent)
- Reset destination view's `transform` property to `CGAffineTransform.identity` after a slide transition completes. [#432](https://github.com/IBAnimatable/IBAnimatable/pull/432) by [@broadwaylamb](https://github.com/broadwaylamb)
- Fixed `{Flip,Turn,Fold}Animator` which was resulting in broken transitions. Thanks to[@phimage](https://github.com/phimage) for the fix. [#441](https://github.com/IBAnimatable/IBAnimatable/pull/437) by [@tbaranes](https://github.com/tbaranes)

---
### [3.1.3](https://github.com/IBAnimatable/IBAnimatable/releases/tag/3.1.3)
Expand Down
4 changes: 2 additions & 2 deletions IBAnimatable/FlipAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private extension FlipAnimator {
axesValues = valuesForAxe(initialValue: reverse ? 1.0 : 0.0, reverseValue: 0.5)
updateAnchorPointAndOffset(anchorPoint: CGPoint(x: axesValues.0, y: axesValues.1), view: flippedSectionOfToView)

flippedSectionOfToView.layer.transform = rotate(angle: reverse ? .pi * 2 : -.pi * 2)
flippedSectionOfToView.layer.transform = rotate(angle: (reverse ? .pi : -.pi) / 2)
return ((flippedSectionOfFromView, flippedSectionOfFromViewShadow), (flippedSectionOfToView, flippedSectionOfToViewShadow))
}

Expand Down Expand Up @@ -173,7 +173,7 @@ private extension FlipAnimator {
completion: @escaping AnimatableCompletion) {
UIView.animateKeyframes(withDuration: transitionDuration, delay: 0, options: .layoutSubviews, animations: {
UIView.addKeyframe(withRelativeStartTime: 0.0, relativeDuration: 0.5, animations: {
flippedSectionOfFromView.0.layer.transform = self.rotate(angle: self.reverse ? -.pi * 2 : .pi * 2)
flippedSectionOfFromView.0.layer.transform = self.rotate(angle: (self.reverse ? -.pi : .pi) / 2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the self here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we do but #446 removes all of them where not necessary. I could've missed some but I think I got them all 😛

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SD10 thanks for taking care of self.

flippedSectionOfFromView.1.alpha = 1.0
})

Expand Down
8 changes: 4 additions & 4 deletions IBAnimatable/FoldAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ private extension FoldAnimator {
axesValues = valuesForAxe(initialValue: self.reverse ? width : 0.0, reverseValue: height / 2)
leftToViewFold.layer.position = CGPoint(x: axesValues.0, y: axesValues.1)
axesValues = valuesForAxe(initialValue: 0.0, reverseValue: 1.0)
leftToViewFold.layer.transform = CATransform3DMakeRotation(.pi * 2, axesValues.0, axesValues.1, 0.0)
leftToViewFold.layer.transform = CATransform3DMakeRotation(.pi / 2, axesValues.0, axesValues.1, 0.0)
toViewFolds.append(leftToViewFold)

let rightToViewFold = makeSnapshot(from: toView, afterUpdates: true, offset: offset + foldSize, left: false)
axesValues = valuesForAxe(initialValue: self.reverse ? width : 0.0, reverseValue: height / 2)
rightToViewFold.layer.position = CGPoint(x: axesValues.0, y: axesValues.1)
axesValues = valuesForAxe(initialValue: 0.0, reverseValue: 1.0)
rightToViewFold.layer.transform = CATransform3DMakeRotation(-.pi * 2, axesValues.0, axesValues.1, 0.0)
rightToViewFold.layer.transform = CATransform3DMakeRotation(-.pi / 2, axesValues.0, axesValues.1, 0.0)
toViewFolds.append(rightToViewFold)
}
return [toViewFolds, fromViewFolds]
Expand Down Expand Up @@ -185,14 +185,14 @@ private extension FoldAnimator {
var axesValues = self.valuesForAxe(initialValue: self.reverse ? 0.0 : self.width, reverseValue: self.height / 2)
leftFromView.layer.position = CGPoint(x: axesValues.0, y: axesValues.1)
axesValues = self.valuesForAxe(initialValue: 0.0, reverseValue: 1.0)
leftFromView.layer.transform = CATransform3DRotate(self.transform, .pi * 2, axesValues.0, axesValues.1, 0)
leftFromView.layer.transform = CATransform3DRotate(self.transform, .pi / 2, axesValues.0, axesValues.1, 0)
leftFromView.subviews[1].alpha = 1.0

let rightFromView = fromViewFolds[i * 2 + 1]
axesValues = self.valuesForAxe(initialValue: self.reverse ? 0.0 : self.width, reverseValue: self.height / 2)
rightFromView.layer.position = CGPoint(x: axesValues.0, y: axesValues.1)
axesValues = self.valuesForAxe(initialValue: 0.0, reverseValue: 1.0)
rightFromView.layer.transform = CATransform3DRotate(self.transform, -.pi * 2, axesValues.0, axesValues.1, 0)
rightFromView.layer.transform = CATransform3DRotate(self.transform, -.pi / 2, axesValues.0, axesValues.1, 0)
rightFromView.subviews[1].alpha = 1.0

let leftToView = toViewFolds[i * 2]
Expand Down
4 changes: 2 additions & 2 deletions IBAnimatable/TurnAnimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ extension TurnAnimator: UIViewControllerAnimatedTransitioning {

private func animateTurnTransition(fromView: UIView, toView: UIView, completion: @escaping AnimatableCompletion) {
let factor = reverse ? 1.0 : -1.0
toView.layer.transform = rotate(angle: factor * -.pi * 2)
toView.layer.transform = rotate(angle: factor * -.pi / 2)
UIView.animateKeyframes(withDuration: transitionDuration, delay: 0.0, options: .layoutSubviews, animations: {
UIView.addKeyframe(withRelativeStartTime: 0.0, relativeDuration: 0.5) {
fromView.layer.transform = self.rotate(angle: factor * .pi * 2)
fromView.layer.transform = self.rotate(angle: factor * .pi / 2)
}

UIView.addKeyframe(withRelativeStartTime: 0.5, relativeDuration: 0.5) {
Expand Down