Hi :smile: I added AnimatedVisibility to each ite...
# compose
t
Hi 😄 I added AnimatedVisibility to each item in a lazyColumn. I want to invoke an action at the end of tween animation. I can add listener to 
animateColorAsState
 ; however,  this causes to take action while tween animation is running. Is there any way to understand  when the exit animation completed?
Copy code
LazyColumn {
    itemsIndexed(questionsData.questions) { index, item ->
        if (index == 0)
            Spacer(
                modifier = Modifier
                    .height(56.dp)
                    .fillMaxWidth()
            )
        androidx.compose.animation.AnimatedVisibility(
            visible = item.selectedAnswer.isNullOrEmpty(),
            enter = expandHorizontally(),
            exit = shrinkHorizontally(
                animationSpec = tween(
                    durationMillis = 500,
                )
            )
        ) {
            val color: Color by animateColorAsState(
                if (item.selectedAnswer.isNullOrEmpty()) placeHolderColor else secondaryColor,
                finishedListener = {
                    if (progress == 1f) {
                        backAction()
                    }
                }
            )
            QuestionTitleView(
                item.question,
                onQuestionAnswerAction = {
                    onQuestionAnswerAction(item)
                },
                backgroundColor = color
            )
        }
    }
}
c
Possibly xy problem? What are you trying to do? Animate items as they come onto the screen. If so, i recall theres a specific api for that? If not, then sorry for not helping.
d
To observe the state of
AnimatedVisibility
consider using the AnimatedVisibility API that accepts a
MutableTransitionState
, you can then check its
currentState
against
targetState
for when the animation has finished. Note that once the animation has finished exiting, the
content
block of the
AnimatedVisibility
will be skipped altogether. In other words, you won't be able to trigger animations in the child of AnimatedVisibility once it finishes exiting