commonMain.com.arkivanov.decompose.extensions.compose.stack.animation.Scale.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of extensions-compose Show documentation
Show all versions of extensions-compose Show documentation
Kotlin Multiplatform lifecycle-aware business logic components
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