MCPcopy Create free account
hub / github.com/dailydotdev/apps / onTouchEnd

Function onTouchEnd

packages/shared/src/components/shell/sheetDrag.ts:209–243  ·  view source on GitHub ↗
(event: TouchEvent)

Source from the content-addressed store, hash-verified

207 };
208
209 const onTouchEnd = (event: TouchEvent) => {
210 if (!tracking) {
211 return;
212 }
213 tracking = false;
214 if (!dragging) {
215 return;
216 }
217 dragging = false;
218
219 const base = startedExpanded ? fullHeight : restHeight;
220 const wanted = base - dy;
221 const below = restHeight - wanted;
222 const overallVelocity = dy / Math.max(1, event.timeStamp - startTime);
223
224 if (
225 below > 0 &&
226 (below > restHeight / 3 || velocity > flick || overallVelocity > flick)
227 ) {
228 settle();
229 style.setProperty('--sheet-drag', `${Math.max(0, below)}px`);
230 onDismiss(event);
231 return;
232 }
233
234 if (velocity < upFlick) {
235 settleTo(true);
236 return;
237 }
238 if (velocity > flick) {
239 settleTo(false);
240 return;
241 }
242 settleTo(wanted > (restHeight + fullHeight) / 2);
243 };
244
245 // Once the sheet has entered, its enter animation is over for good; a
246 // drag that removes and restores the panel's state must not replay it.

Callers

nothing calls this directly

Calls 3

settleToFunction · 0.85
settleFunction · 0.70
onDismissFunction · 0.50

Tested by

no test coverage detected