Matija Sokol
03/20/2024, 9:05 AMPager
? In my case, Pager
item contains LazyColumn
so there is horizontal Pager swipe and vertical LazyColumn scroll conflict. This is common problem which is easy to fix in View system by overriding touch slop
property in ViewPager
. Is same possible in Compose?Albert Chang
03/20/2024, 11:56 AMLocalViewConfiguration
with touchSlop
overridden.Matija Sokol
03/20/2024, 11:58 AMval viewConfiguration = LocalViewConfiguration.current
val updatedViewConfiguration = remember(viewConfiguration) {
object : ViewConfiguration by viewConfiguration {
override val touchSlop: Float
get() = viewConfiguration.touchSlop * 3
}
}
Box(modifier = Modifier.fillMaxSize()) {
CompositionLocalProvider(
LocalViewConfiguration provides updatedViewConfiguration,
) {
Pager(...)
}
}
And then override it again inside page where LazyColumn
is defined:
val viewConfiguration = LocalViewConfiguration.current
val updatedViewConfiguration = remember(viewConfiguration) {
object : ViewConfiguration by viewConfiguration {
override val touchSlop: Float
get() = 5f // decrease for higher sensitivity
}
}
HorizontalPager(
state = pagerState,
key = ...,
) { index ->
CompositionLocalProvider(
LocalViewConfiguration provides updatedViewConfiguration,
) {
LazyColumn(...)
}
}
Albert Chang
03/20/2024, 12:48 PMMatija Sokol
03/21/2024, 8:55 AMPager
and not LazyColumn
scroll. That is a reason why I want to decrease Pager
sensitivity.
But with this approach (using CompositionLocalProvider
), when I decrease Pager
sensitivity, I also change sensitivity for LazyColumn
since LazyColumn
is a child of a Pager
item.
Do you have any suggestion to fix that?Albert Chang
03/21/2024, 8:57 AMलातों वाला भूत
03/23/2024, 1:05 AMMatija Sokol
04/23/2024, 8:16 AM