material-motion-js icon indicating copy to clipboard operation
material-motion-js copied to clipboard

Prefer velocity over threshold for swipeable direction

Open appsforartists opened this issue 8 years ago • 0 comments

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.

appsforartists avatar May 18 '17 22:05 appsforartists