import { Button, Modal } from 'antd'; import React, { useRef, useState } from 'react'; import type { DraggableData, DraggableEvent } from 'react-draggable'; import Draggable from 'react-draggable'; const App: React.FC = () => { const [open, setOpen] = useState(false); const [disabled, setDisabled] = useState(true); const [bounds, setBounds] = useState({ left: 0, top: 0, bottom: 0, right: 0 }); const draggleRef = useRef(null); const showModal = () => { setOpen(true); }; const handleOk = (e: React.MouseEvent) => { console.log(e); setOpen(false); }; const handleCancel = (e: React.MouseEvent) => { console.log(e); setOpen(false); }; 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), }); }; return ( <> { if (disabled) { setDisabled(false); } }} onMouseOut={() => { setDisabled(true); }} // fix eslintjsx-a11y/mouse-events-have-key-events // https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/mouse-events-have-key-events.md onFocus={() => {}} onBlur={() => {}} // end > Draggable Modal } open={open} onOk={handleOk} onCancel={handleCancel} modalRender={(modal) => ( onStart(event, uiData)} >
{modal}
)} >

Just don't learn physics at school and your life will be full of magic and miracles.


Day before yesterday I saw a rabbit, and yesterday a deer, and today, you.

); }; export default App;