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

Function onTouchMove

packages/shared/src/components/shell/ReadingDrawer.tsx:701–744  ·  view source on GitHub ↗
(event: TouchEvent)

Source from the content-addressed store, hash-verified

699 }
700 };
701 const onTouchMove = (event: TouchEvent) => {
702 const touch = event.touches[0];
703 if (!touch) {
704 return;
705 }
706 if (!held) {
707 if (!take) {
708 return;
709 }
710 const dx = touch.clientX - touchX;
711 const dy = touch.clientY - touchY;
712 if (dy === 0 && dx === 0) {
713 return;
714 }
715 if (
716 Math.abs(dx) >= Math.abs(dy) ||
717 (take === 'lift' && dy > 0) ||
718 (take === 'pull' && dy < 0)
719 ) {
720 take = null;
721 return;
722 }
723 held = {
724 from: take === 'lift' ? restY : current.full,
725 startY: touch.clientY,
726 samples: [],
727 };
728 styleMoving({ transition: null, 'will-change': 'transform' });
729 }
730 event.preventDefault();
731 const moved = held.startY - touch.clientY;
732 const y =
733 held.from < current.full
734 ? held.from + Math.min(current.full - held.from, Math.max(0, moved))
735 : current.full -
736 Math.min(current.full - current.card, Math.max(0, -moved));
737 held.samples.push([touch.clientY, performance.now()]);
738 if (held.samples.length > 5) {
739 held.samples.shift();
740 }
741 virtualY = y;
742 present(y);
743 onScroll();
744 };
745 const onTouchEnd = () => {
746 dragging = false;
747 take = null;

Callers

nothing calls this directly

Calls 5

styleMovingFunction · 0.85
presentFunction · 0.85
pushMethod · 0.80
nowMethod · 0.80
onScrollFunction · 0.70

Tested by

no test coverage detected