Fix modal offset: use overflow:hidden instead of position:fixed on body

This commit is contained in:
2026-05-29 15:10:27 +03:00
parent c0be9f6eb4
commit 40d3729a78
2 changed files with 6 additions and 10 deletions

BIN
chrome_11eKLevsrE.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 KiB

View File

@@ -35,19 +35,15 @@ export default function CatModal({ catId, onClose }: CatModalProps) {
useEffect(() => { if (data?.cat) setLikeCount(data.cat.likes_count); }, [data]); useEffect(() => { if (data?.cat) setLikeCount(data.cat.likes_count); }, [data]);
useEffect(() => { useEffect(() => {
const scrollY = window.scrollY; const scrollY = window.scrollY;
document.documentElement.style.overflow = 'hidden';
document.documentElement.style.height = '100%';
document.body.style.overflow = 'hidden'; document.body.style.overflow = 'hidden';
document.body.style.position = 'fixed'; document.body.style.height = '100%';
document.body.style.top = `-${scrollY}px`;
document.body.style.left = '0';
document.body.style.right = '0';
document.body.style.width = '100%';
return () => { return () => {
document.documentElement.style.overflow = '';
document.documentElement.style.height = '';
document.body.style.overflow = ''; document.body.style.overflow = '';
document.body.style.position = ''; document.body.style.height = '';
document.body.style.top = '';
document.body.style.left = '';
document.body.style.right = '';
document.body.style.width = '';
window.scrollTo(0, scrollY); window.scrollTo(0, scrollY);
}; };
}, []); }, []);