Is there any way to reset `targetContentZIndex` af...
# compose
a
Is there any way to reset
targetContentZIndex
after a
ContentTransform
animation is done in
AnimatedContent
?
I came up with a hacky solution here, not ideal, if there’s a way to reset this, that’d be great
d
Curious what's your use case for needing to reset it?
a
I'm implementing a stack navigator with transitions, I need to make sure when popping, the previous screen in the stack doesn't overlay the old current screen
Right now I'm just basing it off of the size of the history
d
Having the
zIndex
based on the size of the stack would be a good choice for your use case. How and when would you want to reset the zIndex if we had a way to reset it? I'm assuming you are trying to reset the zIndex for the outgoing screen?
a
My thinking was to expose an initialContentZIndex to go alongside target
d
What would you reset it to?
a
You can see the current behavior of it here, so you can visualize the zindex
initial zIndex would be 0 whereas the target zIndex would be -1
That way the previous, initial screen, would still be elevated
Currently what I’m doing
d
That sounds nice in the ideal scenario. What if the animation gets interrupted and there are more than one outgoing screens?
a
Hmmmmm, that’s a good point
In this case, keeping it based on history size is ideal
d
(The question above was one of the things that we factored into this design.) It's entirely possible there are better solutions than what's provided. 🙂 I'm open to new ideas
a
Is there any kind of perf drawback with zindex?
Especially with really large ones?
I guess as long as you have relevant data captured within this scope, it’s probably better to use that
d
Do you mean perf drawback in the fully obstructed cases where there is a rich screen underneath?
a
No, because there would be no screen underneath technically, until a transition occurs
I just mean if you set a really high zindex level in general, is there any limitations with that?
With how drawing is handled, etc?
d
I don't think the specific zIndex value matters much to performance. The zIndex eventually comes down to a sorting: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]ommonMain/kotlin/androidx/compose/ui/node/LayoutNode.kt;l=394
a
Good to know!
d
Pretty cool demo btw! 😍
🙌🏻 1
a
Thank you, my manager gave me the blessing to rewrite our react native app, we’re kinda sick and tired of the performance overhead and tooling effort associated with it
The react native app has an inconsistent design system as well, so the goal is to get it up to RealPage’s RAUL v3 design language spec
d
Inconsistent design as well?
Oh, as well as the perf
a
Yup, plus, the codebase feels kinda thrown together in places, poor patterns in use, poor state management
d
Sounds like you have a fun project on your hand. 😉
a
And don’t get me started on React Native’s bridge concept 😆
It has been so far, I’ve been itching for more excuses to use compose other than just hobby projects
Being able to do the little things, and still have this perform with almost 0 jank… it’s been really fulfilling
d
Glad to hear that. Let me know if you have any other questions/suggestions on animation. As I was just thinking about it, there's another interruption scenario during the screen transition, which is going back before the push onto the stack is finished, then all of a sudden the incoming screen becomes outgoing, and vice versa. We definitely don't want the zIndex to be swapped in that case - zIndex jump almost never looks good
a
Yeah, as of now though, I haven’t seen any kind of major zindex jumping with using the stack, but any sanity check would be a huge help 😛
d
This design is forcing
zIndex
to be considered more holistically.
Yeah, as of now though, I haven’t seen any kind of major zindex jumping with using the stack, but any sanity check would be a huge help
Yea, this design doesn't allow one to muck with zIndex on outgoing content. But it is possible to cause a zIndex jump in an interrupted animation, where the outgoing screen becomes the new target with a new zIndex.
a
That should have a lesser zindex still, since the stack is smaller at time of eval though, right?
d
if you use the stack size as the zIndex, it should be the same.
(unless you keep the transient entry that is currently exiting in the stack)
a
I’m not keeping it currently, but that’s also why theres the +1 and -1 offsets on the zIndex added to the stack size
That bit is handled internally by the transition system
d
In that case I would expect the current size of the stack to be sufficient, maybe that's what
history.size + 1f
is?
a
Yeah, that is to compensate for the loss of the current item
Though, -1 probably wouldnt be needed then
-1 is definitely not needed
👍 1
@Doris Liu did you have any say on the Swipeable implementation used in material?
d
Mostly in terms of influencing design through the shape of lower level animation APIs. Why
a
Is there any reason why the internal progress is documented to return 1F when currently 0, but not actually animated? It’s not all that clear to me, seems counterintuitive
I ripped the current impl from the material code, but there seems to be indication of it potentially moving to foundation, I just wanted to know if this behavior was absolutely set in stone?
d
The
SwipeProgress
seems to be experimental, so definitely not set in stone. I'd recommend putting your feedback in a bug. The documentation says when it's not animating, the from/to would be the same, so the progress fraction won't matter that much I assume?