some fiinal touches to swipe to delete

This commit is contained in:
corgifist 2025-08-03 14:34:35 +03:00
parent 096ff7dfec
commit 41dab6701c
2 changed files with 6 additions and 4 deletions

View File

@ -75,7 +75,8 @@ main {
.no-scroll { .no-scroll {
overflow: hidden; overflow: hidden;
height: 100vh; /* Optional, but often recommended for full-page scroll prevention */ height: 100%; /* Optional, but often recommended for full-page scroll prevention */
touch-action: none;
} }
.dark body { .dark body {

View File

@ -111,13 +111,14 @@ const SwipeToDelete: FC<SwipeToDeleteProps> = ({
isSticky || isSticky ||
velocity < -1000; velocity < -1000;
setAllowOverscroll(false); setAllowOverscroll(false);
document.body.classList.remove('no-scroll');
if (!shouldDelete) { if (!shouldDelete) {
content.current?.classList.add('ios-ease'); content.current?.classList.add('ios-ease');
text.current?.classList.add('ios-ease'); text.current?.classList.add('ios-ease');
document.body.classList.remove('no-scroll');
const textWidth = text.current ? text.current.getBoundingClientRect().width : 0; const textWidth = text.current ? text.current.getBoundingClientRect().width : 0;
if (((velocity < 0 && Math.abs(velocity) > 10) || dragX < -textWidth * 1.5 && velocity > 0) && text.current && (dragX === 0 ? Math.abs(velocityY) < 5 : true)) { if (((velocity < 0 && Math.abs(velocity) > 10) || dragX < -textWidth * 1.5 && velocity > 0) && text.current && (Math.abs(dragX) < 30 ? Math.abs(velocityY) < 5 : true)) {
setDragX(-textWidth * 1.5); setDragX(-textWidth * 1.5);
} else if (allowOverscroll && dragX > 0) { } else if (allowOverscroll && dragX > 0) {
setDragX(0); setDragX(0);
@ -201,7 +202,7 @@ const SwipeToDelete: FC<SwipeToDeleteProps> = ({
node.removeEventListener("mousemove", handleMouseMove); node.removeEventListener("mousemove", handleMouseMove);
node.removeEventListener("mouseup", handleEnd); node.removeEventListener("mouseup", handleEnd);
} }
}, [dragging, dragX, velocity, container]); }, [dragging, dragX, velocity, velocityY, container]);
const deleteTransform = isCollapsing const deleteTransform = isCollapsing
? `translateX(calc(${dragX}px + 5rem))` ? `translateX(calc(${dragX}px + 5rem))`