HeroTransitions / Hero

Elegant transition library for iOS & tvOS
https://HeroTransitions.github.io/Hero/
MIT License
22.02k stars 1.72k forks source link

Usage with URLNavigator #675

Closed netgfx closed 4 years ago

netgfx commented 4 years ago

What did you do?

Trying to use the build in transitions with URLNavigator library https://github.com/devxoul/URLNavigator

navigator.register("app://about") { url, values, context in
        let vc2 = AboutVC(navigator: navigator)
        vc2.hero.isEnabled = true
        vc2.hero.modalAnimationType = .selectBy(presenting: .cover(direction: .up), dismissing: .cover(direction: .down))
        return vc2
    }

then self.navigator.push("app://about", context: nil, from: TransparentNavigationViewController.self as? UINavigationControllerType, animated: true)

What did you expect to happen?

Expected to see the custom animation

What happened instead?

Normal push animation happens.

General Information

Demo Project

netgfx commented 4 years ago

I was able to solve this by adding the following line:

self.navigationController?.hero.navigationAnimationType = .autoReverse(presenting: .cover(direction: .up)) or self.navigationController?.hero.navigationAnimationType = .selectBy(presenting: .cover(direction: .up), dismissing: .slide(direction: .down))

then self.navigator.push("app://about", context: nil, from: nil, animated: true) So the trick here is to have .hero.isEnabled = true on the navigator controller and then apply the animation to the navigator controller and not the presented view