diff --git a/Sources/Animator/HeroViewPropertyViewContext.swift b/Sources/Animator/HeroViewPropertyViewContext.swift index 11e56596..5dcbdd63 100644 --- a/Sources/Animator/HeroViewPropertyViewContext.swift +++ b/Sources/Animator/HeroViewPropertyViewContext.swift @@ -36,7 +36,8 @@ internal class HeroViewPropertyViewContext: HeroAnimatorViewContext { } override func resume(timePassed: TimeInterval, reverse: Bool) -> TimeInterval { - guard let visualEffectView = snapshot as? UIVisualEffectView else { return 0 } + guard let visualEffectView = snapshot as? UIVisualEffectView else { return .zero } + guard duration > 0 else { return .zero } if reverse { viewPropertyAnimator?.stopAnimation(false) viewPropertyAnimator?.finishAnimation(at: .current) diff --git a/Sources/Transition/HeroTransition+Start.swift b/Sources/Transition/HeroTransition+Start.swift index bbc9d573..3bcd666a 100644 --- a/Sources/Transition/HeroTransition+Start.swift +++ b/Sources/Transition/HeroTransition+Start.swift @@ -93,9 +93,9 @@ extension HeroTransition { } // There is no covariant in Swift, so we need to add plugins one by one. - for plugin in plugins { - processors.append(plugin) - animators.append(plugin) + plugins.forEach { + processors.append($0) + animators.append($0) } transitionContainer?.isUserInteractionEnabled = isUserInteractionEnabled @@ -110,14 +110,14 @@ extension HeroTransition { context = HeroContext(container: container) - for processor in processors { - processor.hero = self + processors.forEach { + $0.hero = self } - for animator in animators { - animator.hero = self + animators.forEach { + $0.hero = self } - if let toView = toView, let fromView = fromView { + if let toView = toView, let fromView = fromView, toView != fromView { // if we're presenting a view controller, remember the position & dimension // of the view relative to the transition container so that we can: // - correctly place the view in the transition container when presenting @@ -160,24 +160,16 @@ extension HeroTransition { context.insertToViewFirst = true } - for processor in processors { - processor.process(fromViews: context.fromViews, toViews: context.toViews) + processors.forEach { + $0.process(fromViews: context.fromViews, toViews: context.toViews) } + animatingFromViews = context.fromViews.filter { (view: UIView) -> Bool in - for animator in animators { - if animator.canAnimate(view: view, appearing: false) { - return true - } - } - return false + animators.contains { $0.canAnimate(view: view, appearing: false) } } + animatingToViews = context.toViews.filter { (view: UIView) -> Bool in - for animator in animators { - if animator.canAnimate(view: view, appearing: true) { - return true - } - } - return false + animators.contains { $0.canAnimate(view: view, appearing: true) } } if let toView = toView {