Commit 7b809595 by Daniel Dahan

progression commit for Motion+Animate

parent f85a6744
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
965FE9691FDDA1F20098BDD0 /* MotionViewOrderStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965FE9681FDDA1F20098BDD0 /* MotionViewOrderStrategy.swift */; }; 965FE9691FDDA1F20098BDD0 /* MotionViewOrderStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965FE9681FDDA1F20098BDD0 /* MotionViewOrderStrategy.swift */; };
965FE96B1FDDA4EA0098BDD0 /* BaseMotionPreprocessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965FE96A1FDDA4EA0098BDD0 /* BaseMotionPreprocessor.swift */; }; 965FE96B1FDDA4EA0098BDD0 /* BaseMotionPreprocessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965FE96A1FDDA4EA0098BDD0 /* BaseMotionPreprocessor.swift */; };
965FE96D1FDDA6400098BDD0 /* BaseMotionAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965FE96C1FDDA6400098BDD0 /* BaseMotionAnimator.swift */; }; 965FE96D1FDDA6400098BDD0 /* BaseMotionAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965FE96C1FDDA6400098BDD0 /* BaseMotionAnimator.swift */; };
965FE96F1FDEFA8B0098BDD0 /* Motion+Animate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 965FE96E1FDEFA8B0098BDD0 /* Motion+Animate.swift */; };
96E409651F24F7370015A2B5 /* MotionAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E4093D1F24F7370015A2B5 /* MotionAnimator.swift */; }; 96E409651F24F7370015A2B5 /* MotionAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E4093D1F24F7370015A2B5 /* MotionAnimator.swift */; };
96E409661F24F7370015A2B5 /* MotionAnimatorViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E4093E1F24F7370015A2B5 /* MotionAnimatorViewContext.swift */; }; 96E409661F24F7370015A2B5 /* MotionAnimatorViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E4093E1F24F7370015A2B5 /* MotionAnimatorViewContext.swift */; };
96E409671F24F7370015A2B5 /* MotionCoreAnimationViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E4093F1F24F7370015A2B5 /* MotionCoreAnimationViewContext.swift */; }; 96E409671F24F7370015A2B5 /* MotionCoreAnimationViewContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E4093F1F24F7370015A2B5 /* MotionCoreAnimationViewContext.swift */; };
...@@ -91,6 +92,7 @@ ...@@ -91,6 +92,7 @@
965FE9681FDDA1F20098BDD0 /* MotionViewOrderStrategy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MotionViewOrderStrategy.swift; sourceTree = "<group>"; }; 965FE9681FDDA1F20098BDD0 /* MotionViewOrderStrategy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MotionViewOrderStrategy.swift; sourceTree = "<group>"; };
965FE96A1FDDA4EA0098BDD0 /* BaseMotionPreprocessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseMotionPreprocessor.swift; sourceTree = "<group>"; }; 965FE96A1FDDA4EA0098BDD0 /* BaseMotionPreprocessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseMotionPreprocessor.swift; sourceTree = "<group>"; };
965FE96C1FDDA6400098BDD0 /* BaseMotionAnimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseMotionAnimator.swift; sourceTree = "<group>"; }; 965FE96C1FDDA6400098BDD0 /* BaseMotionAnimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseMotionAnimator.swift; sourceTree = "<group>"; };
965FE96E1FDEFA8B0098BDD0 /* Motion+Animate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Motion+Animate.swift"; sourceTree = "<group>"; };
96C98DD11E424AB000B22906 /* Motion.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Motion.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 96C98DD11E424AB000B22906 /* Motion.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Motion.framework; sourceTree = BUILT_PRODUCTS_DIR; };
96E4093D1F24F7370015A2B5 /* MotionAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MotionAnimator.swift; sourceTree = "<group>"; }; 96E4093D1F24F7370015A2B5 /* MotionAnimator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MotionAnimator.swift; sourceTree = "<group>"; };
96E4093E1F24F7370015A2B5 /* MotionAnimatorViewContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MotionAnimatorViewContext.swift; sourceTree = "<group>"; }; 96E4093E1F24F7370015A2B5 /* MotionAnimatorViewContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MotionAnimatorViewContext.swift; sourceTree = "<group>"; };
...@@ -157,6 +159,7 @@ ...@@ -157,6 +159,7 @@
965FE9601FDCC3AF0098BDD0 /* MotionState.swift */, 965FE9601FDCC3AF0098BDD0 /* MotionState.swift */,
965FE9681FDDA1F20098BDD0 /* MotionViewOrderStrategy.swift */, 965FE9681FDDA1F20098BDD0 /* MotionViewOrderStrategy.swift */,
965FE9661FDD99800098BDD0 /* Motion+Start.swift */, 965FE9661FDD99800098BDD0 /* Motion+Start.swift */,
965FE96E1FDEFA8B0098BDD0 /* Motion+Animate.swift */,
965FE9621FDCCE030098BDD0 /* Motion+Complete.swift */, 965FE9621FDCCE030098BDD0 /* Motion+Complete.swift */,
965FE9641FDCCE910098BDD0 /* MotionProgressRunner.swift */, 965FE9641FDCCE910098BDD0 /* MotionProgressRunner.swift */,
96E409511F24F7370015A2B5 /* MotionAnimation.swift */, 96E409511F24F7370015A2B5 /* MotionAnimation.swift */,
...@@ -359,6 +362,7 @@ ...@@ -359,6 +362,7 @@
965FE9651FDCCE910098BDD0 /* MotionProgressRunner.swift in Sources */, 965FE9651FDCCE910098BDD0 /* MotionProgressRunner.swift in Sources */,
965FE9611FDCC3AF0098BDD0 /* MotionState.swift in Sources */, 965FE9611FDCC3AF0098BDD0 /* MotionState.swift in Sources */,
96E4097F1F24F7370015A2B5 /* MotionTransition.swift in Sources */, 96E4097F1F24F7370015A2B5 /* MotionTransition.swift in Sources */,
965FE96F1FDEFA8B0098BDD0 /* Motion+Animate.swift in Sources */,
96E409751F24F7370015A2B5 /* Motion.swift in Sources */, 96E409751F24F7370015A2B5 /* Motion.swift in Sources */,
96E4096F1F24F7370015A2B5 /* Motion+Obj-C.swift in Sources */, 96E4096F1F24F7370015A2B5 /* Motion+Obj-C.swift in Sources */,
96E409711F24F7370015A2B5 /* Motion+UIView.swift in Sources */, 96E409711F24F7370015A2B5 /* Motion+UIView.swift in Sources */,
......
/*
* The MIT License (MIT)
*
* Copyright (C) 2017, Daniel Dahan and CosmicMind, Inc. <http://cosmicmind.com>.
* All rights reserved.
*
* Original Inspiration & Author
* Copyright (c) 2016 Luke Zhao <me@lkzhao.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import UIKit
extension Motion {
/// Starts the transition animation.
func animate() {
guard .starting == state else {
return
}
state = .animating
if let tv = toView {
context.unhide(view: tv)
}
for (fv, tv) in transitionPairs {
for v in fv {
context.hide(view: v)
}
for v in tv {
context.hide(view: v)
}
}
var t: TimeInterval = 0
var animatorWantsInteractive = false
if context.insertToViewFirst {
for (fv, tv) in transitionPairs {
for v in tv {
context.snapshotView(for: v)
}
for v in fv {
context.snapshotView(for: v)
}
}
} else {
for (fv, tv) in transitionPairs {
for v in fv {
context.snapshotView(for: v)
}
for v in tv {
context.snapshotView(for: v)
}
}
}
// UIKit appears to set fromView setNeedLayout to be true.
// We don't want fromView to layout after our animation starts.
// Therefore we kick off the layout beforehand
fromView?.layoutIfNeeded()
for (i, a) in animators.enumerated() {
let d = a.animate(fromViews: transitionPairs[i].0, toViews: transitionPairs[i].1)
if .infinity == d {
animatorWantsInteractive = true
} else {
t = max(t, d)
}
}
totalDuration = t
if let forceFinishing = forceFinishing {
complete(isFinishing: forceFinishing)
} else if let startingProgress = startingProgress {
update(elapsedTime: startingProgress)
} else if animatorWantsInteractive {
update(elapsedTime: 0)
} else {
complete(after: totalDuration, isFinishing: true)
}
fullScreenSnapshot?.removeFromSuperview()
}
}
...@@ -279,7 +279,7 @@ public class Motion: NSObject, MotionProgressRunnerDelegate { ...@@ -279,7 +279,7 @@ public class Motion: NSObject, MotionProgressRunnerDelegate {
*/ */
internal var forceNonInteractive = false internal var forceNonInteractive = false
internal var forceFinishing: Bool? internal var forceFinishing: Bool?
internal var startingProgress: CGFloat? internal var startingProgress: TimeInterval?
/// Indicates whether a UINavigationController is transitioning. /// Indicates whether a UINavigationController is transitioning.
internal var isNavigationController = false internal var isNavigationController = false
...@@ -450,63 +450,6 @@ public extension Motion { ...@@ -450,63 +450,6 @@ public extension Motion {
} }
internal extension Motion { internal extension Motion {
/**
Animates the views. Subclasses should call `prepareTransition` &
`prepareTransitionPairs` before calling `animate`.
*/
@objc
func animate() {
guard .starting == state else {
return
}
state = .animating
if let tv = toView {
context.unhide(view: tv)
}
for (fv, tv) in transitionPairs {
for view in fv {
context.hide(view: view)
}
for view in tv {
context.hide(view: view)
}
}
var t: TimeInterval = 0
var b = false
for (i, a) in animators.enumerated() {
let d = a.animate(fromViews: transitionPairs[i].0, toViews: transitionPairs[i].1)
if .infinity == d {
b = true
} else {
t = max(t, d)
}
}
totalDuration = t
if b {
update(elapsedTime: 0)
} else {
complete(after: t, isFinishing: true)
}
updateContainerBackgroundColor()
updateInsertOrder()
fullScreenSnapshot?.removeFromSuperview()
}
}
internal extension Motion {
/// Updates the container background color. /// Updates the container background color.
func updateContainerBackgroundColor() { func updateContainerBackgroundColor() {
if let v = containerBackgroundColor { if let v = containerBackgroundColor {
......
...@@ -166,6 +166,7 @@ public extension MotionContext { ...@@ -166,6 +166,7 @@ public extension MotionContext {
- Parameter for view: A UIView. - Parameter for view: A UIView.
- Returns: A UIView. - Returns: A UIView.
*/ */
@discardableResult
func snapshotView(for view: UIView) -> UIView { func snapshotView(for view: UIView) -> UIView {
if let snapshot = viewToSnapshot[view] { if let snapshot = viewToSnapshot[view] {
return snapshot return snapshot
......
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