Commit 9e63ef52 by Daniel Dahan

minor tweaks before reworking broken view controller animations

parent e5372859
...@@ -276,20 +276,18 @@ public extension MotionController { ...@@ -276,20 +276,18 @@ public extension MotionController {
return return
} }
guard let a = animators else {
return
}
var v: TimeInterval = 0 var v: TimeInterval = 0
for x in a { if let a = animators {
var t = elapsedTime for x in a {
var t = elapsedTime
if t < 0 {
t = -t if t < 0 {
t = -t
}
v = max(v, x.resume(at: t * totalDuration, isReversed: true))
} }
v = max(v, x.resume(at: t * totalDuration, isReversed: true))
} }
complete(after: v, isFinished: false) complete(after: v, isFinished: false)
...@@ -394,24 +392,22 @@ internal extension MotionController { ...@@ -394,24 +392,22 @@ internal extension MotionController {
return return
} }
guard let tp = transitionPairs else { if let tp = transitionPairs {
return for x in tp {
} for v in x.fromViews {
context.hide(view: v)
for x in tp { }
for v in x.fromViews {
context.hide(view: v) for v in x.toViews {
} context.hide(view: v)
}
for v in x.toViews {
context.hide(view: v)
} }
} }
var t: TimeInterval = 0 var t: TimeInterval = 0
var b = false var b = false
if let a = animators { if let a = animators, let tp = transitionPairs {
for (i, x) in a.enumerated() { for (i, x) in a.enumerated() {
let d = x.animate(fromViews: tp[i].0, toViews: tp[i].1) let d = x.animate(fromViews: tp[i].0, toViews: tp[i].1)
...@@ -440,7 +436,7 @@ internal extension MotionController { ...@@ -440,7 +436,7 @@ internal extension MotionController {
*/ */
func complete(after: TimeInterval, isFinished: Bool) { func complete(after: TimeInterval, isFinished: Bool) {
guard isTransitioning else { guard isTransitioning else {
fatalError() return
} }
if after <= 0.001 { if after <= 0.001 {
...@@ -449,9 +445,11 @@ internal extension MotionController { ...@@ -449,9 +445,11 @@ internal extension MotionController {
} }
let v = (isFinished ? elapsedTime : 1 - elapsedTime) * totalDuration let v = (isFinished ? elapsedTime : 1 - elapsedTime) * totalDuration
self.isFinished = isFinished self.isFinished = isFinished
self.currentAnimationDuration = after + v
self.beginTime = CACurrentMediaTime() - v currentAnimationDuration = after + v
beginTime = CACurrentMediaTime() - v
} }
/** /**
...@@ -461,7 +459,6 @@ internal extension MotionController { ...@@ -461,7 +459,6 @@ internal extension MotionController {
*/ */
func complete(isFinished: Bool) { func complete(isFinished: Bool) {
defer { defer {
animators?.forEach { animators?.forEach {
$0.clean() $0.clean()
} }
......
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