You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
1.2 KiB
2 lines
1.2 KiB
import{G as x,u as c,ap as A}from"./index-f4658ae7.js";function E(n){const d=(o,t)=>getComputedStyle(o)[t],D=o=>{if(!o)return;o.setAttribute("data-drag",c(n.draggable));const t=o.querySelector(".ant-modal-header"),e=o.querySelector(".ant-modal");!t||!e||!c(n.draggable)||(t.style.cursor="move",t.onmousedown=s=>{if(!s)return;const T=s.clientX,L=s.clientY,W=document.body.clientWidth,v=document.documentElement.clientHeight,H=e.offsetWidth,S=e.offsetHeight,m=e.offsetLeft,g=W-e.offsetLeft-H,p=e.offsetTop,y=v-e.offsetTop-S,a=d(e,"left"),i=d(e,"top");let f=+a,u=+i;a.includes("%")?(f=+document.body.clientWidth*(+a.replace(/%/g,"")/100),u=+document.body.clientHeight*(+i.replace(/%/g,"")/100)):(f=+a.replace(/px/g,""),u=+i.replace(/px/g,"")),document.onmousemove=function(h){let l=h.clientX-T,r=h.clientY-L;-l>m?l=-m:l>g&&(l=g),-r>p?r=-p:r>y&&(r=y),e.style.cssText+=`;left:${l+f}px;top:${r+u}px;`},document.onmouseup=()=>{document.onmousemove=null,document.onmouseup=null}})},b=()=>{const o=document.querySelectorAll(".ant-modal-wrap");for(const t of Array.from(o)){if(!t)continue;const e=d(t,"display"),s=t.getAttribute("data-drag");e!=="none"&&(s===null||c(n.destroyOnClose))&&D(t)}};x(()=>{!c(n.visible)||!c(n.draggable)||A(()=>{b()},30)})}export{E as useModalDragMove};
|