Fix modal scroll shift: add width:100% to body lock
This commit is contained in:
@@ -35,17 +35,19 @@ 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.body.style.overflow = 'hidden';
|
||||||
document.body.style.position = 'fixed';
|
document.body.style.position = 'fixed';
|
||||||
document.body.style.top = `-${scrollY}px`;
|
document.body.style.top = `-${scrollY}px`;
|
||||||
document.body.style.left = '0';
|
document.body.style.left = '0';
|
||||||
document.body.style.right = '0';
|
document.body.style.right = '0';
|
||||||
document.body.style.overflow = 'hidden';
|
document.body.style.width = '100%';
|
||||||
return () => {
|
return () => {
|
||||||
|
document.body.style.overflow = '';
|
||||||
document.body.style.position = '';
|
document.body.style.position = '';
|
||||||
document.body.style.top = '';
|
document.body.style.top = '';
|
||||||
document.body.style.left = '';
|
document.body.style.left = '';
|
||||||
document.body.style.right = '';
|
document.body.style.right = '';
|
||||||
document.body.style.overflow = '';
|
document.body.style.width = '';
|
||||||
window.scrollTo(0, scrollY);
|
window.scrollTo(0, scrollY);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user