-
Notifications
You must be signed in to change notification settings - Fork 590
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
[Navigation Animation] Control composable route zIndex #1160
Comments
I tried implementing this myself: I was able to calculate the right Am I missing something? I case I'm not - I've created a feature request on google issue tracker. |
Want to add in @doris4lt to give her more context on the goal here. |
I think the functionality that you are asking for can be achieved with Could you give it a try so we know whether we need to add more support for zIndex in AnimatedContent, or surface that support in navigation APIs? |
Thanks, @doris4lt, Not sure what is the ideal API to solve this issue - in my project I just check the index in |
@PhilipDukhov How would you like to customize the target zIndex? We could potentially support the target zIndex through |
@doris4lt I'm using the following code in
I guess that the most flexible solution is to allow customizations of I actually resolve all my animations in |
Have you considered
Could you give me a fanfic example of how you would like to customize |
@doris4lt For my needs But I ran into another problem with Let's say I have several views in the stack. And I want to replace the stack with a new single view using slide animation. I use
The problem is that Is there any way to recalculate |
Hi, I get the same problem with zindex using slideInHorizontally, but I dont get how to set the variable targetContentZIndex , it just shows "Unresolved reference: targetContentZIndex" @PhilipDukhov Can you kindly give a hint how you do it ? Thanks |
@x4080 have you checked official sample on https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/animation/animation/samples/src/main/java/androidx/compose/animation/samples/AnimatedContentSamples.kt;l=242? Until this issue is resolved, you have to create a fork or copy source code to your project to make this change in |
Hi @doris4lt, can you confirm that the problem from my last comment is clear, or should I provide a minimal reproducible example with a video and more details? |
@PhilipDukhov thanks, I did what you describe above and works, I think I modified inside push and pop to inc or dec z-index I wondered why its not default :) |
@PhilipDukhov Thanks for the example. Sorry I didn't see the question until just now.
The intention is not to allow the zIndex to change for the content that is already on screen, to avoid a sudden jump. This could happen especially when you interrupt an animation, e.g. when going from destination A -> B, user changes their mind to go to C. Now you have both A and B exiting, while C entering. If we allow B's zIndex to be changed at the point of interruption, it could potentially jump above or below A. With that said, we are looking for better ways to support zIndex customization without introducing a foot gun. We just haven't found it yet. If I understand your use case correctly, its spacial model isn't completely dictated by the back queue. More specifically, in the example of Could you elaborate on the ideal z-order that you'd like to see for the content in the stack? Seems like there are special cases on top of a more general rule, which is perfectly valid. But I'd like to have a better understanding of the overall requirements. |
@doris4lt I found a way to calculate it for my particular case using an auxiliary array, so being able to change |
@PhilipDukhov |
@doris4lt Sure, it looks like this:
|
What we do need here is the ability to manipulate witch state will be "on top".
or make NavController api work with compose
or make ZIndex of a destination equal to destination index in NavController.backQueue |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
It's still relevant |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
It's still relevant |
We can at the very least update the z-order to match the ordering of our visible entries which reflects what we would expect from an animation stand point. |
Any update on this? Currently a forked version of
But this should be a treated as a temporary fix until an official solution is pushed where the z-order matches the ordering of visible entries. I am thinking @PhilipDukhov 's issue is similar to #1172 that we're currently facing. |
NavHost should respect the z-order established by visibleEntries. This ensures that incoming Composables will be on top of exiting ones, except in the case of a pop it is expected that it is reversed. Fixes: google#1160
I'm trying to implement modal transition: new screen slides in from bottom and slides out back.
Expected behaviour:
Slide in animation works fine, but slide out animation doesn't - because appearing view seems to have higher
zIndex
, no matter wether it is pushing or popping.Actual behaviour:
I've tried specifying it with a modifier, it didn't worked out. In my case I need
zIndex
to be equal to backstack index, in other words during pop disappearing view should have higher zIndex, than the appearing one.The text was updated successfully, but these errors were encountered: