(detail: GestureDetail)
| 57 | }; |
| 58 | |
| 59 | const onEnd = (detail: GestureDetail) => { |
| 60 | // the swipe back gesture has ended |
| 61 | const delta = getDeltaX(detail); |
| 62 | const width = win.innerWidth; |
| 63 | const stepValue = delta / width; |
| 64 | const velocity = getVelocityX(detail); |
| 65 | const z = width / 2.0; |
| 66 | const shouldComplete = velocity >= 0 && (velocity > 0.2 || delta > z); |
| 67 | |
| 68 | const missing = shouldComplete ? 1 - stepValue : stepValue; |
| 69 | const missingDistance = missing * width; |
| 70 | let realDur = 0; |
| 71 | if (missingDistance > 5) { |
| 72 | const dur = missingDistance / Math.abs(velocity); |
| 73 | realDur = Math.min(dur, 540); |
| 74 | } |
| 75 | |
| 76 | onEndHandler(shouldComplete, stepValue <= 0 ? 0.01 : clamp(0, stepValue, 0.9999), realDur); |
| 77 | }; |
| 78 | |
| 79 | return createGesture({ |
| 80 | el, |
no test coverage detected