I have a nested HorizontalPager like
HorizontalPager(
count = list.size
) {
HorizontalPager(
count = list2.size
) {
//items
}
}
is there any way to disable horizontal scrolling in parents pager, but enable in childrens.
This solution disables scroll in all childs views and it isn't what i need
private val HorizontalScrollConsumer = object : NestedScrollConnection {
override fun onPreScroll(available: Offset, source: NestedScrollSource) = available.copy(y = 0f)
override suspend fun onPreFling(available: Velocity) = available.copy(y = 0f)
}
fun Modifier.disabledHorizontalPointerInputScroll(disabled: Boolean = true) =
if (disabled) this.nestedScroll(HorizontalScrollConsumer) else this
Pass this argument in HorizontalPager
userScrollEnabled = false
HorizontalPager(
...
userScrollEnabled = false
...
) {
// Your Code...
}
Note: By default userScrollEnabled is true, if we need to disable it, just pass this argument with false in HorizontalPager
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With