Skip to content

Commit

Permalink
revert the HorizontalPagerTransitionSample changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sarria committed Nov 26, 2021
1 parent ef08f36 commit de54275
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
Expand All @@ -40,6 +41,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
import androidx.compose.ui.util.lerp
import coil.annotation.ExperimentalCoilApi
Expand Down Expand Up @@ -133,13 +135,16 @@ fun HorizontalPagerWithOffsetTransition() {
.align(Alignment.BottomCenter)
.padding(16.dp)
// We add an offset lambda, to apply a light parallax effect
.graphicsLayer {
.offset {
// Calculate the offset for the current page from the
// scroll position
val pageOffset =
this@HorizontalPager.calculateCurrentOffsetForPage(page)
// Then use it as a multiplier to apply an offset
translationX = pageOffset * 64
IntOffset(
x = (36.dp * pageOffset).roundToPx(),
y = 0
)
}
)
}
Expand Down

0 comments on commit de54275

Please sign in to comment.