2 lines
3.5 KiB
JavaScript
2 lines
3.5 KiB
JavaScript
import{b as h,W as g,X as D,Y as V,n as F,Z as _,_ as W,q as X,$ as Y,U as H,e as I}from"./index-cV5RpzD5.js";function C(u){var r;const n=g(u);return(r=n==null?void 0:n.$el)!=null?r:n}const z=D?window:void 0,O=D?window.document:void 0;function b(...u){let r,n,c,l;if(typeof u[0]=="string"||Array.isArray(u[0])?([n,c,l]=u,r=z):[r,n,c,l]=u,!r)return W;Array.isArray(n)||(n=[n]),Array.isArray(c)||(c=[c]);const i=[],m=()=>{i.forEach(a=>a()),i.length=0},d=(a,p,s,o)=>(a.addEventListener(p,s,o),()=>a.removeEventListener(p,s,o)),v=X(()=>[C(r),g(l)],([a,p])=>{if(m(),!a)return;const s=Y(p)?{...p}:p;i.push(...n.flatMap(o=>c.map(w=>d(a,o,w,s))))},{immediate:!0,flush:"post"}),E=()=>{v(),m()};return _(E),E}function P(){const u=h(!1);return H()&&I(()=>{u.value=!0}),u}function T(u){const r=P();return F(()=>(r.value,!!u()))}function U(u,r={}){var n,c;const{pointerTypes:l,preventDefault:i,stopPropagation:m,exact:d,onMove:v,onEnd:E,onStart:a,initialValue:p,axis:s="both",draggingElement:o=z,containerElement:w,handle:S=u}=r,f=h((n=g(p))!=null?n:{x:0,y:0}),e=h(),x=t=>l?l.includes(t.pointerType):!0,k=t=>{g(i)&&t.preventDefault(),g(m)&&t.stopPropagation()},$=t=>{var y;if(!x(t)||g(d)&&t.target!==g(u))return;const q=((y=g(w))!=null?y:g(u)).getBoundingClientRect(),R={x:t.clientX-q.left,y:t.clientY-q.top};(a==null?void 0:a(R,t))!==!1&&(e.value=R,k(t))},B=t=>{if(!x(t)||!e.value)return;let{x:y,y:M}=f.value;(s==="x"||s==="both")&&(y=t.clientX-e.value.x),(s==="y"||s==="both")&&(M=t.clientY-e.value.y),f.value={x:y,y:M},v==null||v(f.value,t),k(t)},L=t=>{x(t)&&e.value&&(e.value=void 0,E==null||E(f.value,t),k(t))};if(D){const t={capture:(c=r.capture)!=null?c:!0};b(S,"pointerdown",$,t),b(o,"pointermove",B,t),b(o,"pointerup",L,t)}return{...V(f),position:f,isDragging:F(()=>!!e.value),style:F(()=>`left:${f.value.x}px;top:${f.value.y}px;`)}}const A=["fullscreenchange","webkitfullscreenchange","webkitendfullscreen","mozfullscreenchange","MSFullscreenChange"];function Z(u,r={}){const{document:n=O,autoExit:c=!1}=r,l=F(()=>{var e;return(e=C(u))!=null?e:n==null?void 0:n.querySelector("html")}),i=h(!1),m=F(()=>["requestFullscreen","webkitRequestFullscreen","webkitEnterFullscreen","webkitEnterFullScreen","webkitRequestFullScreen","mozRequestFullScreen","msRequestFullscreen"].find(e=>n&&e in n||l.value&&e in l.value)),d=F(()=>["exitFullscreen","webkitExitFullscreen","webkitExitFullScreen","webkitCancelFullScreen","mozCancelFullScreen","msExitFullscreen"].find(e=>n&&e in n||l.value&&e in l.value)),v=F(()=>["fullScreen","webkitIsFullScreen","webkitDisplayingFullscreen","mozFullScreen","msFullscreenElement"].find(e=>n&&e in n||l.value&&e in l.value)),E=["fullscreenElement","webkitFullscreenElement","mozFullScreenElement","msFullscreenElement"].find(e=>n&&e in n),a=T(()=>l.value&&n&&m.value!==void 0&&d.value!==void 0&&v.value!==void 0),p=()=>E?(n==null?void 0:n[E])===l.value:!1,s=()=>{if(v.value){if(n&&n[v.value]!=null)return n[v.value];{const e=l.value;if((e==null?void 0:e[v.value])!=null)return!!e[v.value]}}return!1};async function o(){if(!(!a.value||!i.value)){if(d.value)if((n==null?void 0:n[d.value])!=null)await n[d.value]();else{const e=l.value;(e==null?void 0:e[d.value])!=null&&await e[d.value]()}i.value=!1}}async function w(){if(!a.value||i.value)return;s()&&await o();const e=l.value;m.value&&(e==null?void 0:e[m.value])!=null&&(await e[m.value](),i.value=!0)}async function S(){await(i.value?o():w())}const f=()=>{const e=s();(!e||e&&p())&&(i.value=e)};return b(n,A,f,!1),b(()=>C(l),A,f,!1),c&&_(o),{isSupported:a,isFullscreen:i,enter:w,exit:o,toggle:S}}export{U as a,Z as u};
|