Using accompanist-pager
version 0.25.1
, animateScrollToPage()
doesn't seem to scroll all the way to make the next page fully visible, the previous page is still shown. The non animated version scrollToPage()
seems to work fine however. Am I missing some additional params ?
@ExperimentalPagerApi
@Composable
fun MyPager() {
val pagerState = rememberPagerState()
HorizontalPager(
count = 10,
state = pagerState
) { pagerIndex ->
Box(
modifier = Modifier
.fillMaxWidth()
.height(150.dp)
.background(if (pagerIndex.mod(2) == 0) Color.Cyan else Color.Red)
)
}
with(pagerState) {
LaunchedEffect(key1 = currentPage) {
launch {
delay(10000)
animateScrollToPage(
page = (currentPage + 1).mod(pageCount)
)
}
}
}
}