Thread
#compose
    a

    allan.conda

    1 year ago
    Is it possible to make the Composable not clip within its bounds when using AnimatedVisibility? slideInVertically() seems unusable due to the clipping
    Doris Liu

    Doris Liu

    1 year ago
    slideInVertically
    shouldn't clip, but its parent may choose to clip it. Which composable are you seeing the clipping in?
    a

    allan.conda

    1 year ago
    ah. I’m trying to animate my LazyColumn items
    Doris Liu

    Doris Liu

    1 year ago
    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

    1 year ago
    Thanks! I’m going to see what I can find and do that if I can’t otherwise.
    Do you know how I can make AnimatedVisibility only run once on LazyColumn(For) ? It seems to work fine for ScrollableColumn, but for LazyLoading it gets animated when the composable appears again in view.
    Ok I guess I can file it as a bug and it can either be considered or set to won’t fix
    Doris Liu

    Doris Liu

    1 year ago
    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

    1 year ago
    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?
    Doris Liu

    Doris Liu

    1 year ago
    Without knowing the details of your use case, my advice is around preventing items from animating when added to the tree again:
    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

    1 year ago
    Thank you! That works