Hi, I want to make a carousel that swipes the imag...
# compose
a
Hi, I want to make a carousel that swipes the images in this fashion… I have a scrollable row and I was able to set the correct width and spacing for each item, but I don’t know how to observe the scroll direction in order to calculate the Y translation… is there a way to observe such event/s?
f
I think @Leland Richardson [G] recreated such a carousel once in compose in a stream
a
Yep, the dogfooding series I think? But it was with an old version of Compose... I looked up to the 3rd video though, idk if in the subsequent videos he treats this use case...
o
Also you can use Pager implementation from Jetcaster sample app https://github.com/android/compose-samples/blob/de4d7b8f3ff9d09a600b34da84c0283567[…]Jetcaster/app/src/main/java/com/example/jetcaster/util/Pager.kt In
pageContent
lambda you have access to the
PagerScope
where you can use
page
/
currentPage
/
currentPageOffset
to calculate the appropriate Y translation for each item.
a
oh didn’t know that such sample app exists… going to look at it, thanks!
👍 1