Dominaezzz
08/09/2021, 10:18 PMModifier.animateContentSize . Is there a version of this like Modifier.animateContentPosition ? Or how would I go about writing my own? Modifier.layout doesn't provide a position.Dominaezzz
08/09/2021, 10:23 PMDoris Liu
08/09/2021, 10:32 PMDominaezzz
08/09/2021, 10:36 PMLayoutNode from position to position is something the parent layout should probably do. (At least for what I had in mind)Dominaezzz
08/09/2021, 10:36 PMDominaezzz
08/09/2021, 10:38 PMLazyColumn re-ordering animations, then realised that it would be really broken for scrolling. Which is why I concluded that LazyColumn should be doing the animations instead of the items.Dominaezzz
08/09/2021, 10:41 PManimateContentPosition would probably require global position, which is more/less impossible to get within the same frame/composition.
Actually, not global position per se, but it'll have to climb up the layout hierarchy to some "global enough" layout to get the position.Dominaezzz
08/09/2021, 10:42 PMDoris Liu
08/09/2021, 10:42 PManimateContentSizeDoris Liu
08/09/2021, 10:46 PMActually, not global position per se, but it'll have to climb up the layout hierarchy to some "global enough" layout to get the position.Seems like you are trying to animate the position relative to an
indirect parent? With direct parents, you could use LayoutCoordinates#positionInParent() to get the child placementDominaezzz
08/09/2021, 10:48 PMIt's also quite interesting to insert an additional modifier between child and parent for such an animationThis sounds like more or less what I'm looking for. The only pesky thing is I need to disable the animation during scroll. Or rather, scroll should be one layer above the "global enough" parent. Maybe
LazyColumn is not composable enough.Dominaezzz
08/09/2021, 10:49 PMLayoutCoordinates from? I don't think Layout or Modifier.layout provides this?Doris Liu
08/09/2021, 10:51 PMonGlobalPositioned modifier to get the LayoutCoordinates.
I'm playing around with an idea around Modifier.animatePlacement , I can upload the code if you are interested.`Dominaezzz
08/09/2021, 10:52 PMDoris Liu
08/09/2021, 11:14 PMDominaezzz
08/10/2021, 10:03 AMonGlaballyPositioned gives the position a frame too late I think.Doris Liu
08/10/2021, 5:11 PMonGlobalPositioned for acquiring LayoutCoordinates for the first time. It will be in the same first frame, but after draw. Being late on the first frame is not a problem since we don't animate when layout first show up anyways. The subsequent LayoutCoordinates#positionInParent are queried during placement time, which triggers a calculation (instead of using the cached position from last frame).
I don't think there should be any stutter, nor do I see any. But it does have the same issue with scrolling as you mentioned earlier, since scrolling also changes the "position in parent". 🙂Dominaezzz
08/10/2021, 5:19 PMLayoutCoordinates was an immutable snapshot but it seems to be a persistent reference to the parent node. So positionInParent is always the current value.Dominaezzz
08/10/2021, 5:20 PMAnimatedVisibility , which will hide any stutter I think. If you straight up removed the node, I think the stutter, if there is any, will show itself. I should try this out myself.Doris Liu
08/10/2021, 5:26 PManimatePlacement modifier) doesn't start until that exit animation is done and item is removed. I had the immediate removal before. I don't see why it would stutter. Even if it's one frame behind, you'd just see a spring chain like effect.
Yes, please feel free to try it yourself. 🙂