https://kotlinlang.org logo
t

Timo Drick

05/18/2020, 8:48 PM
How should touch drag gesture consumption work? I have following problem. I do have e.g.: A scrollable list and each element can be swiped. The problem now is that both gestures are detected at the same time. But i want to stop detecting the swipe gesture when the user is scrolling and vice versa. Here is a sample (A little bit simplified just using Vertical/HorizontalScroller to demonstrate the problem:
Copy code
VerticalScroller() {
    Column(Modifier.padding(10.dp)) {
        for (i in 0..50) {
            Box(backgroundColor = if (i % 2 == 0) Color.LightGray else Color.Gray) {
                HorizontalScroller(()) {
                    Row {
                        for (j in 0..10) {
                            Text("i: $i element $j", Modifier.padding(20.dp))
                        }
                    }
                }
            }
        }
    }
}
m

matvei

05/19/2020, 11:16 AM
Hey. This is called orientation locking and it should be implemented by default in scrollers, but it's not there for now, still to be implemented 🙂
t

Timo Drick

05/19/2020, 4:16 PM
Ok thanks. Maybe it would also be helpfull if the Vertical/HorizontalScroller could expose a scrolling state. So it is possible to know if the user is currently scrolling.
m

matvei

05/19/2020, 5:09 PM
Thanks for suggestion. I'm not sure that would be the right way to solve this particular problem, but feature request is definitely feasible. Please, file a feature requiest!
t

Timo Drick

05/19/2020, 6:03 PM
OK. Btw. i tried to implement scroll detection myself by modifieng the Scroller and noticed that the Modifier.scrollable callback: onScrollStopped is called after fling is ready. But when the drag/scroll is canceled onScrollStopped is never called. So with Modifier.scrollable it is not possible to monitor scrolling reliable.
3 Views