Archie
09/12/2021, 5:05 PMresistance
in:
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 behaviormatvei
09/13/2021, 11:27 AMswipeableState.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 🙂Archie
09/13/2021, 11:31 AM