From c52cd12b3d83a798b2ba5b3d152c489fef4cc952 Mon Sep 17 00:00:00 2001 From: corgifist Date: Sat, 2 Aug 2025 16:38:58 +0300 Subject: [PATCH] changed some swipe to delete settings --- src/app/(dashboard)/layout.tsx | 2 +- src/app/(dashboard)/page.tsx | 10 +++---- src/app/(editor)/editor/[uuid]/page.tsx | 2 +- .../swipe-to-delete/SwipeToDelete.tsx | 27 +++++-------------- src/components/swipe-to-delete/styles.css | 15 +++++------ 5 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/app/(dashboard)/layout.tsx b/src/app/(dashboard)/layout.tsx index 84c4523..f3be314 100644 --- a/src/app/(dashboard)/layout.tsx +++ b/src/app/(dashboard)/layout.tsx @@ -11,7 +11,7 @@ export default async function RootLayout({ return ( -
+
{children} diff --git a/src/app/(dashboard)/page.tsx b/src/app/(dashboard)/page.tsx index 7d30017..c066f0c 100644 --- a/src/app/(dashboard)/page.tsx +++ b/src/app/(dashboard)/page.tsx @@ -451,9 +451,9 @@ const ProjectContainer = ({ ); return isMobile ? ( -
- deleteProject(project.uuid)} transitionDuration={200} height={210.38} deleteThreshold={45}> -
+
+ deleteProject(project.uuid)} transitionDuration={200} deleteThreshold={50}> +
{projectComponent}
@@ -517,7 +517,7 @@ export default function Home(): ReactNode { return ( -
+
@@ -602,7 +602,7 @@ export default function Home(): ReactNode {
-
+
{filteredProjects && filteredProjects.map((project) => )}
{(filteredProjects != undefined && filteredProjects.length == 0) && ( diff --git a/src/app/(editor)/editor/[uuid]/page.tsx b/src/app/(editor)/editor/[uuid]/page.tsx index 6c2b294..fb41a06 100644 --- a/src/app/(editor)/editor/[uuid]/page.tsx +++ b/src/app/(editor)/editor/[uuid]/page.tsx @@ -73,5 +73,5 @@ export default function Editor() {
- ) : <>; + ) : <>Project is invalid (or is it?); } \ No newline at end of file diff --git a/src/components/swipe-to-delete/SwipeToDelete.tsx b/src/components/swipe-to-delete/SwipeToDelete.tsx index c1c2bb6..40f8dd9 100644 --- a/src/components/swipe-to-delete/SwipeToDelete.tsx +++ b/src/components/swipe-to-delete/SwipeToDelete.tsx @@ -90,11 +90,15 @@ export const SwipeToDelete = ({ startTouchPosition.current = cursorPosition(event); initTranslate.current = translate; setTouching(true); - if (!deleting) setDeleting(true); + setDeleting(true); }, [disabled, touching, translate, deleting, setDeleting] ); + useEffect(() => { + // setDeleting(touching); + }, [touching]); + useEffect(() => { const root = container.current; root?.style.setProperty("--rstdiHeight", height + "px"); @@ -122,9 +126,8 @@ export const SwipeToDelete = ({ if (rtl && cursorPosition(event) < startTouchPosition.current - initTranslate.current) return setTranslate(0); setTranslate(cursorPosition(event) - startTouchPosition.current + initTranslate.current); - if (!deleting) setDeleting(true); }, - [rtl, touching, deleting, setDeleting] + [rtl, touching] ); @@ -181,7 +184,7 @@ export const SwipeToDelete = ({ setTranslate(() => (rtl ? 1 : -1) * deleteWidth); } setTouching(() => false); - if (deleting) setDeleting(false); + setDeleting(false); if (deleteWithoutConfirm) onDeleteClick(); }, [containerWidth, deleteWidth, deleteWithoutConfirmThreshold, onDeleteClick, rtl, translate, deleting, setDeleting] @@ -207,22 +210,6 @@ export const SwipeToDelete = ({ }; }, [onMouseMove, onMouseUp, onTouchMove, touching]); - // disabling scrolling when swiping to delete - useEffect(() => { - const handleScroll = (e: Event) => { - if (deleting) { - e.preventDefault(); - document.body.style.overflow = 'hidden'; - } else { - document.body.style.overflow = 'auto'; - } - }; - - window.addEventListener('scroll', handleScroll); - - return () => window.removeEventListener('scroll', handleScroll); - }, [deleting]); - return (
diff --git a/src/components/swipe-to-delete/styles.css b/src/components/swipe-to-delete/styles.css index 1a7bd39..d8fb7f2 100644 --- a/src/components/swipe-to-delete/styles.css +++ b/src/components/swipe-to-delete/styles.css @@ -13,11 +13,10 @@ width: auto; position: relative; box-sizing: border-box; - overflow: hidden; height: 100%; max-height: 100%; - overflow: hidden; overscroll-behavior: none; + overflow: hidden; } .rstdi *, @@ -27,7 +26,7 @@ } .rstdi.deleting { - transition: all var(--rstdiTransitionDuration) ease-out; + transition: all var(--rstdiTransitionDuration) cubic-bezier(0.33, 1, 0.68, 1); opacity: 0; max-height: 0; } @@ -40,7 +39,7 @@ } .rstdi .content.transition { - transition: all var(--rstdiTransitionDuration) ease-out; + transition: all var(--rstdiTransitionDuration) cubic-bezier(0.33, 1, 0.68, 1); } .rstdi .content.deleting { @@ -48,14 +47,14 @@ width: auto; position: relative; transform: translateX(-100%); - transition: all var(--rstdiTransitionDuration) ease-out; + transition: all var(--rstdiTransitionDuration) cubic-bezier(0.33, 1, 0.68, 1); } .rstdi .delete { position: absolute; right: 0; - margin-top: 1px; - height: calc(100% - 3px); + margin-top: 0px; + height: 100%; width: 100%; top: 0; background: var(--rstdiDeleteColor); @@ -67,7 +66,7 @@ .rstdi .delete button { width: var(--rstdiDeleteWidth); - transition: transform var(--rstdiTransitionDuration) ease-out; + transition: transform var(--rstdiTransitionDuration) cubic-bezier(0.33, 1, 0.68, 1); transform: translateX(var(--rstdiButtonMarginLeft)); text-align: center; height: 100%;