Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #735 check 0 divide, use TimeInt.zero over 0 #736

Merged
merged 4 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Sources/Animator/HeroViewPropertyViewContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
36 changes: 14 additions & 22 deletions Sources/Transition/HeroTransition+Start.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down