Timo Drick

    Timo Drick

    2 years ago
    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:
    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))
                            }
                        }
                    }
                }
            }
        }
    }
    matvei

    matvei

    2 years ago
    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 🙂
    Timo Drick

    Timo Drick

    2 years ago
    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.
    matvei

    matvei

    2 years ago
    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!
    Timo Drick

    Timo Drick

    2 years ago
    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.