When using `AnimatedVisibility` to expand/collapse...
# compose
u
When using
AnimatedVisibility
to expand/collapse some content inside
ModalBottomSheetLayout
the animation is odd when collapsing. The sheet it appears to be "jumping", i.e. settings its height in such way that there is a hole at the bottom for a brief period, which doesn't feel correct for a bottom sheet It feels like it's some sort of springy easing function, any idea what I have to tweak?
e
Content is removed from the composition immediately (probably the data is now empty) so size is zero while animating out. In my case, I have some code to cache the data till the animation is done:
Copy code
AnimatedVisibility(
  visible = selections.isNotEmpty(),
  enter = expandVertically(expandFrom = <http://Alignment.Top|Alignment.Top>),
  exit = shrinkVertically(shrinkTowards = <http://Alignment.Top|Alignment.Top>),
) {
  // We hold the state locally so that while the transition is 'Visible' we can still draw the chips.
  var localSelections by remember { mutableStateOf(selections) }
  // Only update the local state when we are not transitioning, ie when current & target are equal
  if (transition.currentState == transition.targetState) localSelections = selections

  SelectionChips(localSelections)
}
j
We have a fix for this issue pending, I'll follow up with an issue to follow.
@efemoney What's happening in the video above is that the layout size changes from the animation, but Swipeable only catches up in the next frame. So it's always a bit behind and doesn't match the layout size properly.
I don't have an ETA, but we are doing our best to bring in the fix soon
u
Okay I'll live with it for the time being, thanks!
e
Ah that's true! i slowed it down, it's different from what I mentioned 😅🙏🏽