feat: add custom modal for lock body scroller

This commit is contained in:
jialin
2025-02-23 13:32:03 +08:00
parent c6cc5810ca
commit f8c7f88ac2
4 changed files with 31 additions and 9 deletions
+19
View File
@@ -0,0 +1,19 @@
import useBodyScroll from '@/hooks/use-body-scroll';
import { Modal, type ModalProps } from 'antd';
import React from 'react';
const ScrollerModal = (props: ModalProps) => {
const { saveScrollHeight, restoreScrollHeight } = useBodyScroll();
React.useEffect(() => {
if (props.open) {
saveScrollHeight();
} else {
restoreScrollHeight();
}
}, [props.open]);
return <Modal {...props} />;
};
export default ScrollerModal;