From 7ae1b04bbd458c65c7c4d09152c90464ef2fd5bc Mon Sep 17 00:00:00 2001 From: Jeff Verkoeyen Date: Thu, 18 May 2017 14:03:40 -0400 Subject: [PATCH] Move fallback calculations to later in the transition lifecycle. Summary: This ensures that fallback calculations have access to the containerView property. Reviewers: O2 Material Motion, O4 Material Apple platform reviewers, #material_motion, markwei Reviewed By: O2 Material Motion, O4 Material Apple platform reviewers, #material_motion, markwei Tags: #material_motion Differential Revision: http://codereview.cc/D3239 --- src/transitions/TransitionContext.swift | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/transitions/TransitionContext.swift b/src/transitions/TransitionContext.swift index 37cd120..e076d8a 100644 --- a/src/transitions/TransitionContext.swift +++ b/src/transitions/TransitionContext.swift @@ -111,14 +111,6 @@ public final class TransitionContext: NSObject { self.transition = transition super.init() - - while let fallbackTransition = self.transition as? TransitionWithFallback { - let fallback = fallbackTransition.fallbackTansition(withContext: self) - if fallback === self.transition { - break - } - self.transition = fallback - } } fileprivate let initialDirection: TransitionDirection @@ -182,6 +174,16 @@ extension TransitionContext { self.runtime = MotionRuntime(containerView: containerView()) self.replicator.containerView = containerView() + // We query the fallback just before initiating the transition so that the transition context is + // primed with the content view and other transition-related information. + while let fallbackTransition = self.transition as? TransitionWithFallback { + let fallback = fallbackTransition.fallbackTansition(withContext: self) + if fallback === self.transition { + break + } + self.transition = fallback + } + pokeSystemAnimations() var terminators = transition.willBeginTransition(withContext: self, runtime: self.runtime)