@@ -57,10 +57,7 @@ const UNSET = -1;
5757const DIRECTION_VERTICAL = - 1 ;
5858const DIRECTION_HORIZONTAL = 1 ;
5959
60- const SWIPE_VELOCITY_THRESHOLD_DEFAULT = 500 ;
61- const SWIPE_DISTANCE_THRESHOLD_DEFAULT = 60 ;
62-
63- const SWIPE_DISTANCE_MINIMUM = 5 ;
60+ const SWIPE_VELOCITY_IMPACT = 0.01 ;
6461
6562/**
6663 * The distance of touch start from the edge of the screen where the gesture will be recognized
@@ -70,7 +67,7 @@ const GESTURE_RESPONSE_DISTANCE_VERTICAL = 135;
7067
7168const {
7269 abs,
73- and ,
70+ add ,
7471 block,
7572 call,
7673 cond,
@@ -83,7 +80,6 @@ const {
8380 multiply,
8481 neq,
8582 onChange,
86- or,
8783 set,
8884 spring,
8985 sub,
@@ -245,6 +241,21 @@ export default class Card extends React.Component<Props> {
245241 ] ) ;
246242 } ;
247243
244+ private velocitySignum = cond (
245+ this . velocity ,
246+ divide ( abs ( this . velocity ) , this . velocity ) ,
247+ 0
248+ ) ;
249+ private extrapolatedPosition = add (
250+ this . gesture ,
251+ multiply (
252+ this . velocity ,
253+ this . velocity ,
254+ this . velocitySignum ,
255+ SWIPE_VELOCITY_IMPACT
256+ )
257+ ) ;
258+
248259 private exec = block ( [
249260 onChange (
250261 this . isClosing ,
@@ -335,22 +346,9 @@ export default class Card extends React.Component<Props> {
335346 set ( this . isSwiping , FALSE ) ,
336347 this . runTransition (
337348 cond (
338- or (
339- and (
340- greaterThan ( abs ( this . gesture ) , SWIPE_DISTANCE_MINIMUM ) ,
341- greaterThan (
342- abs ( this . velocity ) ,
343- SWIPE_VELOCITY_THRESHOLD_DEFAULT
344- )
345- ) ,
346- cond (
347- greaterThan (
348- abs ( this . gesture ) ,
349- SWIPE_DISTANCE_THRESHOLD_DEFAULT
350- ) ,
351- TRUE ,
352- FALSE
353- )
349+ greaterThan (
350+ abs ( this . extrapolatedPosition ) ,
351+ divide ( this . distance , 2 )
354352 ) ,
355353 cond (
356354 lessThan (
0 commit comments