material-motion-js
material-motion-js copied to clipboard
Prefer velocity over threshold for swipeable direction
Right now, there's not an easy way to get direction from a velocity - you have to drag an element by a certain distance. We should support this.
Maybe something like:
const whenEnded$ = recognitionState.whenIs(ENDED);
whenEnded$.rewriteToFirst(
drag$.velocityWhen(whenEnded$).hasMagnitudeOfAtLeast(3).toThreshold(),
drag$.slidingThreshold(56)
).subscribe(
direction
);
which would filter velocity to be of at least a particular magnitude, then convert it to a ThresholdSide, and fallback to positional detection if the velocity isn't high enough.