k

    Kazemihabib1996

    2 years ago
    What happens when we
    return the amount of the [dragDistance] that has been consumed.
    ? I'm trying to understand the below sentence
    consume all delta no matter the bounds to avoid nested dragging (as example)
    https://android.googlesource.com/platform/frameworks/support/+/androidx-master-dev/ui/ui-foundation/samples/src/main/java/androidx/ui/foundation/samples/DraggableSamples.kt#100
    matvei

    matvei

    2 years ago
    Hello! Good question 🙂
    So in dragging in compose we have a build-in nested dradding via delta consumption. It means that every draggable/ scrollable thing should consume as much as it needs and report the amount consumed, so underlying infrastructure redirect this delta on the parent above the hierarchy. This enables nested dragging "by default", because if your draggable thing hits the bound and stops consuming deltas (returns 0), some parent, which is also scrollable, will start scrolling. In the example we're developing seekbar (slider-like) component and we don't want to participate in the nested dragging (we don't want to open navigation drawer when you hit the bound on the horizontal slider)
    Agree that documentaiton and example are quite confusing, will try to come up with something better. Hit me up with any questions that you have please 🙂
    k

    Kazemihabib1996

    2 years ago
    @matvei Thank you, for your nice explanation based on your scroller example, I write the below code, and understood it completely
    HorizontalScroller {
       Row {
         repeat(10) { Text("Text $it") }
    
          DraggableSample()
          repeat(10) { Text("Text $it") }
        }
    }
    matvei

    matvei

    2 years ago
    Yay! Happy to help and explain!