Skip to content

Commit

Permalink
Fix SharedAxis state being reversed
Browse files Browse the repository at this point in the history
  • Loading branch information
fornewid committed Mar 20, 2021
1 parent 6c0d1d0 commit d6511e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ fun <T> SharedAxis(
}
) { if (it == key) 1f else 0f }
val start = if (transition.targetState == key) {
if (forward) -slideDistance else slideDistance
} else {
if (forward) slideDistance else -slideDistance
} else {
if (forward) -slideDistance else slideDistance
}
val slide = lerp(start, 0.dp, slideFraction)
when (axis) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ import soup.material.transition.compose.SharedAxis
fun SharedAxisScreen() {
val axis = Axis.Y
val (forward, onForwardChanged) = remember {
mutableStateOf(true)
mutableStateOf(false)
}
SharedAxis(axis = axis, forward = forward, targetState = forward) { forward ->
Surface(
color = if (forward) {
MaterialTheme.colors.background
} else {
MaterialTheme.colors.primary
} else {
MaterialTheme.colors.background
},
modifier = Modifier
.fillMaxSize()
Expand All @@ -49,9 +49,9 @@ fun SharedAxisScreen() {
}
) {
if (forward) {
Text(text = "Hello Android!")
} else {
Text(text = "Hello SharedAxis!")
} else {
Text(text = "Hello Android!")
}
}
}
Expand Down

0 comments on commit d6511e5

Please sign in to comment.