https://kotlinlang.org logo
Title
s

ste

07/05/2022, 3:21 PM
How can I disable
HorizontalPager
scroll (via
userScrollEnabled
) when the user started a
LazyColumn
scroll (and vice versa)? Do I need to write a complex
NestedScrollConnection
?
c

chatterInDaSkull

07/05/2022, 7:38 PM
Are you using the accompanist
HorizontalPager
?
s

ste

07/05/2022, 7:56 PM
Yes
c

chatterInDaSkull

07/05/2022, 7:58 PM
For a consistent user experience, I would disable horizontal scrolling altogether. Having two directions of scrolls in the same page is not a good ux
s

ste

07/05/2022, 8:12 PM
Material design guidelines don't say so (https:/material.io/components/tabs#behavior), and many users already asked for this feature. Many apps (made with the traditional Android `View`s) have the desired behavior - and I could achieve it as well using my own
Pager
... Of course, the UX I showed is terrible.
c

chatterInDaSkull

07/05/2022, 10:16 PM
val listState = rememberLazyListState()
https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/LazyListState#isScrollInProgress() This should tell you whether someone is scrolling around vertically, you can simple change the value for
userScrollEnabled
based on it
s

ste

07/06/2022, 7:33 AM
@chatterInDaSkull I did that already but it's not enough. The very first drag will still dispatch X changes to the
HorizontalPager
and Y changes to the
LazyColumn
I think it's due to how
HorizontalPager
detect drags: it uses
scrollable
instead of
draggable
(my
Pager
that doesn't have this problem uses
detectHorizontalDragGestures
)
PS: I can't really use my
Pager
because it's not lazy. I started re-implementing it using a
LazyLayout
yesterday
c

chatterInDaSkull

07/06/2022, 7:49 AM
Might be worth writing a bug report or a feature request for accompanist itself
s

ste

07/06/2022, 12:19 PM
I implemented my own pager and got an acceptable result:
c

chatterInDaSkull

07/06/2022, 4:31 PM
you should share your snippet so people can use it in the future