Skip to content

Commit 75a2456

Browse files
authored
improve: ScrollLocker call related (#227)
1 parent 9238fb6 commit 75a2456

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Dialog/index.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ export default function Dialog(props: IDialogChildProps) {
136136
useEffect(() => {
137137
if (visible) {
138138
setAnimatedVisible(true);
139-
scrollLocker?.lock();
140-
141-
return scrollLocker?.unLock;
142139
}
143140
return () => {};
144141
}, [visible]);
@@ -151,6 +148,14 @@ export default function Dialog(props: IDialogChildProps) {
151148
[],
152149
);
153150

151+
useEffect(() => {
152+
if (animatedVisible) {
153+
scrollLocker?.lock();
154+
return scrollLocker?.unLock;
155+
}
156+
return () => {};
157+
}, [animatedVisible]);
158+
154159
// ========================= Render =========================
155160
return (
156161
<div className={`${prefixCls}-root`}>

0 commit comments

Comments
 (0)