Hi Guys, Just wondering whether anyone could expla...
# compose
a
Hi Guys, Just wondering whether anyone could explain the
resistance
in:
Copy code
Modifier.swipeable(
    state = swipeableState,
    anchors = anchors,
    reverseDirection = false,
    thresholds = { _, _ -> FractionalThreshold(0.0f) },
    resistance = resistanceConfig(anchors.keys, 0f, 0f), // This right here...
    orientation = Orientation.Vertical,
)
No matter what value I set it in, I can’t seem to see the difference in the Swipe behavior
m
The resistance config is intended to provide proper value for
swipeableState.offset
when it goes beyond the bounds of the first/last anchor, based on resistanceConfig. Basically, resistanceConfig defines
swipeableState.offset = offsetCoercedToBounds + resisranceConfig.apply(swipeableState.overflow)
This means that resistance config decides how much to add to the
offset
when users drags beyond the possible bounds. You, as a developer of the swipeable component is responsible for making it visible on a screen in whatever shape and motion you want. Typically overflow is shown as a drawing effect (showing effect at the bound user drag beyond) or some offset (like pretending that you react on user dragging beyond the bound, but still snapping to the bound when user let go). The latter can be seen in the@experimental BackdropScaffold implementation in material. `
BackdropScaffold
provides resistance config, and then applies
swipeableState.offset
to it's front layer, and it automatically overflows a bit, so user sees that they are swiping beyond possible value and have a good, playful UX. It's not the easiest concept to grasp, so let me know if you have more questions about resistance 🙂
❤️ 1
🔝 1
a
Hi @matvei, Thank you so much. This explains alot. Really appreciate it. I'll try again and play with it some more maybe I'll have additional question by then. Again, thank you so much.
😊 1