From a64866fdf5bdbb3c2eae9e96929132a42fdd2b52 Mon Sep 17 00:00:00 2001 From: ner Date: Thu, 4 Apr 2024 12:31:19 +0300 Subject: [PATCH] fix: pull to close --- components/ui/dialog.tsx | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/components/ui/dialog.tsx b/components/ui/dialog.tsx index f8dd777..ac8de2b 100644 --- a/components/ui/dialog.tsx +++ b/components/ui/dialog.tsx @@ -52,7 +52,6 @@ const DialogContent = React.forwardRef< const threshold = 150; const { clientY } = event.touches[0]; - const content = contentRef.current; const overlay = overlayRef.current; const wrapper = wrapperRef.current; const diff = clientY - position.current; @@ -62,12 +61,8 @@ const DialogContent = React.forwardRef< close.current = canBeClosed && isTop; - if (isTop && content && wrapper) { - const opacity = `${1 - (diff * 100) / threshold / 100}`; - - content.style.opacity = opacity; - wrapper.style.opacity = opacity; - content.style.transform = `translate(-50%, ${diff}px)`; + if (isTop && wrapper) { + wrapper.style.opacity = `${1 - (diff * 100) / threshold / 100}`; } if (top <= 0 && delta.current < 0 && canBeClosed) onClose?.(); @@ -78,11 +73,9 @@ const DialogContent = React.forwardRef< close.current = false; - if (!contentRef.current || !wrapperRef.current) return; + if (!wrapperRef.current) return; - contentRef.current.style.opacity = '1'; wrapperRef.current.style.opacity = '1'; - contentRef.current.style.transform = 'translate(-50%, 0)'; }; const handleRef = (element: HTMLDivElement | null) => {