This message was deleted.
# compose
s
This message was deleted.
z
This code results in 1 recomposition:
Copy code
val transition = updateTransition(
    targetState = BackStackState(
        key = key,
        size = stack.size
    ),
    label = null
)

transition.AnimatedContent(
    contentKey = BackStackState::key,
    transitionSpec = {
        contentTransform(
            forward = targetState.size >= initialState.size
        )
    },
    content = { (key) ->
        val render = renders.getValue(key)

        stateKeeper.SavedState(
            key = key,
            content = {
                Render(render)
            }
        )
    }
)

    private fun contentTransform(
        forward: Boolean
    ): ContentTransform {
        return when {
            forward -> {
                ContentTransform(
                    targetContentEnter = slideInVertically(
                        initialOffsetY = { height -> height },
                        animationSpec = SlideSpec
                    ),
                    initialContentExit = fadeOut(
                        animationSpec = FloatSpec
                    ),
                    targetContentZIndex = 1f,
                    sizeTransform = null
                )
            }
            else -> {
                ContentTransform(
                    targetContentEnter = fadeIn(
                        animationSpec = FloatSpec
                    ),
                    initialContentExit = slideOutVertically(
                        targetOffsetY = { height -> height },
                        animationSpec = SlideSpec
                    ),
                    targetContentZIndex = -1f,
                    sizeTransform = null
                )
            }
        }
    }
And this results in 4 recompositions:
Copy code
val transition = updateTransition(
    targetState = MultiPaneState(
        key = key,
        mode = mode
    ),
    label = null
)

transition.AnimatedContent(
    contentKey = MultiPaneState::key,
    transitionSpec = {
        contentTransform(
            forward = targetState.mode >= initialState.mode,
        )
    },
    content = { (key) ->
        val render = renders.getValue(key)

        stateKeeper.SavedState(
            key = key,
            content = {
                Render(render)
            }
        )
    }
)

 private fun contentTransform(
        forward: Boolean
    ): ContentTransform {
        return when {
            forward -> {
                ContentTransform(
                    targetContentEnter = slideInHorizontally(
                        initialOffsetX = { width -> width },
                        animationSpec = SlideSpec
                    ),
                    initialContentExit = slideOutHorizontally(
                        targetOffsetX = { width -> -width },
                        animationSpec = SlideSpec
                    ),
                    targetContentZIndex = 1f,
                    sizeTransform = null
                )
            }
            else -> {
                ContentTransform(
                    targetContentEnter = slideInHorizontally(
                        initialOffsetX = { width -> -width },
                        animationSpec = SlideSpec
                    ),
                    initialContentExit = slideOutHorizontally(
                        targetOffsetX = { width -> width },
                        animationSpec = SlideSpec
                    ),
                    targetContentZIndex = -1f,
                    sizeTransform = null
                )
            }
        }
    }
z
did you mean to ask a question?
z
Hey! Sorry, I realized how general my question was and that the issue was probably elsewhere.