Skip to content

Commit 3783d7a

Browse files
committed
feat(blog): implement scroll locking for mobile TOC drawer
1 parent eb72bc1 commit 3783d7a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

apps/blog/web/src/components/mobile/MobileTOC.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ export const MobileTOC = () => {
1616
const [toc, setToc] = useState<TOCItem[]>([]);
1717
const [activeId, setActiveId] = useState<string>('');
1818

19+
// Body Scroll Lock
20+
useEffect(() => {
21+
if (isOpen) {
22+
document.body.style.overflow = 'hidden';
23+
} else {
24+
document.body.style.overflow = 'unset';
25+
}
26+
27+
return () => {
28+
document.body.style.overflow = 'unset';
29+
};
30+
}, [isOpen]);
31+
1932
useEffect(() => {
2033
// DOM이 렌더링된 후 헤더를 찾습니다.
2134
const updateToc = () => {

0 commit comments

Comments
 (0)