0

I have LazyColumn that has verticalScroll modifier, and each child row also has a horizontal swipeable modifier. Everything actually works pretty well, but there is a bit of a problem when trying to scroll vertically -- if there's even a very slight horizontal movement, then the vertical scroll doesn't get triggered, and the horizontal swipe is triggered instead.

Is there any way to set a 'preference' for the vertical scroll, so that if there's any vertical movement, then the swipe shouldn't happen?

Edit: I should clarify that I'm using the swipeable modifier on each row for swipe-to-dismiss functionality. It's got some custom functionality, which is why I'm not using the SwipeToDismiss() composable, but I did try running it using SwipeToDismiss(), and it has the same problem

user496854
  • 6,461
  • 10
  • 47
  • 84

1 Answers1

0

I suggest using HorizontalPager() inside your verticalScroll Column.

Column(
    Modifier
        .verticalScroll(scrollState)
) {
    HorizontalPager(/*...*/)
}

It is smooth by default but you can even modify the gesture of it by changing flingBehavour as described here:

Swipe sensitivity for HorizontalPager in Compose

  • I'm not sure what you mean. How would a HorizontalPager fix the problem? as I said, I don't really have a problem with the swipeable modifier. Just a problem with the fact that it seems to be triggered with the slightest sideways movement when I'm trying to scroll up or down – user496854 Jul 25 '22 at 13:52
  • By using HorizontalPager, you can edit minFlingDistanceDp to change the sensitivity. but the initial sensitivity is ok too and HorizontalPager scrolls is not triggered with the slightest sideways movement. – Yamin Yazdanpanah Jul 26 '22 at 10:08
  • But won't that prevent the vertical scroll from initialing? Regardless of whether or not the the sideways movement is triggered, it would be consumed by the HorizontalPager. And that means that the vertical drag would be consumed as well, unless I'm understanding it wrong. – user496854 Jul 27 '22 at 02:42