|
@@ -12,8 +12,10 @@ export default function CommonModal({
|
|
|
isOpen,
|
|
isOpen,
|
|
|
destroyOnClose = false,
|
|
destroyOnClose = false,
|
|
|
contentClassName,
|
|
contentClassName,
|
|
|
|
|
+ contentStyle = {},
|
|
|
clickOutsideClose,
|
|
clickOutsideClose,
|
|
|
onClose,
|
|
onClose,
|
|
|
|
|
+ animationEndCallback = () => {},
|
|
|
header,
|
|
header,
|
|
|
body,
|
|
body,
|
|
|
footer
|
|
footer
|
|
@@ -21,8 +23,10 @@ export default function CommonModal({
|
|
|
isOpen: boolean;
|
|
isOpen: boolean;
|
|
|
destroyOnClose?: boolean;
|
|
destroyOnClose?: boolean;
|
|
|
contentClassName?: string;
|
|
contentClassName?: string;
|
|
|
|
|
+ contentStyle?: React.CSSProperties;
|
|
|
clickOutsideClose?: boolean;
|
|
clickOutsideClose?: boolean;
|
|
|
onClose: (e: boolean) => void;
|
|
onClose: (e: boolean) => void;
|
|
|
|
|
+ animationEndCallback?: (flag: string) => void;
|
|
|
header?: React.ReactNode;
|
|
header?: React.ReactNode;
|
|
|
body: React.ReactNode;
|
|
body: React.ReactNode;
|
|
|
footer?: React.ReactNode;
|
|
footer?: React.ReactNode;
|
|
@@ -118,12 +122,17 @@ export default function CommonModal({
|
|
|
}
|
|
}
|
|
|
// 如果是关闭,动画结束之后才隐藏
|
|
// 如果是关闭,动画结束之后才隐藏
|
|
|
const handlerAnimationEnd = (e: React.AnimationEvent<HTMLDivElement>) => {
|
|
const handlerAnimationEnd = (e: React.AnimationEvent<HTMLDivElement>) => {
|
|
|
|
|
+ // 如果子元素上也有自己的动画效果,也会触发父元素的动画事件
|
|
|
|
|
+ if (e.target !== e.currentTarget) return;
|
|
|
if(e.animationName === "fade-out") {
|
|
if(e.animationName === "fade-out") {
|
|
|
setRootVisible('hidden');
|
|
setRootVisible('hidden');
|
|
|
if(destroyOnClose){
|
|
if(destroyOnClose){
|
|
|
setMounted(false);
|
|
setMounted(false);
|
|
|
cssInit.current=false;
|
|
cssInit.current=false;
|
|
|
}
|
|
}
|
|
|
|
|
+ animationEndCallback('close');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ animationEndCallback('show');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 初始化时是隐藏状态
|
|
// 初始化时是隐藏状态
|
|
@@ -152,6 +161,7 @@ export default function CommonModal({
|
|
|
}
|
|
}
|
|
|
)}
|
|
)}
|
|
|
style={{
|
|
style={{
|
|
|
|
|
+ ...contentStyle,
|
|
|
paddingTop: rootPddingTop,
|
|
paddingTop: rootPddingTop,
|
|
|
paddingBottom: rootPddingBottom
|
|
paddingBottom: rootPddingBottom
|
|
|
}}
|
|
}}
|