Hero: zPositions not being respected (with example)

Created on 6 May 2017  路  7Comments  路  Source: HeroTransitions/Hero

Hi There,

Firstly, love the library - amazing job.

Hero seems to be reordering layers depending on whether a view appears at the end of the transition or not.

I've created a quick example (excuse the poor code) here . You'll notice the 'Previous' button is being covered by the animating background.

Any suggestions would be great.

Steve

reopen if needed

Most helpful comment

Try adding the .useGlobalCoordinateSpace modifier to the views being obscured.

All 7 comments

I have the same problem currently. I set the heroModifier zPosition to 0, but I can't see any changes

@Sn0wfreezeDev did you ever find a solve by chance?

My solution was to set the alpha of the overlaying buttons to 0.0 and when the animation is completed animate the buttons in after that.
The problem is that it took longer until everything was shown, but I guess in my setup it's almost impossible to animate the image into the correct position without overlaying the buttons.

Cheers,
Alex

Try adding the .useGlobalCoordinateSpace modifier to the views being obscured.

@leeprobert my DUDE! Wasted half my day before trying .useGlobalCoordinateSpace. Thanks!

Does not help with issue #454

I use this piece of code, and works great:

extension HeroModifier { 
    static var bringToFront: HeroModifier { 
        return zPositionGlobal(CGFloat.greatestFiniteMagnitude) 
    } 

    static func zPositionGlobal(_ zPosition: CGFloat) -> HeroModifier { 
        return HeroModifier(applyFunction: { (targetState) in 
            targetState.coordinateSpace = .global 
            if targetState.beginState == nil { 
                targetState.beginState = [] 
            } 
            targetState.beginState!.append(.zPosition(zPosition)) 
        }) 
    } 
} 
Was this page helpful?
0 / 5 - 0 ratings

Related issues

joeljfischer picture joeljfischer  路  3Comments

aloisdeniel picture aloisdeniel  路  5Comments

josmanperez picture josmanperez  路  3Comments

czater picture czater  路  3Comments

pxwinter picture pxwinter  路  3Comments