https://kotlinlang.org logo
#compose
Title
# compose
a

allan.conda

10/28/2020, 11:38 AM
Is it possible to make the Composable not clip within its bounds when using AnimatedVisibility? slideInVertically() seems unusable due to the clipping
d

Doris Liu

10/29/2020, 12:54 AM
slideInVertically
shouldn't clip, but its parent may choose to clip it. Which composable are you seeing the clipping in?
a

allan.conda

10/29/2020, 12:54 AM
ah. I’m trying to animate my LazyColumn items
d

Doris Liu

10/29/2020, 12:58 AM
That sounds like a reasonable use case. Please file a bug if there's no good way to do it through public API. 🙂
a

allan.conda

10/29/2020, 1:21 AM
Thanks! I’m going to see what I can find and do that if I can’t otherwise.
Ok I guess I can file it as a bug and it can either be considered or set to won’t fix
d

Doris Liu

10/29/2020, 1:25 AM
In LazyColumn(For) you'll need to hoist the state for whether the item has been shown. If an item has been shown, you can set the
initiallyVisible
param to true, to prevent animations from firing.
a

allan.conda

10/29/2020, 1:59 PM
I’ve been trying to do that but I’m encountering problems. It recomposes instantly in my case and doesn’t animate. I can’t find API to listen to the end of the animation. If it isn’t too much to ask could you provide a minimal sample of what you mean?
d

Doris Liu

10/29/2020, 7:50 PM
Without knowing the details of your use case, my advice is around preventing items from animating when added to the tree again:
Copy code
val items = remember { colors.map {
    Pair(it, mutableStateOf(false) /*initiallyVisible*/) } }
LazyColumnFor(
    items
) {
    AnimatedVisibility(true, initiallyVisible = it.second.value) {
        onDispose {
            it.second.value = true
        }
        // Children here
    }
}
a

allan.conda

10/30/2020, 9:38 AM
Thank you! That works
29 Views