diff --git a/Sources/Hero.swift b/Sources/Hero.swift index 9f870c8e..67a8ed97 100644 --- a/Sources/Hero.swift +++ b/Sources/Hero.swift @@ -177,9 +177,9 @@ internal extension Hero { animate() #else if inNavigationController { - // When animating within navigationController, we have to delay a frame. - // otherwise snapshots will not be taken. Possibly a bug with UIKit - execute(after: 0.01666666667) { + // When animating within navigationController, we have to dispatch later into the main queue. + // otherwise snapshots will be pure white. Possibly a bug with UIKit + DispatchQueue.main.async { self.animate() } } else { diff --git a/Sources/HeroBaseController.swift b/Sources/HeroBaseController.swift index 58209495..7dab18fd 100644 --- a/Sources/HeroBaseController.swift +++ b/Sources/HeroBaseController.swift @@ -22,13 +22,6 @@ import UIKit -internal var heroOperationQueue: OperationQueue = { - let oq = OperationQueue() - oq.maxConcurrentOperationCount = 1 - oq.name = "heroOperationQueue" - return oq -}() - /// Base class for managing a Hero transition public class HeroBaseController: NSObject { // MARK: Properties @@ -143,7 +136,7 @@ public extension HeroBaseController { */ public func update(progress: Double) { guard transitioning else { return } - execute { + DispatchQueue.main.async { self.beginTime = nil self.progress = max(0, min(1, progress)) } @@ -156,7 +149,7 @@ public extension HeroBaseController { */ public func end(animate: Bool = true) { guard transitioning && interactive else { return } - execute { + DispatchQueue.main.async { if !animate { self.complete(finished:true) return @@ -177,7 +170,7 @@ public extension HeroBaseController { */ public func cancel(animate: Bool = true) { guard transitioning && interactive else { return } - execute { + DispatchQueue.main.async { if !animate { self.complete(finished:false) return @@ -205,7 +198,7 @@ public extension HeroBaseController { */ public func apply(modifiers: [HeroModifier], to view: UIView) { guard transitioning && interactive else { return } - execute { + DispatchQueue.main.async { let targetState = HeroTargetState(modifiers: modifiers) if let otherView = self.context.pairedView(for: view) { for animator in self.animators { @@ -372,19 +365,6 @@ internal extension HeroBaseController { completion?(finished) } - - func execute(after: TimeInterval = 0, block: @escaping () -> Void) { - if heroOperationQueue.operationCount > 0 || after > 0 { - heroOperationQueue.addOperation { - Thread.sleep(forTimeInterval: after) - DispatchQueue.main.async { - block() - } - } - } else { - block() - } - } } // MARK: Plugin Support