MCPcopy Create free account
hub / github.com/ionic-team/ionic-framework / onEnd

Function onEnd

core/src/utils/gesture/swipe-back.ts:59–77  ·  view source on GitHub ↗
(detail: GestureDetail)

Source from the content-addressed store, hash-verified

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,

Callers 1

pointerUpFunction · 0.70

Calls 3

clampFunction · 0.90
getDeltaXFunction · 0.85
getVelocityXFunction · 0.85

Tested by

no test coverage detected