mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 11:42:22 +08:00
fix: 路由动画卡顿
This commit is contained in:
parent
4d020c9ed7
commit
f182706e0e
|
@ -4,26 +4,37 @@ import androidx.compose.animation.AnimatedContentTransitionScope
|
|||
import androidx.compose.animation.EnterTransition
|
||||
import androidx.compose.animation.ExitTransition
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInHorizontally
|
||||
import androidx.compose.animation.slideOutHorizontally
|
||||
import androidx.navigation.NavBackStackEntry
|
||||
import com.blankj.utilcode.util.ScreenUtils
|
||||
import com.ramcosta.composedestinations.spec.DestinationStyle
|
||||
|
||||
object ProfileTransitions : DestinationStyle.Animated {
|
||||
private const val durationMillis = 400
|
||||
override fun AnimatedContentTransitionScope<NavBackStackEntry>.enterTransition(): EnterTransition? {
|
||||
return slideInHorizontally(tween()) { it }
|
||||
return slideInHorizontally(
|
||||
initialOffsetX = { ScreenUtils.getScreenWidth() }, animationSpec = tween(durationMillis)
|
||||
)
|
||||
}
|
||||
|
||||
override fun AnimatedContentTransitionScope<NavBackStackEntry>.exitTransition(): ExitTransition? {
|
||||
return slideOutHorizontally(tween()) { -it } + fadeOut(tween())
|
||||
return slideOutHorizontally(
|
||||
targetOffsetX = { -ScreenUtils.getScreenWidth() / 2 },
|
||||
animationSpec = tween(durationMillis)
|
||||
)
|
||||
}
|
||||
|
||||
override fun AnimatedContentTransitionScope<NavBackStackEntry>.popEnterTransition(): EnterTransition? {
|
||||
return slideInHorizontally(tween()) { -it }
|
||||
return slideInHorizontally(
|
||||
initialOffsetX = { -ScreenUtils.getScreenWidth() / 2 },
|
||||
animationSpec = tween(durationMillis)
|
||||
)
|
||||
}
|
||||
|
||||
override fun AnimatedContentTransitionScope<NavBackStackEntry>.popExitTransition(): ExitTransition? {
|
||||
return slideOutHorizontally(tween()) { it }
|
||||
return slideOutHorizontally(
|
||||
targetOffsetX = { ScreenUtils.getScreenWidth() }, animationSpec = tween(durationMillis)
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user