@Albert Chang Yeah I experimented with this but it doesn’t emit page changes continuously. I opened an issue here https://github.com/google/accompanist/issues/313 but it seems this is more suited to swiping a single item at a time
p
patrick
04/12/2021, 7:48 AM
@Jason Ankers if it’s just about the highlighting of the middle item you can do that without needing to get real-time updates of the selected position. I had a similar use-case (number wheel that repeats itself / infinite) and it works with the pager but is quite ugly since the fling is really slow as the pager tries to snap to every single item basically.
You can use something like the following within the PagerScope:
Copy code
val absolutePageOffset =
calculateCurrentOffsetForPage(position).absoluteValue.coerceIn(0f, 1f)
val textColor = androidx.compose.ui.graphics.lerp(
MaterialTheme.colors.primary.copy(alpha = ContentAlpha.medium),
MaterialTheme.colors.primary,
1 - absolutePageOffset
)
j
Jason Ankers
04/12/2021, 7:54 AM
@patrick Thanks that definitely helps with the highlighting. I think the main issue with using pager is we basically lose the scroll inertia so it feels a bit janky