From 694ea85ed3d618a568270afe34473c19cb717e5e Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Tue, 27 Oct 2026 20:03:27 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=95=84=EC=9D=B4=ED=8F=B0=20=EC=82=AC?= =?UTF-8?q?=ED=8C=8C=EB=A6=AC=EC=97=90=EC=84=9C=20=EC=87=BC=EC=B8=A0?= =?UTF-8?q?=EB=A5=BC=20=EB=88=84=EB=A5=B4=EB=A9=B4=20=EC=B2=AB=20=EC=98=81?= =?UTF-8?q?=EC=83=81=EB=B6=80=ED=84=B0=20=EC=97=B4=EB=A6=AC=EB=8D=98=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=E2=80=94=20=EC=8B=9C=EC=9E=91=20=EC=98=81?= =?UTF-8?q?=EC=83=81=EC=9C=BC=EB=A1=9C=20=EC=98=AE=EA=B8=B4=20=EB=92=A4=20?= =?UTF-8?q?=ED=95=9C=20=EB=B2=88=20=EB=8D=94=20=EB=A7=9E=EC=B6=94=EA=B3=A0?= =?UTF-8?q?,=20=EC=98=AE=EA=B8=B0=EA=B8=B0=20=EC=A0=84=EC=97=94=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EB=8A=94=20=EC=B9=B8=20=EB=B3=80=ED=99=94?= =?UTF-8?q?=EB=A5=BC=20=EB=AC=B4=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/b/Shorts.tsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/src/b/Shorts.tsx b/frontend/src/b/Shorts.tsx index 9555a03..9655d67 100644 --- a/frontend/src/b/Shorts.tsx +++ b/frontend/src/b/Shorts.tsx @@ -184,14 +184,24 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta // 처음 한 번: 시작 영상으로 맞추고, 뒤 페이지 스크롤을 잠근다 const startRef = useRef(start) - useEffect(() => { - // scrollIntoView 는 바깥 칸까지 굴려 버튼 줄이 헤더 밑으로 숨으므로 목록만 옮긴다 + // 시작 영상으로 옮기기 전엔 보이는 칸이 바뀐 것으로 치지 않는다 (사파리는 처음 그릴 때 맨 위 칸이 먼저 보여 첫 영상으로 바뀌던 것) + const placed = useRef(false) + useLayoutEffect(() => { + // scrollIntoView 는 바깥 칸까지 굴려 버튼 줄이 헤더 밑으로 숨으므로 목록만 옮긴다. 사파리는 첫 그림 전에 옮긴 값을 되돌려 한 번 더 const box = list.current - if (box) box.scrollTop = box.clientHeight * startRef.current + const place = () => { + if (box) box.scrollTop = box.clientHeight * startRef.current + } + place() + const raf = requestAnimationFrame(() => { + place() + placed.current = true + }) const root = document.documentElement const before = root.style.overflow root.style.overflow = 'hidden' return () => { + cancelAnimationFrame(raf) root.style.overflow = before } }, []) @@ -207,6 +217,7 @@ function ShortsViewer({ items, start, onClose, onAt }: { items: ShortItem[]; sta if (!box) return const io = new IntersectionObserver( (entries) => { + if (!placed.current) return for (const e of entries) if (e.isIntersecting) setAt(Number((e.target as HTMLElement).dataset.i)) }, { root: box, threshold: 0.6 },