Commit a05bea12 authored by Chunchi Che's avatar Chunchi Che

update checkCardModal.tsx

parent 21cd9e99
...@@ -13,15 +13,14 @@ import { ...@@ -13,15 +13,14 @@ import {
resetCheckCardModal, resetCheckCardModal,
setCheckCardModalIsOpen, setCheckCardModalIsOpen,
} from "../../reducers/duel/mod"; } from "../../reducers/duel/mod";
import { Modal, Button, Row, Col, Popover } from "antd"; import { Button, Row, Col, Popover } from "antd";
import { CheckCard } from "@ant-design/pro-components"; import { CheckCard } from "@ant-design/pro-components";
import { import {
sendSelectCardResponse, sendSelectCardResponse,
sendSelectChainResponse, sendSelectChainResponse,
} from "../../api/ocgcore/ocgHelper"; } from "../../api/ocgcore/ocgHelper";
import type { DraggableData, DraggableEvent } from "react-draggable";
import Draggable from "react-draggable";
import NeosConfig from "../../../neos.config.json"; import NeosConfig from "../../../neos.config.json";
import DragModal from "./dragModal";
const CheckCardModal = () => { const CheckCardModal = () => {
const dispatch = store.dispatch; const dispatch = store.dispatch;
...@@ -36,27 +35,7 @@ const CheckCardModal = () => { ...@@ -36,27 +35,7 @@ const CheckCardModal = () => {
// Draggable 相关 // Draggable 相关
const [draggable, setDraggable] = useState(false); const [draggable, setDraggable] = useState(false);
const [bounds, setBounds] = useState({
left: 0,
top: 0,
bottom: 0,
right: 0,
});
const draggleRef = useRef<HTMLDivElement>(null); const draggleRef = useRef<HTMLDivElement>(null);
const onStart = (_event: DraggableEvent, uiData: DraggableData) => {
const { clientWidth, clientHeight } = window.document.documentElement;
const targetRect = draggleRef.current?.getBoundingClientRect();
if (!targetRect) {
return;
}
setBounds({
left: -targetRect.left + uiData.x,
right: clientWidth - (targetRect.right - uiData.x),
top: -targetRect.top + uiData.y,
bottom: clientHeight - (targetRect.bottom - uiData.y),
});
};
const onMouseOver = () => { const onMouseOver = () => {
if (draggable) { if (draggable) {
setDraggable(false); setDraggable(false);
...@@ -86,11 +65,12 @@ const CheckCardModal = () => { ...@@ -86,11 +65,12 @@ const CheckCardModal = () => {
}; };
return ( return (
<Modal <DragModal
title={`请选择${min}到${max}张卡片`} modalProps={{
open={isOpen} title: `请选择${min}到${max}张卡片`,
closable={false} open: isOpen,
footer={ closable: false,
footer: (
<> <>
<Button <Button
disabled={response.length < min || response.length > max} disabled={response.length < min || response.length > max}
...@@ -126,13 +106,11 @@ const CheckCardModal = () => { ...@@ -126,13 +106,11 @@ const CheckCardModal = () => {
<></> <></>
)} )}
</> </>
} ),
modalRender={(modal) => ( width: 800,
<Draggable disabled={!draggable} bounds={bounds} onStart={onStart}> }}
<div ref={draggleRef}>{modal}</div> dragRef={draggleRef}
</Draggable> draggable={draggable}
)}
width={800}
> >
<CheckCard.Group <CheckCard.Group
multiple multiple
...@@ -181,7 +159,7 @@ const CheckCardModal = () => { ...@@ -181,7 +159,7 @@ const CheckCardModal = () => {
); );
})} })}
</CheckCard.Group> </CheckCard.Group>
</Modal> </DragModal>
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment