https://kotlinlang.org logo
Title
a

andrew

03/05/2022, 1:37 AM
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

Doris Liu

03/05/2022, 5:38 AM
Curious what's your use case for needing to reset it?
a

andrew

03/07/2022, 12:38 AM
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

Doris Liu

03/07/2022, 7:18 PM
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

andrew

03/08/2022, 12:00 AM
My thinking was to expose an initialContentZIndex to go alongside target
d

Doris Liu

03/08/2022, 12:01 AM
What would you reset it to?
a

andrew

03/08/2022, 12:01 AM
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

Doris Liu

03/08/2022, 12:05 AM
That sounds nice in the ideal scenario. What if the animation gets interrupted and there are more than one outgoing screens?
a

andrew

03/08/2022, 12:05 AM
Hmmmmm, that’s a good point
In this case, keeping it based on history size is ideal
d

Doris Liu

03/08/2022, 12:06 AM
(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

andrew

03/08/2022, 12:06 AM
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

Doris Liu

03/08/2022, 12:07 AM
Do you mean perf drawback in the fully obstructed cases where there is a rich screen underneath?
a

andrew

03/08/2022, 12:08 AM
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

Doris Liu

03/08/2022, 12:11 AM
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

andrew

03/08/2022, 12:12 AM
Good to know!
d

Doris Liu

03/08/2022, 12:12 AM
Pretty cool demo btw! 😍
🙌🏻 1
a

andrew

03/08/2022, 12:13 AM
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

Doris Liu

03/08/2022, 12:14 AM
Inconsistent design as well?
Oh, as well as the perf
a

andrew

03/08/2022, 12:16 AM
Yup, plus, the codebase feels kinda thrown together in places, poor patterns in use, poor state management
d

Doris Liu

03/08/2022, 12:16 AM
Sounds like you have a fun project on your hand. 😉
a

andrew

03/08/2022, 12:16 AM
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

Doris Liu

03/08/2022, 12:19 AM
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

andrew

03/08/2022, 12:20 AM
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

Doris Liu

03/08/2022, 12:21 AM
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

andrew

03/08/2022, 12:24 AM
That should have a lesser zindex still, since the stack is smaller at time of eval though, right?
d

Doris Liu

03/08/2022, 12:26 AM
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

andrew

03/08/2022, 12:27 AM
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

Doris Liu

03/08/2022, 12:30 AM
In that case I would expect the current size of the stack to be sufficient, maybe that's what
history.size + 1f
is?
a

andrew

03/08/2022, 12:36 AM
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

Doris Liu

03/09/2022, 2:24 AM
Mostly in terms of influencing design through the shape of lower level animation APIs. Why
a

andrew

03/09/2022, 3:45 AM
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

Doris Liu

03/09/2022, 3:52 AM
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?