From f437fe9157f0fddcf3c8b922639d26e29c899e0d Mon Sep 17 00:00:00 2001 From: Joseph Mattello Date: Thu, 5 May 2022 03:16:02 -0400 Subject: [PATCH 1/3] Fixes #735 check 0 divide, use TimeInt.zero over 0 Signed-off-by: Joseph Mattello --- Sources/Animator/HeroViewPropertyViewContext.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) From e00b9046971b668d8770fd68600f8761b7ee0fd2 Mon Sep 17 00:00:00 2001 From: Joseph Mattello Date: Thu, 5 May 2022 03:20:00 -0400 Subject: [PATCH 2/3] refs #734 check toView != fromView Signed-off-by: Joseph Mattello --- Sources/Transition/HeroTransition+Start.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Transition/HeroTransition+Start.swift b/Sources/Transition/HeroTransition+Start.swift index bbc9d573..f6a7630b 100644 --- a/Sources/Transition/HeroTransition+Start.swift +++ b/Sources/Transition/HeroTransition+Start.swift @@ -117,7 +117,7 @@ extension HeroTransition { animator.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 From e00bc08e95fbcd42dfe17e29f9a45bfa5cbc6e0a Mon Sep 17 00:00:00 2001 From: Joseph Mattello Date: Fri, 6 May 2022 00:20:19 -0400 Subject: [PATCH 3/3] refs #735 cleanup crashing function code make loop improvements Signed-off-by: Joseph Mattello --- Sources/Transition/HeroTransition+Start.swift | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/Sources/Transition/HeroTransition+Start.swift b/Sources/Transition/HeroTransition+Start.swift index f6a7630b..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,11 +110,11 @@ 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, toView != fromView { @@ -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 {