Tgo1014
04/05/2022, 9:34 AMLazyRow
? The idea would be to manually controle the LazyRow
position to sync the scroll when dragging a pagerAlbert Chang
04/05/2022, 9:37 AMscrollToItem()
.Tgo1014
04/05/2022, 9:42 AMscrollToItem()
it moves directly but the idea is to sync the drags to move togetherAlbert Chang
04/05/2022, 9:46 AMLaunchedEffect
.Tgo1014
04/05/2022, 10:19 AMRow
using a Modifier.offset
but this doesn’t work with a LazyRow
.Albert Chang
04/05/2022, 10:23 AMTgo1014
04/05/2022, 10:26 AMRow
now.Tgo1014
04/05/2022, 10:27 AMTgo1014
04/05/2022, 10:28 AMModifier.offset
we can move the items according to the pager offset but this via modifier doesn’t work for LazyRow
. Any idea how to do it?Albert Chang
04/05/2022, 10:33 AMLaunchedEffect
.
Something like this should work:
LaunchedEffect(pagerState.currentPage, pagerState.currentPageOffest) {
lazyListState.scrollToItem(pagerState.currentPage, pagerState.currentPageOffest)
}
Tgo1014
04/05/2022, 10:36 AMscrollToItem
is Int
but pagerState.currentPageOffest
is Float, so a 0.5 offset would be 0 as intAlbert Chang
04/05/2022, 10:37 AMAlbert Chang
04/05/2022, 10:39 AMTgo1014
04/05/2022, 10:42 AMLaunchedEffect(state.currentPageOffset) {
scrollState.scrollToItem(
state.currentPage,
state.currentPageOffset.times(itemWidthPx).toInt()))
}
Thanks a lot for the help 🙌🏽