Skip to content

Commit

Permalink
fix: check for animated transitions only in root vc
Browse files Browse the repository at this point in the history
  • Loading branch information
ioannisj committed Nov 28, 2024
1 parent e2b088d commit 59c2145
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions PostHog/Replay/PostHogReplayIntegration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,8 @@
}

private func toScreenshotWireframe(_ window: UIWindow) -> RRWireframe? {
if !window.isVisible() {
return nil
}

// this will bail on interactive animations (e.g edge slide)
if isAnimatingTransition(window) {
if !window.isVisible() || isAnimatingTransition(window) {
return nil
}

Expand All @@ -393,18 +389,7 @@

/// Check if window's root view controller is animating a transition
private func isAnimatingTransition(_ window: UIWindow) -> Bool {
guard let viewController = window.rootViewController else { return false }

return isAnimatingTransition(viewController)
}

// Recursively check if a view controller (or any of its children) is currently animating a transition
// During a transition, a UIViewControllerTransitionCoordinator is assigned to a UIViewController which controls the overall transition
private func isAnimatingTransition(_ viewController: UIViewController) -> Bool {
if let isAnimated = viewController.transitionCoordinator?.isAnimated {
return isAnimated
}
return viewController.children.contains(where: isAnimatingTransition)
window.rootViewController?.transitionCoordinator?.isAnimated ?? false
}

private func isAssetsImage(_ image: UIImage) -> Bool {
Expand Down

0 comments on commit 59c2145

Please sign in to comment.