All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.arkivanov.decompose.extensions.compose.stack.animation.Scale.kt Maven / Gradle / Ivy

The newest version!
package com.arkivanov.decompose.extensions.compose.stack.animation

import androidx.compose.animation.core.FiniteAnimationSpec
import androidx.compose.animation.core.tween
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale

/**
 * A simple scaling animation. Front (above) children are scaling from [frontFactor] to 1.0.
 * Back (below) children are scaling from 1.0 to [backFactor].
 */
fun scale(
    animationSpec: FiniteAnimationSpec = tween(),
    frontFactor: Float = 1.15F,
    backFactor: Float = 0.95F,
): StackAnimator =
    stackAnimator(animationSpec = animationSpec) { factor, _, content ->
        content(
            Modifier.scale(
                if (factor >= 0F) {
                    factor * (frontFactor - 1F) + 1F
                } else {
                    factor * (1F - backFactor) + 1F
                }
            )
        )
    }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy