fix: make nav rail animate horizontally

This commit is contained in:
Harsh Shandilya 2023-05-28 13:54:37 +05:30
parent 3db05fb3b1
commit 1e5ae4048c
No known key found for this signature in database

View file

@ -11,8 +11,8 @@ import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.FastOutLinearInEasing import androidx.compose.animation.core.FastOutLinearInEasing
import androidx.compose.animation.core.LinearOutSlowInEasing import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.tween import androidx.compose.animation.core.tween
import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutVertically import androidx.compose.animation.slideOutHorizontally
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.NavigationRail import androidx.compose.material3.NavigationRail
@ -35,15 +35,15 @@ fun ClawNavigationRail(
AnimatedVisibility( AnimatedVisibility(
visible = isVisible, visible = isVisible,
enter = enter =
slideInVertically( slideInHorizontally(
// Enters by sliding up from offset 0 to fullHeight. // Enters by sliding in from offset -fullWidth to 0.
initialOffsetY = { fullHeight -> fullHeight }, initialOffsetX = { fullWidth -> -fullWidth },
animationSpec = tween(durationMillis = AnimationDuration, easing = LinearOutSlowInEasing), animationSpec = tween(durationMillis = AnimationDuration, easing = LinearOutSlowInEasing),
), ),
exit = exit =
slideOutVertically( slideOutHorizontally(
// Exits by sliding up from offset 0 to -fullHeight. // Exits by sliding out from offset 0 to -fullWidth.
targetOffsetY = { fullHeight -> fullHeight }, targetOffsetX = { fullWidth -> -fullWidth },
animationSpec = tween(durationMillis = AnimationDuration, easing = FastOutLinearInEasing), animationSpec = tween(durationMillis = AnimationDuration, easing = FastOutLinearInEasing),
), ),
modifier = Modifier, modifier = Modifier,