google / accompanist

A collection of extension libraries for Jetpack Compose
https://google.github.io/accompanist
Apache License 2.0
7.37k stars 597 forks source link

Use current or target page for custom indicator #726

Closed DonnyRozendal closed 2 years ago

DonnyRozendal commented 2 years ago

I have made a custom pager indicator that I want to update by checking the current or target page. I have some issues with this:

pagerState.currentPage only updates after scrolling has finished. This is too late for what I need. pagerState.targetPage updates instantly (as soon as the next page is visible), but only when paging up. When it pages down, it updates when the scroll animation starts. This if fine but it is inconsistent.

Meanwhile, if I use OnPageChangeCallback from ViewPager2 and implement onPageSelected, the selected page always updates when the scroll animation starts (so when the user lifts his or her finger). Which is exactly what I need. This feature is present in targetPage, but only when paging down. Is this a bug?

Shouldn't the behavior overlap as much as possible with ViewPager2 ?

Version: 0.18.0

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.