Hi everyone, I need some help with an issue I'm fa...
# compose
l
Hi everyone, I need some help with an issue I'm facing. I’ve implemented a Horizontal Pager where each page displays an image. When I click on the bottom bar to navigate to a specific page, I use
pagerState.animateScrollToPage
. It works perfectly when moving from page 0 to page 2, with the animation functioning smoothly. However, when navigating from page 0 to page 3 or from page 3 to page 0, the animation skips intermediate pages, making it look strange and unnatural. Here’s a video to better illustrate the issue: https://www.youtube.com/shorts/U5ZboJKc1So. If anyone has any suggestions on how to fix this, I’d really appreciate it. Thanks!
k
@Lucas Prioste I think this happens because when an item is far off from another, on scroll to page pager moves to the nearest item before animating to the target page If the number of items/pages is fixed and small you could try setting
beyondBoundsPageCount
to the total count
👍 1
l
Thanks for your response! I had tried that, but the problem remained. Instead, I used
animateScrollBy
and calculated the exact scroll distance needed for each page, and now it’s working fine. 🚀
🙌🏾 1