Commit 48064570 by Daniel Dahan

updated to and from references

parent c2ddc79c
...@@ -364,10 +364,14 @@ open class Motion: NSObject { ...@@ -364,10 +364,14 @@ open class Motion: NSObject {
open let transitionBackgroundView = UIView() open let transitionBackgroundView = UIView()
/// A reference to the view controller that is being transitioned to. /// A reference to the view controller that is being transitioned to.
open var toViewController: UIViewController! open var toViewController: UIViewController {
return transitionContext.viewController(forKey: .to)!
}
/// A reference to the view controller that is being transitioned from. /// A reference to the view controller that is being transitioned from.
open var fromViewController: UIViewController! open var fromViewController: UIViewController {
return transitionContext.viewController(forKey: .from)!
}
/// The transition context for the current transition. /// The transition context for the current transition.
open var transitionContext: UIViewControllerContextTransitioning! open var transitionContext: UIViewControllerContextTransitioning!
...@@ -386,7 +390,7 @@ open class Motion: NSObject { ...@@ -386,7 +390,7 @@ open class Motion: NSObject {
/// The view that is being transitioned to. /// The view that is being transitioned to.
open var toView: UIView { open var toView: UIView {
return toViewController.view return transitionContext.view(forKey: .to)!
} }
/// The subviews of the view being transitioned to. /// The subviews of the view being transitioned to.
...@@ -396,7 +400,7 @@ open class Motion: NSObject { ...@@ -396,7 +400,7 @@ open class Motion: NSObject {
/// The view that is being transitioned from. /// The view that is being transitioned from.
open var fromView: UIView { open var fromView: UIView {
return fromViewController.view return transitionContext.view(forKey: .from)!
} }
/// The subviews of the view being transitioned from. /// The subviews of the view being transitioned from.
...@@ -406,7 +410,7 @@ open class Motion: NSObject { ...@@ -406,7 +410,7 @@ open class Motion: NSObject {
/// A time value to delay the transition animation by. /// A time value to delay the transition animation by.
fileprivate var delayTransitionByTimeInterval: TimeInterval { fileprivate var delayTransitionByTimeInterval: TimeInterval {
return fromViewController?.motionDelegate?.motionDelayTransitionByTimeInterval?(motion: self) ?? 0 return fromViewController.motionDelegate?.motionDelayTransitionByTimeInterval?(motion: self) ?? 0
} }
/// The default initializer. /// The default initializer.
...@@ -520,8 +524,6 @@ extension Motion: UIViewControllerAnimatedTransitioning { ...@@ -520,8 +524,6 @@ extension Motion: UIViewControllerAnimatedTransitioning {
@objc(animateTransition:) @objc(animateTransition:)
open func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { open func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
self.transitionContext = transitionContext self.transitionContext = transitionContext
prepareToViewController()
prepareFromViewController()
fromViewController.motionDelegate?.motion?(motion: self, willTransition: fromView, toView: toView) fromViewController.motionDelegate?.motion?(motion: self, willTransition: fromView, toView: toView)
...@@ -552,22 +554,6 @@ extension Motion: UIViewControllerAnimatedTransitioning { ...@@ -552,22 +554,6 @@ extension Motion: UIViewControllerAnimatedTransitioning {
} }
extension Motion { extension Motion {
/// Prepares the toViewController.
fileprivate func prepareToViewController() {
guard let v = transitionContext.viewController(forKey: .to) else {
return
}
toViewController = v
}
/// Prepares the fromViewController.
fileprivate func prepareFromViewController() {
guard let v = transitionContext.viewController(forKey: .from) else {
return
}
fromViewController = v
}
/// Prepares the containerView. /// Prepares the containerView.
fileprivate func prepareContainerView() { fileprivate func prepareContainerView() {
containerView = transitionContext.containerView containerView = transitionContext.containerView
...@@ -587,7 +573,6 @@ extension Motion { ...@@ -587,7 +573,6 @@ extension Motion {
guard to.motionIdentifier == from.motionIdentifier else { guard to.motionIdentifier == from.motionIdentifier else {
continue continue
} }
transitionPairs.append((from, to)) transitionPairs.append((from, to))
} }
} }
......
...@@ -173,7 +173,7 @@ extension CALayer { ...@@ -173,7 +173,7 @@ extension CALayer {
- Parameter animations: An Array of MotionAnimation values. - Parameter animations: An Array of MotionAnimation values.
*/ */
open func motion(_ animations: [MotionAnimation]) { open func motion(_ animations: [MotionAnimation]) {
motion(delay: 0, duration: 0.25, timingFunction: .easeInEaseOut, animations: animations) motion(delay: 0, duration: 0.35, timingFunction: .easeInEaseOut, animations: animations)
} }
/** /**
......
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