react-motion-gallery 2.0.69 → 2.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/chunk-HLFWK42L.mjs +1 -0
- package/dist/chunk-WUB37KRW.mjs +4 -0
- package/dist/fullscreen-zoom-pan.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/zoomPan.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-7WKLGKCT.mjs +0 -1
- package/dist/chunk-GS2GLLIJ.mjs +0 -4
package/README.md
CHANGED
|
@@ -48,13 +48,13 @@ This table reports local gzip measurements for selected runtime surfaces. Type-o
|
|
|
48
48
|
| `fullscreen/slider` | 39.5kB |
|
|
49
49
|
| `fullscreen/controls` | 173.0B |
|
|
50
50
|
| `fullscreen/captions` | 13.2kB |
|
|
51
|
-
| `fullscreen/zoom-pan` | 12.
|
|
51
|
+
| `fullscreen/zoom-pan` | 12.4kB |
|
|
52
52
|
| `fullscreen/video` | 16.4kB |
|
|
53
53
|
| `fullscreen/lazy-load` | 13.2kB |
|
|
54
54
|
| `fullscreen/crossfade` | 181.0B |
|
|
55
55
|
| `fullscreen/thumbnails` | 160.0B |
|
|
56
56
|
| `Video` | 12.7kB |
|
|
57
|
-
| `ZoomPanImage` |
|
|
57
|
+
| `ZoomPanImage` | 11.0kB |
|
|
58
58
|
| `zoomPan/hover` | 124.0B |
|
|
59
59
|
| `media / toMediaItems` | 260.0B |
|
|
60
60
|
| `media/ready` | 656.0B |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {l,h,g,j,a as a$2,i,f as f$1,e as e$1,m,n,o,p,d,q,k,c as c$1,b as b$3}from'./chunk-WUB37KRW.mjs';import {a as a$1}from'./chunk-ADIHG7AT.mjs';import {a}from'./chunk-JJMFOLJZ.mjs';import {b as b$2}from'./chunk-P2GQPFSL.mjs';import {e,c,b as b$1}from'./chunk-HGY3QLCE.mjs';import {b}from'./chunk-AKY343WN.mjs';import*as t from'react';import {jsx}from'react/jsx-runtime';var Ve=3,dt="[data-rmg-slider-core-scope]";function yt(...p){return p.filter(Boolean).join(" ")}function f(p){return p>1.01}function bt(){let p=new Set;return {publishZoomIn(I){p.forEach(D=>D(I));},subscribeZoomIn(I){return p.add(I),()=>{p.delete(I);}}}}var je=t.forwardRef(function(I,D){let{className:_e,style:Ne,imageClassName:We,imageStyle:Ke,zoom:ie,disabled:o$1=false,onDragStart:fe,src:x,...Ue}=I,l$1=t.useMemo(()=>({...a,...ie??{}}),[ie]),R=t.useMemo(()=>l(l$1),[l$1]),H=t.useMemo(()=>({zoom:l$1}),[l$1]),C=b(),r=t.useRef(null),me=t.useRef([]);me.current=[r];let a$3=t.useRef(1),Re=t.useRef({x:0,y:0}),pe=t.useRef({x:0,y:0}),$e=t.useRef(false),B=t.useRef(false),k$1=t.useRef(false),u=t.useRef(null),qe=t.useRef(false),Ge=t.useRef("idle"),de=t.useRef(null),V=t.useRef(null),j$1=t.useRef(null),_=t.useRef(null),N=t.useRef(null),M=t.useRef(null),S=t.useRef(null),A=t.useRef(null),Y=t.useRef(null),E=t.useRef(null),T=t.useRef(null),O=t.useRef(null),X=t.useRef(null),F=t.useRef(null),W=t.useRef(false),ye=t.useRef(0),be=t.useRef(1),Pe=t.useRef(false),i$1=t.useRef(false),v=t.useRef(null),K=t.useRef({active:false,pointerId:null,lastX:0,lastY:0,totalAbsDx:0,totalAbsDy:0}),[Je,Qe]=t.useState(1),U=t.useCallback(e=>{a$3.current=e,Qe(e);},[]),d$1=f(Je),y=typeof C?.normIdx=="number"?C.normIdx:null,L=C?.indexChannel,w=t.useMemo(()=>C?.storeBag?C.storeBag.getOrCreate("rmg-zoom-pan-layout-sync",bt):null,[C?.storeBag]),ge=t.useRef(false),et=t.useCallback(e=>{if(r.current=e,u.current=e,!!D){if(typeof D=="function"){D(e);return}D.current=e;}},[D]),b$4=t.useCallback((e,n,s,m,ne)=>h({scale:e,imgW:n,imgH:s,currentImageEl:u.current,viewW:m,viewH:ne}),[]),J=t.useCallback((e,n)=>{let s=u.current,m=a$1(s);m&&(m.style.transition&&(m.style.transition=""),m.style.transform=`translate3d(${e}px, ${n}px, 0) scale(${a$3.current})`);},[]),Q=t.useCallback(()=>{u.current=r.current,g({fs:H,currentImage:u,scaleRef:a$3,locX:V,prevX:_,offX:M,tgtX:A,locY:j$1,prevY:N,offY:S,tgtY:Y,bodyX:E,bodyY:T,boundsX:O,boundsY:X,Vector1D:b$1,ScrollBody:c,ScrollBounds:e,boundsForCurrent:b$4});},[b$4,H]),$=t.useCallback(()=>{F.current?.stop(),E.current?.useDuration(0).useFriction(1).sync(),T.current?.useDuration(0).useFriction(1).sync();},[]),he=t.useCallback(()=>{u.current=r.current,j({currentImage:u,locX:V,prevX:_,offX:M,tgtX:A,locY:j$1,prevY:N,offY:S,tgtY:Y,bodyX:E,bodyY:T,boundsX:O,boundsY:X,ScrollBody:c,ScrollBounds:e,baseFitSize:a$2,boundsForCurrent:b$4,panDuration:l$1.panDuration,panFriction:l$1.panFriction,animRef:F});},[b$4,l$1.panDuration,l$1.panFriction]),P=t.useCallback((e="transform 0.2s cubic-bezier(.4,0,.22,1)")=>{u.current=r.current,$(),i({setScale:U,zoomState:{previousZoom:pe,panRef:Re,scaleRef:a$3},imageRefs:me,resetPan:he,transition:e});},[he,U,$]),c$2=t.useMemo(()=>({fs:H,currentImage:u,scaleRef:a$3,setScale:U,previousZoom:pe,suppressLoopRef:$e,locX:V,prevX:_,offX:M,tgtX:A,locY:j$1,prevY:N,offY:S,tgtY:Y,bodyX:E,bodyY:T,boundsX:O,boundsY:X,Vector1D:b$1,ScrollBody:c,ScrollBounds:e,boundsForCurrent:b$4,renderPan:J,animRef:F,panRef:Re,resetAllZoomDom:$}),[b$4,H,J,U,$]),tt=f$1({fs:H,isZoomed:d$1,zoomCtx:c$2,currentImage:u,rebuildPanBodies:Q,renderPan:J,handleZoomToggle:e$1,suppressNextClickRef:B,pointerDownRef:qe,interactionModeRef:Ge,boundsX:O,boundsY:X,bodyX:E,bodyY:T,locX:V,locY:j$1,prevX:_,prevY:N,offX:M,offY:S,tgtX:A,tgtY:Y,axisRef:de,animRef:F});t.useEffect(()=>{de.current=b$2();},[]),t.useLayoutEffect(()=>{u.current=r.current,Pe.current=!!r.current?.closest(dt);});let g$1=t.useCallback(()=>{K.current={active:false,pointerId:null,lastX:0,lastY:0,totalAbsDx:0,totalAbsDy:0};},[]),h$1=t.useCallback(()=>{i$1.current=false,v.current=null;},[]),nt=t.useCallback(e=>{o$1||!R||!m(e)||f(a$3.current)||!r.current||!n(c$2,{imageRef:r,clientX:e.clientX,clientY:e.clientY,hover:R})||(i$1.current=true,v.current=e.pointerId??null,g$1());},[o$1,R,g$1,c$2]),rt=t.useCallback(e=>{if(!(o$1||!R)&&m(e)){if(!i$1.current){if(f(a$3.current)||!r.current||!n(c$2,{imageRef:r,clientX:e.clientX,clientY:e.clientY,hover:R}))return;i$1.current=true,v.current=e.pointerId??null,g$1();return}v.current!=null&&e.pointerId!==v.current||o(c$2,{imageRef:r,clientX:e.clientX,clientY:e.clientY});}},[o$1,R,g$1,c$2]),De=t.useCallback(e=>{!R||!i$1.current||m(e)&&(v.current!=null&&e.pointerId!==v.current||(h$1(),p(c$2,{imageRef:r,durationMs:R.zoomOutDurationMs})));},[R,h$1,c$2]),ot=t.useCallback(e=>{o$1||f(a$3.current)||e.button!==void 0&&e.button!==0||(k$1.current=false,K.current={active:true,pointerId:e.pointerId,lastX:e.clientX,lastY:e.clientY,totalAbsDx:0,totalAbsDy:0});},[o$1]),at=t.useCallback(e=>{if(o$1||f(a$3.current))return;let n=K.current;if(!n.active||n.pointerId!==e.pointerId)return;let s=e.clientX-n.lastX,m=e.clientY-n.lastY;n.lastX=e.clientX,n.lastY=e.clientY,n.totalAbsDx+=Math.abs(s),n.totalAbsDy+=Math.abs(m),(n.totalAbsDx>Ve||n.totalAbsDy>Ve)&&(k$1.current=true);},[o$1]),ee=t.useCallback(e=>{if(o$1||f(a$3.current))return;let n=K.current;!n.active||n.pointerId!==e.pointerId||g$1();},[o$1,g$1]),ct=t.useCallback(e=>{if(i$1.current){e.preventDefault(),e.stopPropagation();return}(B.current||k$1.current)&&(B.current=false,k$1.current=false,e.preventDefault(),e.stopPropagation());},[]),ut=t.useCallback(e=>{if(!e.defaultPrevented){if(i$1.current){e.preventDefault(),e.stopPropagation();return}o$1||d$1||W.current||(u.current=r.current,e$1(c$2,e,r));}},[o$1,d$1,c$2]),te=t.useCallback(e$1=>{if(o$1||!r.current)return;if(u.current=r.current,e$1.ctrlKey){e$1.cancelable&&e$1.preventDefault(),e$1.stopPropagation();let Me=e$1.deltaY;e$1.deltaMode===1&&(Me*=15);let pt=a$3.current*(1-Me/100);d(c$2,{destZoomLevel:pt,centerPoint:{x:e$1.clientX,y:e$1.clientY},imageRef:r});return}if(!f(a$3.current))return;e$1.cancelable&&e$1.preventDefault(),e$1.stopPropagation(),Q();let n=a$1(r.current);if(!n)return;let s=r.current.getBoundingClientRect(),{baseW:m,baseH:ne}=a$2(n,s.width,s.height),{x:ve,y:Ie,povX:ft,povY:mt}=b$4(a$3.current,m,ne,s.width,s.height);O.current=e(ve,M.current,A.current,E.current,ft,l$1.panDuration),X.current=e(Ie,S.current,Y.current,T.current,mt,l$1.panDuration);let Ce={x:ve.constrain((M.current?.get()??0)-e$1.deltaX),y:Ie.constrain((S.current?.get()??0)-e$1.deltaY)},Rt=i$1.current?q(c$2,{imageRef:r,target:Ce,syncMode:"target"}):false;i$1.current||k(c$2,Ce,"target"),E.current?.useDuration(0).useFriction(1),T.current?.useDuration(0).useFriction(1),Rt||F.current?.start();},[b$4,o$1,Q,l$1.panDuration,c$2]);t.useEffect(()=>{let e=r.current;if(e)return e.addEventListener("wheel",te,{passive:false}),()=>{e.removeEventListener("wheel",te);}},[te]),t.useEffect(()=>{let e=r.current;if(!e)return;let n=s=>{o$1||Pe.current&&f(a$3.current)&&s.stopPropagation();};return e.addEventListener("mousedown",n,{capture:true}),e.addEventListener("touchstart",n,{capture:true,passive:false}),()=>{e.removeEventListener("mousedown",n,true),e.removeEventListener("touchstart",n,true);}},[o$1]);let st=t.useCallback(e=>{o$1||e.touches.length!==2||(e.preventDefault(),g$1(),k$1.current=false,W.current=true,ye.current=c$1(e.touches[0],e.touches[1]),be.current=a$3.current);},[o$1,g$1]),lt=t.useCallback(e=>{if(o$1||!W.current||e.touches.length!==2||!r.current)return;e.preventDefault(),u.current=r.current;let n=be.current*(c$1(e.touches[0],e.touches[1])/ye.current),s=b$3(e.touches[0],e.touches[1]);d(c$2,{destZoomLevel:n,centerPoint:s,imageRef:r});},[o$1,c$2]),Ee=t.useCallback(()=>{W.current=false;},[]);t.useEffect(()=>{o$1&&f(a$3.current)&&(h$1(),P());},[o$1,h$1,P]),t.useEffect(()=>{if(L)return L.onBasePointerDown(()=>{f(a$3.current)&&P();})},[P,L]),t.useEffect(()=>{if(w&&y!=null)return w.subscribeZoomIn(e=>{e!==y&&f(a$3.current)&&P();})},[y,w,P]),t.useEffect(()=>{let e=ge.current;if(ge.current=d$1,e||!d$1||y==null)return;w?.publishZoomIn(y);let n=L?.get().index;n==null||n===y||L?.set(y,"animated",{meta:{source:"external"}});},[d$1,y,w,L]);let Te=t.useRef(x);t.useEffect(()=>{Te.current!==x&&(Te.current=x,h$1(),P("none"));},[h$1,P,x]),t.useEffect(()=>()=>{let e=r.current,n=a$1(e);n&&(n.style.transition="",n.style.transform="translate3d(0px, 0px, 0) scale(1)"),a$3.current=1,h$1();},[h$1]);let it=t.useCallback(e=>{e.preventDefault(),fe?.(e);},[fe]);return jsx("div",{ref:et,className:_e,"data-rmg-zoom-pan-root":"true","data-rmg-fs-media":"true","data-rmg-fs-media-viewport":"true",onClickCapture:ct,onClick:ut,onPointerEnter:nt,onPointerDown:e=>{if(i$1.current&&m(e)){B.current=true,e.preventDefault(),e.stopPropagation();return}ot(e),!o$1&&tt.handlePanPointerStart(e,r);},onPointerMove:e=>{rt(e),!i$1.current&&at(e);},onPointerLeave:e=>{De(e),ee(e);},onPointerUp:ee,onPointerCancel:e=>{De(e),ee(e);},onTouchStart:st,onTouchMove:lt,onTouchEnd:Ee,onTouchCancel:Ee,style:{position:"relative",overflow:"hidden",minWidth:0,minHeight:0,touchAction:o$1?"auto":d$1?"none":"pan-y",...Ne},children:jsx("div",{"data-rmg-zoom-pan-stage":"true",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:"100%",minWidth:0},children:jsx("img",{...Ue,ref:e=>{e&&!e.style.transform&&(e.style.transform="translate3d(0px, 0px, 0) scale(1)");},src:x,className:yt(We),"data-rmg-zoom-pan-image":"true",draggable:false,onDragStart:it,style:{display:"block",maxWidth:"100%",maxHeight:"100%",objectFit:"contain",transformOrigin:"0 0",willChange:"transform",backfaceVisibility:"hidden",touchAction:"manipulation",userSelect:"none",cursor:o$1?"default":d$1?"grab":"zoom-in",...Ke}})})})});export{je as a};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import {a,c,h,e,b}from'./chunk-ADIHG7AT.mjs';import {f,d,g as g$1,h as h$1,a as a$1}from'./chunk-HGY3QLCE.mjs';import {g}from'./chunk-UAEPMZQY.mjs';import*as S from'react';function A(e){if(!e)return {x:0,y:0};let r=window.getComputedStyle(e),n=r.transform&&r.transform!=="none"?r.transform:e.style.transform;if(!n||n==="none")return {x:0,y:0};let t=n.match(/matrix3d\(([^)]+)\)/);if(t){let c=t[1].split(",").map(parseFloat);return {x:c[12]||0,y:c[13]||0}}let o=n.match(/matrix\(([^)]+)\)/);if(o){let c=o[1].split(",").map(parseFloat);return {x:c[4]||0,y:c[5]||0}}let s=n.match(/translate(?:3d)?\(\s*([-\d.]+)px(?:,\s*([-\d.]+)px)?/);return s?{x:Number.parseFloat(s[1])||0,y:Number.parseFloat(s[2]??"0")||0}:{x:0,y:0}}function W(e,r,n){let t=e.naturalWidth||e.width||r,o=e.naturalHeight||e.height||n,s=Math.min(r/t,n/o);return {baseW:t*s,baseH:o*s}}function j(e,r,n){return Math.max(r,Math.min(n,e))}function je(e,r){return r?{x:(e.clientX+r.clientX)/2,y:(e.clientY+r.clientY)/2}:{x:e.clientX,y:e.clientY}}function _e(e,r){let n=e.clientX-r.clientX,t=e.clientY-r.clientY;return Math.hypot(n,t)}var ne=new WeakMap;function Ve(e){let r=typeof window<"u"&&typeof window.getComputedStyle=="function"?window.getComputedStyle(e).transform:"";return r&&r!=="none"?r:e.style.transform||"translate3d(0px, 0px, 0) scale(1)"}function te(e,r,n,t,o=300){let s=e.currentImage.current;if(!s)return;let c=b(s);if(!c.length)return;let a=`transform ${o}ms cubic-bezier(.4,0,.22,1)`,m=`translate3d(${r}px, ${n}px, 0) scale(${t})`;c.forEach(u=>{let i=ne.get(u);i!=null&&window.clearTimeout(i);let f=Ve(u);u.style.transition="",u.style.transform=f,u.offsetWidth,u.style.transition=a,u.style.transform=m;let d=window.setTimeout(()=>{ne.get(u)===d&&(u.style.transition="",ne.delete(u));},o+30);ne.set(u,d);}),e.offX.current?.set(r),e.offY.current?.set(n),e.locX.current?.set(r),e.locY.current?.set(n),e.prevX.current?.set(r),e.prevY.current?.set(n),e.tgtX.current?.set(r),e.tgtY.current?.set(n),e.scaleRef.current=t,e.setScale(t);}function Ge(e,r){let{destZoomLevel:n,centerPoint:t,imageRef:o}=r;if(!o.current)return;e.currentImage.current=o.current;let s=e.currentImage.current,c$1=a(s);if(!c$1)return;let a$1=c(s)??s,m=a$1.getBoundingClientRect();if(h({width:m.width,height:m.height},c$1))return;let{x:u,y:i}=A(c$1);(!e.locX.current||!e.locY.current)&&(e.locX.current=e.Vector1D(u),e.prevX.current=e.Vector1D(u),e.offX.current=e.Vector1D(u),e.tgtX.current=e.Vector1D(u),e.locY.current=e.Vector1D(i),e.prevY.current=e.Vector1D(i),e.offY.current=e.Vector1D(i),e.tgtY.current=e.Vector1D(i),e.bodyX.current=e.ScrollBody(e.locX.current,e.offX.current,e.prevX.current,e.tgtX.current,e.fs.zoom.panDuration,e.fs.zoom.panFriction).sync(),e.bodyY.current=e.ScrollBody(e.locY.current,e.offY.current,e.prevY.current,e.tgtY.current,e.fs.zoom.panDuration,e.fs.zoom.panFriction).sync());let f=e.scaleRef.current||1,d=j(n,1,e.fs.zoom.maxZoomLevel),g=1.01;if(d===f){let z=e.offX.current?.get()??u,B=e.offY.current?.get()??i,O=Math.abs(z)<.5&&Math.abs(B)<.5;if(d>g||O)return}let R=f>g,v=d>g;!R&&v?e.suppressLoopRef.current=true:R&&!v&&(e.suppressLoopRef.current=false);let T=a$1.getBoundingClientRect(),h$1=T.width,Y=T.height,E=t.x-T.left,w=t.y-T.top,{baseW:b,baseH:M}=W(c$1,h$1,Y),X=(h$1-b)/2,Z=(Y-M)/2,L=e.offX.current.get(),C=e.offY.current.get(),D=d/f,p=L+(1-D)*(E-X-L),l=C+(1-D)*(w-Z-C),{x:H,y:P,povX:F,povY:V}=e.boundsForCurrent(d,b,M,h$1,Y,{ignoreReserved:true});if(p=H.constrain(p),l=P.constrain(l),e.scaleRef.current=d,e.setScale(d),e.previousZoom.current.x=E,e.previousZoom.current.y=w,!v){p=H.constrain(0),l=P.constrain(0),e.boundsX.current=e.ScrollBounds(H,e.offX.current,e.tgtX.current,e.bodyX.current,F,e.fs.zoom.panDuration),e.boundsY.current=e.ScrollBounds(P,e.offY.current,e.tgtY.current,e.bodyY.current,V,e.fs.zoom.panDuration),e.tgtX.current.set(p),e.tgtY.current.set(l),e.bodyX.current?.resetVelocity?.(),e.bodyX.current?.useBaseDuration?.(),e.bodyX.current?.useBaseFriction?.(),e.bodyY.current?.resetVelocity?.(),e.bodyY.current?.useBaseDuration?.(),e.bodyY.current?.useBaseFriction?.(),e.animRef.current?.resetBlend(),e.animRef.current?.start();return}e.tgtX.current.set(p),e.locX.current.set(p),e.prevX.current.set(p),e.offX.current.set(p),e.tgtY.current.set(l),e.locY.current.set(l),e.prevY.current.set(l),e.offY.current.set(l),e.boundsX.current=e.ScrollBounds(H,e.offX.current,e.tgtX.current,e.bodyX.current,F,e.fs.zoom.panDuration),e.boundsY.current=e.ScrollBounds(P,e.offY.current,e.tgtY.current,e.bodyY.current,V,e.fs.zoom.panDuration),e.bodyX.current?.useDuration(0).useFriction(1),e.bodyY.current?.useDuration(0).useFriction(1),e.renderPan(p,l),e.animRef.current?.start();}function xe(e$1,r,n){if(!n.current)return;e$1.currentImage.current=n.current;let t=e$1.currentImage.current;if(!t)return;let o=a(t);if(!o)return;let s=c(t)??t,c$1=s.getBoundingClientRect();if(h({width:c$1.width,height:c$1.height},o))return;let{x:a$1,y:m}=A(o);(!e$1.locX.current||!e$1.locY.current)&&(e$1.locX.current=e$1.Vector1D(a$1),e$1.prevX.current=e$1.Vector1D(a$1),e$1.offX.current=e$1.Vector1D(a$1),e$1.tgtX.current=e$1.Vector1D(a$1),e$1.locY.current=e$1.Vector1D(m),e$1.prevY.current=e$1.Vector1D(m),e$1.offY.current=e$1.Vector1D(m),e$1.tgtY.current=e$1.Vector1D(m),e$1.bodyX.current=e$1.ScrollBody(e$1.locX.current,e$1.offX.current,e$1.prevX.current,e$1.tgtX.current,e$1.fs.zoom.panDuration,e$1.fs.zoom.panFriction).sync(),e$1.bodyY.current=e$1.ScrollBody(e$1.locY.current,e$1.offY.current,e$1.prevY.current,e$1.tgtY.current,e$1.fs.zoom.panDuration,e$1.fs.zoom.panFriction).sync());let u=e$1.scaleRef.current||1,i=u===1,f=i?e$1.fs.zoom.clickZoomLevel:1,d=1.01,g=u>d,R=f>d;g&&!R&&(e$1.suppressLoopRef.current=false,e$1.resetAllZoomDom());let v=s.getBoundingClientRect(),T=v.width,h$1=v.height,{clientX:Y,clientY:E}=e(r),w=Y-v.left,b=E-v.top,{baseW:M,baseH:X}=W(o,T,h$1),Z=(T-M)/2,L=(h$1-X)/2,C=e$1.offX.current.get(),D=e$1.offY.current.get(),p,l;if(i){let B=f/u;p=C+(1-B)*(w-Z-C),l=D+(1-B)*(b-L-D);let{x:O,y:U}=e$1.boundsForCurrent(f,M,X,T,h$1);p=O.constrain(p),l=U.constrain(l);}else p=0,l=0;te(e$1,p,l,f,300),e$1.scaleRef.current=f,e$1.setScale(f),e$1.previousZoom.current.x=w,e$1.previousZoom.current.y=b,e$1.panRef.current={x:p,y:l},e$1.locX.current.set(p),e$1.prevX.current.set(p),e$1.offX.current.set(p),e$1.tgtX.current.set(p),e$1.locY.current.set(l),e$1.prevY.current.set(l),e$1.offY.current.set(l),e$1.tgtY.current.set(l),e$1.bodyX.current=e$1.ScrollBody(e$1.locX.current,e$1.offX.current,e$1.prevX.current,e$1.tgtX.current,e$1.fs.zoom.panDuration,e$1.fs.zoom.panFriction).sync(),e$1.bodyY.current=e$1.ScrollBody(e$1.locY.current,e$1.offY.current,e$1.prevY.current,e$1.tgtY.current,e$1.fs.zoom.panDuration,e$1.fs.zoom.panFriction).sync();let{x:P,y:F,povX:V,povY:z}=e$1.boundsForCurrent(f,M,X,T,h$1);e$1.boundsX.current=e$1.ScrollBounds(P,e$1.offX.current,e$1.tgtX.current,e$1.bodyX.current,V,e$1.fs.zoom.panDuration),e$1.boundsY.current=e$1.ScrollBounds(F,e$1.offY.current,e$1.tgtY.current,e$1.bodyY.current,z,e$1.fs.zoom.panDuration),e$1.tgtX.current.set(P.constrain(e$1.tgtX.current.get())),e$1.tgtY.current.set(F.constrain(e$1.tgtY.current.get())),e$1.animRef.current?.resetBlend();}function ge(e){S.useEffect(()=>{let r=h$1(document,window,()=>{e.boundsX.current?.constrain(e.pointerDownRef.current),e.boundsY.current?.constrain(e.pointerDownRef.current),e.bodyX.current?.seek(),e.bodyY.current?.seek();},n=>{let t=e.locX.current,o=e.locY.current,s=e.prevX.current,c=e.prevY.current;if(!t||!o||!s||!c)return;let a=t.get()*n+s.get()*(1-n),m=o.get()*n+c.get()*(1-n);e.offX.current?.set(a),e.offY.current?.set(m),e.renderPan(a,m);let u=!!e.bodyX.current?.settled()&&!!e.bodyY.current?.settled(),i=!e.boundsX.current?.reached?.()&&!e.boundsY.current?.reached?.();u&&i&&!e.pointerDownRef.current&&e.animRef.current?.stop();});return e.animRef.current=r,r.init(),()=>{r.destroy(),e.animRef.current=null;}},[]);}function ke(){return {scroll:"x",cross:"y",direction(e){return e},measureSize(e){return e.width}}}function Re(e,r){return typeof r.MouseEvent<"u"&&e instanceof r.MouseEvent}function Ze(e,r){return a$1({ownerWindow:r,axis:e})}var N="data-rmg-pan-drag",ve="rmg-zoom-pan-drag-style";function Te(e){let r=S.useMemo(()=>({mouse:400,touch:400}),[]),n=S.useRef(null),t=S.useRef(g$1()).current,o=S.useRef(g$1()).current,s=S.useCallback((u,i)=>u*(i?r.mouse:r.touch),[r]);function c(){if(document.getElementById(ve))return;let u=document.createElement("style");u.id=ve,u.textContent=`
|
|
2
|
+
[data-rmg-zoom-pan-root="true"][${N}] { cursor: grabbing !important; }
|
|
3
|
+
[data-rmg-zoom-pan-root="true"][${N}] * { cursor: grabbing !important; }
|
|
4
|
+
`,document.head.appendChild(u);}S.useEffect(()=>{c();},[]);let a$1=S.useCallback(u=>{let i=e.currentImage.current;if(i){if(u){i.hasAttribute(N)||i.setAttribute(N,"");return}i.hasAttribute(N)&&i.removeAttribute(N);}},[e.currentImage]),m=S.useCallback((u,i)=>{if(!e.isZoomed||!i.current)return;e.currentImage.current=i.current,e.rebuildPanBodies();let f=window,d=e.axisRef.current||ke();n.current=Ze(d,f);let g=u.button!==void 0,R=g?u.button===0:false;if(g&&!R)return;e.pointerDownRef.current=true,e.interactionModeRef.current="drag",a$1(true);let v=()=>{e.pointerDownRef.current=false,e.interactionModeRef.current="idle",o.clear(),a$1(false);};e.tgtX.current?.set(e.locX.current?.get?.()??0),e.tgtY.current?.set(e.locY.current?.get?.()??0);let T=3,h=220,Y=.075,E=0,w=0,b=false,M=performance.now(),X=u.nativeEvent;n.current.pointerDown(X);let Z=p=>{if(!Re(p,window)&&p.touches?.length>=2)return b=true,v(),L(p);let l=n.current.pointerMove(p);E+=Math.abs(l.dx),w+=Math.abs(l.dy),e.bodyX.current?.useFriction(.3).useDuration(.75),e.bodyY.current?.useFriction(.3).useDuration(.75),e.tgtX.current?.add(l.dx),e.tgtY.current?.add(l.dy),e.animRef.current?.start(),"cancelable"in p&&p.cancelable&&p.preventDefault?.();},L=p=>{let l=n.current.pointerUp(p),H=Re(p,window),P=performance.now()-M,F=E<=T&&w<=T,V=Math.abs(l.fx)<=Y&&Math.abs(l.fy)<=Y,z=!b&&F&&V&&P<=h;if(e.pointerDownRef.current=false,e.interactionModeRef.current="idle",o.clear(),v(),z){let se=e.currentImage.current,I=a(se);if(I){let _=p,He=_?.touches?.[0]?.clientX??_?.changedTouches?.[0]?.clientX??_?.clientX??X?.clientX,Se=_?.touches?.[0]?.clientY??_?.changedTouches?.[0]?.clientY??_?.clientY??X?.clientY,Ee={target:I,currentTarget:I,clientX:He,clientY:Se,nativeEvent:_??X};e.handleZoomToggle(e.zoomCtx,Ee,e.currentImage),e.suppressNextClickRef.current=true;let le=p;le?.preventDefault?.(),le?.stopPropagation?.(),e.animRef.current?.stop();return}e.animRef.current?.stop();return}let B=s(l.fx,H),O=s(l.fy,H),U=Math.min(1,Math.abs(l.fx)>0?Math.abs((Math.abs(B)-Math.abs(l.fx))/(l.fx||1)):0),x=Math.min(1,Math.abs(l.fy)>0?Math.abs((Math.abs(O)-Math.abs(l.fy))/(l.fy||1)):0),K=e.fs.zoom.panDuration,q=e.fs.zoom.panDuration,J=e.fs.zoom.panFriction+U/50,Q=e.fs.zoom.panFriction+x/50;e.bodyX.current?.useDuration(K).useFriction(J),e.bodyY.current?.useDuration(q).useFriction(Q),e.tgtX.current?.add(B),e.tgtY.current?.add(O),e.animRef.current?.start();},D=u.nativeEvent instanceof MouseEvent?document:window;o.add(D,"touchmove",Z,{passive:false}).add(D,"touchend",L).add(D,"mousemove",Z,{passive:false}).add(D,"mouseup",L),t.add(window,"touchcancel",L).add(window,"contextmenu",L);},[e,t,o,s,a$1]);return S.useEffect(()=>()=>{o.clear(),t.clear(),e.currentImage.current?.removeAttribute(N),document.documentElement.classList.remove("rmg-pan-grabbing");},[e.currentImage,o,t]),{handlePanPointerStart:m}}function ar(e){return ge(e),Te(e)}function pr(e){if(!e.currentImage.current)return;let r=e.currentImage.current,n=a(r);if(!n)return;let t=c(r)?.getBoundingClientRect()??r.getBoundingClientRect(),o=t.width,s=t.height,{baseW:c$1,baseH:a$1}=W(n,o,s),{x:m,y:u}=A(n);e.locX.current=e.Vector1D(m),e.prevX.current=e.Vector1D(m),e.offX.current=e.Vector1D(m),e.tgtX.current=e.Vector1D(m),e.locY.current=e.Vector1D(u),e.prevY.current=e.Vector1D(u),e.offY.current=e.Vector1D(u),e.tgtY.current=e.Vector1D(u),e.bodyX.current=e.ScrollBody(e.locX.current,e.offX.current,e.prevX.current,e.tgtX.current,e.fs.zoom.panDuration,e.fs.zoom.panFriction).sync(),e.bodyY.current=e.ScrollBody(e.locY.current,e.offY.current,e.prevY.current,e.tgtY.current,e.fs.zoom.panDuration,e.fs.zoom.panFriction).sync();let{x:i,y:f,povX:d,povY:g}=e.boundsForCurrent(e.scaleRef.current,c$1,a$1,o,s);e.boundsX.current=e.ScrollBounds(i,e.offX.current,e.tgtX.current,e.bodyX.current,d,e.fs.zoom.panDuration),e.boundsY.current=e.ScrollBounds(f,e.offY.current,e.tgtY.current,e.bodyY.current,g,e.fs.zoom.panDuration);}function Rr(e){let{scale:r,imgW:n,imgH:t,currentImageEl:o,viewW:s,viewH:c$1,captionW:a,captionH:m,captionPlacement:u,reservedLeft:i,reservedRight:f$1,reservedTop:d$1,reservedBottom:g}=e,R=c(o)?.getBoundingClientRect()??null,v=s??R?.width??document.documentElement.clientWidth,T=c$1??R?.height??window.innerHeight,h=n*r,Y=t*r,E=(v-n)/2,w=(T-t)/2,b=R?.left??0,M=R?.top??0,X=b+E,Z=M+w,L=u==="left"?a??0:0,C=u==="right"?a??0:0,D=u==="top"?m??0:0,p=u==="bottom"?m??0:0,l=i??L,H=f$1??C,P=d$1??D,F=g??p,V=b-l,z=b+v+H,B=M-P,O=M+T+F,U=z-V,x=O-B,K,q,J,Q;if(h<=U){let I=(V+z)/2-X-h/2;K=I,q=I;}else q=V-X,K=z-h-X;if(Y<=x){let I=(B+O)/2-Z-Y/2;J=I,Q=I;}else Q=B-Z,J=O-Y-Z;return {x:d(K,q),y:d(J,Q),povX:f(U),povY:f(x)}}function Xr(e){let{setScale:r,zoomState:n,imageRefs:t,resetPan:o}=e,s=e.transition??"transform 0.2s cubic-bezier(.4,0,.22,1)",c="translate3d(0px, 0px, 0) scale(1)";r(1),n.previousZoom.current.x=0,n.previousZoom.current.y=0,n.panRef.current={x:0,y:0},n.scaleRef.current=1,t.current.forEach(a$1=>{let m=a$1.current;if(!m)return;let u=m.children[0];if(g(u))return;let i=a(m);if(!i)return;let f=s.match(/([\d.]+)s/),d=f?parseFloat(f[1])*1e3:300;i.style.transition=s,i.offsetWidth,i.style.transform=c,window.setTimeout(()=>{i.style.transition="";},d+50);}),o();}function Mr(e){let{currentImage:r,locX:n,prevX:t,offX:o,tgtX:s,locY:c$1,prevY:a$1,offY:m,tgtY:u,bodyX:i,bodyY:f,boundsX:d,boundsY:g$1,ScrollBody:R,ScrollBounds:v,baseFitSize:T,boundsForCurrent:h,panDuration:Y,panFriction:E,animRef:w}=e,b=r.current;if(!b||!n.current||!t.current||!o.current||!s.current||!c$1.current||!a$1.current||!m.current||!u.current)return;let M=b.children[0];if(g(M))return;let X=a(b);if(!X)return;w.current?.stop?.();let L=(c(b)??b).getBoundingClientRect(),C=L.width,D=L.height,{baseW:p,baseH:l}=T(X,C,D);n.current.set(0),t.current.set(0),o.current.set(0),s.current.set(0),c$1.current.set(0),a$1.current.set(0),m.current.set(0),u.current.set(0),i.current=R(n.current,o.current,t.current,s.current,Y,E).sync(),f.current=R(c$1.current,m.current,a$1.current,u.current,Y,E).sync();let{x:H,y:P,povX:F,povY:V}=h(1,p,l,C,D,{ignoreReserved:true});d.current=v(H,o.current,s.current,i.current,F,Y),g$1.current=v(P,m.current,u.current,f.current,V,Y),s.current.set(H.constrain(0)),u.current.set(P.constrain(0)),w.current?.resetBlend();}function Ye(e,r,n="instant"){let t={x:r.x,y:r.y};e.panRef&&(e.panRef.current=t),e.tgtX.current?.set(t.x),e.tgtY.current?.set(t.y),n!=="target"&&(e.offX.current?.set(t.x),e.locX.current?.set(t.x),e.prevX.current?.set(t.x),e.offY.current?.set(t.y),e.locY.current?.set(t.y),e.prevY.current?.set(t.y));}var Ce=260,he=1.01,$=new WeakMap,oe=new WeakMap;function Fe(e){let r=e.style.willChange;r.split(",").some(t=>t.trim()==="transform")||(e.style.willChange=r&&r!=="auto"?`${r}, transform`:"transform"),e.style.backfaceVisibility="hidden";}function Be(e){return typeof e=="object"&&e!=null&&e.__rmgZoomPanPlugin===true}function Oe(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function ze(e,r){let n=a(e.current);if(!n)return r;let t=typeof window<"u"&&typeof window.getComputedStyle=="function"?window.getComputedStyle(n).transform:n.style.transform;if(!t||t==="none")return r;let o=t.match(/matrix3d\(([^)]+)\)/);if(o){let a=o[1].split(",").map(Number.parseFloat);return Number.isFinite(a[0])?a[0]:r}let s=t.match(/matrix\(([^)]+)\)/);if(s){let a=s[1].split(",").map(Number.parseFloat),m=a[0]||0,u=a[1]||0,i=Math.hypot(m,u);return Number.isFinite(i)&&i>0?i:r}let c=t.match(/scale\(([-\d.]+)\)/);if(c){let a=Number.parseFloat(c[1]);return Number.isFinite(a)?a:r}return r}function Le(e){let r=a(e.current);if(!r)return;let n=$.get(r);n&&(window.cancelAnimationFrame(n.rafId),$.delete(r));}function Ie(e){let r=a(e.current);return r?$.get(r)??null:null}function kr(e){if(!e)return null;let r=e.plugins?.find(o=>Be(o)&&o.kind==="hover");if(!r)return null;let n=r.options??{};if(n.enabled===false)return null;let t=n.zoomOutDurationMs??Ce;return {enabled:true,zoomLevel:n.zoomLevel??e.clickZoomLevel,zoomInDurationMs:n.zoomInDurationMs??t,zoomOutDurationMs:t}}function Zr(e){let r=e.pointerType;return r&&r!=="mouse"?false:typeof window>"u"||typeof window.matchMedia!="function"?true:window.matchMedia("(hover: hover) and (pointer: fine)").matches}function De(e,r,n){e.locX.current&&e.locY.current||(e.locX.current=e.Vector1D(r),e.prevX.current=e.Vector1D(r),e.offX.current=e.Vector1D(r),e.tgtX.current=e.Vector1D(r),e.locY.current=e.Vector1D(n),e.prevY.current=e.Vector1D(n),e.offY.current=e.Vector1D(n),e.tgtY.current=e.Vector1D(n),e.bodyX.current=e.ScrollBody(e.locX.current,e.offX.current,e.prevX.current,e.tgtX.current,e.fs.zoom.panDuration,e.fs.zoom.panFriction).sync(),e.bodyY.current=e.ScrollBody(e.locY.current,e.offY.current,e.prevY.current,e.tgtY.current,e.fs.zoom.panDuration,e.fs.zoom.panFriction).sync());}function Me(e,r,n){if(!r.current)return null;e.currentImage.current=r.current;let t=e.currentImage.current,o=a(t);if(!o)return null;let c$1=(c(t)??t).getBoundingClientRect();if(h({width:c$1.width,height:c$1.height},o))return null;let{x:a$1,y:m}=A(o);De(e,a$1,m);let{baseW:u,baseH:i}=W(o,c$1.width,c$1.height),f=e.boundsForCurrent(n,u,i,c$1.width,c$1.height);return {imgEl:o,rect:c$1,bounds:f}}function Pe(e,r,n,t){let o=e.bounds.x.max-e.bounds.x.min,s=e.bounds.y.max-e.bounds.y.min;if(t){let m=e.rect.width>0?(r-t.clientX)/e.rect.width:0,u=e.rect.height>0?(n-t.clientY)/e.rect.height:0;return {x:e.bounds.x.constrain(t.target.x-o*m),y:e.bounds.y.constrain(t.target.y-s*u)}}let c=j(e.rect.width>0?(r-e.rect.left)/e.rect.width:.5,0,1),a=j(e.rect.height>0?(n-e.rect.top)/e.rect.height:.5,0,1);return {x:e.bounds.x.constrain(e.bounds.x.max-o*c),y:e.bounds.y.constrain(e.bounds.y.max-s*a)}}function me(e,r,n,t){oe.set(e,{clientX:r,clientY:n,target:{x:t.x,y:t.y}});}function we(e,r){e.boundsX.current=e.ScrollBounds(r.bounds.x,e.offX.current,e.tgtX.current,e.bodyX.current,r.bounds.povX,e.fs.zoom.panDuration),e.boundsY.current=e.ScrollBounds(r.bounds.y,e.offY.current,e.tgtY.current,e.bodyY.current,r.bounds.povY,e.fs.zoom.panDuration);}function ue(e,r,n="instant"){Ye(e,r,n);}function fe(e,r,n){let t=e.currentImage.current,o=b(t);if(!o.length)return;let s=`translate3d(${r.x}px, ${r.y}px, 0) scale(${n})`;o.forEach(c=>{Fe(c),c.style.transition&&(c.style.transition=""),c.style.transform=s;}),ue(e,r);}function Ae(e){let s=1.2000000000000002,c=3*(.22-.4)-s,a=1-s-c,m=0,u=3-m,i=1-m-u,f=e;for(let d=0;d<6;d+=1){let g=((a*f+c)*f+s)*f,R=(3*a*f+2*c)*f+s;if(Math.abs(g-e)<.001||Math.abs(R)<.001)break;f-=(g-e)/R,f=j(f,0,1);}return ((i*f+u)*f+m)*f}function Xe(e,r){let n=r-e.startMs,t=e.durationMs<=0?1:j(n/e.durationMs,0,1),o=Ae(t),s={x:e.fromX+(e.target.x-e.fromX)*o,y:e.fromY+(e.target.y-e.fromY)*o},c=e.fromScale+(e.targetScale-e.fromScale)*o;return e.currentX=s.x,e.currentY=s.y,fe(e.ctx,{x:e.currentX,y:e.currentY},c),t>=1}function We(e,r,n){let t=a(r.current);if(!t)return;Le(r);let o={ctx:e,imageRef:r,imgEl:t,rafId:0,startMs:Oe(),durationMs:n.durationMs,fromX:n.fromX,fromY:n.fromY,currentX:n.fromX,currentY:n.fromY,fromScale:n.fromScale,target:n.target,targetScale:n.targetScale};function s(c){if($.get(t)!==o)return;if(Xe(o,c)){$.delete(t),e.scaleRef.current=o.targetScale,e.setScale(o.targetScale),fe(e,o.target,o.targetScale);return}o.rafId=window.requestAnimationFrame(s);}$.set(t,o),Xe(o,o.startMs),o.rafId=window.requestAnimationFrame(s);}function Cr(e,r){let n=j(r.hover.zoomLevel,1,e.fs.zoom.maxZoomLevel);if(n<=he)return false;let t=Me(e,r.imageRef,n);if(!t)return false;let o=Pe(t,r.clientX,r.clientY);return we(e,t),me(t.imgEl,r.clientX,r.clientY,o),e.animRef.current?.stop(),e.suppressLoopRef.current=true,e.previousZoom.current.x=r.clientX-t.rect.left,e.previousZoom.current.y=r.clientY-t.rect.top,ue(e,o,"target"),e.scaleRef.current=n,e.setScale(n),We(e,r.imageRef,{fromX:e.offX.current?.get()??0,fromY:e.offY.current?.get()??0,fromScale:ze(r.imageRef,1),target:o,targetScale:n,durationMs:r.hover.zoomInDurationMs}),true}function Fr(e,r){let n=e.scaleRef.current;if(n<=he)return false;let t=Me(e,r.imageRef,n);if(!t)return false;let o=Pe(t,r.clientX,r.clientY,oe.get(t.imgEl));we(e,t),me(t.imgEl,r.clientX,r.clientY,o),e.suppressLoopRef.current=true,ue(e,o,"target");let s=Ie(r.imageRef);return s?(s.target=o,true):(e.animRef.current?.stop(),fe(e,o,n),true)}function Br(e,r){if(!r.imageRef.current)return false;e.currentImage.current=r.imageRef.current,De(e,e.offX.current?.get()??0,e.offY.current?.get()??0),Le(r.imageRef);let n=a(r.imageRef.current);return n&&oe.delete(n),e.animRef.current?.stop(),e.suppressLoopRef.current=false,e.previousZoom.current.x=0,e.previousZoom.current.y=0,e.panRef&&(e.panRef.current={x:0,y:0}),e.bodyX.current?.resetVelocity?.(),e.bodyX.current?.useDuration?.(0),e.bodyX.current?.useFriction?.(1),e.bodyX.current?.sync?.(),e.bodyY.current?.resetVelocity?.(),e.bodyY.current?.useDuration?.(0),e.bodyY.current?.useFriction?.(1),e.bodyY.current?.sync?.(),te(e,0,0,1,r.durationMs),true}function Or(e,r){let n=a(r.imageRef.current);if(!n)return false;let t=oe.get(n);t&&me(n,t.clientX,t.clientY,r.target),ue(e,r.target,r.syncMode??"target");let o=$.get(n);return o?(o.target=r.target,true):false}export{W as a,je as b,_e as c,Ge as d,xe as e,ar as f,pr as g,Rr as h,Xr as i,Mr as j,Ye as k,kr as l,Zr as m,Cr as n,Fr as o,Br as p,Or as q};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {k,h,j,a as a$2,i,g as g$1,f as f$1,e as e$1,l,m,n,o,d,c as c$3,b as b$2}from'./chunk-GS2GLLIJ.mjs';import {b,a as a$3,c as c$2,f as f$2,g as g$3}from'./chunk-ADIHG7AT.mjs';import {c}from'./chunk-P2GQPFSL.mjs';import {e,c as c$1,b as b$1}from'./chunk-HGY3QLCE.mjs';import {g as g$2}from'./chunk-UAEPMZQY.mjs';import {a as a$1}from'./chunk-B4CC5AGE.mjs';import {f,g}from'./chunk-HK2DPKES.mjs';import {a}from'./chunk-V7DPXRZF.mjs';import*as u from'react';var lt=300,mt="cubic-bezier(.4,0,.22,1)";function ft(i){return {enabled:i?.zoomFade!==false,durationMs:i?.zoomFadeDurationMs??lt,easing:i?.zoomFadeEasing??mt,zoomInTransform:i?.zoomInTransform??"",zoomOutTransform:i?.zoomOutTransform??""}}function $e(i){if(!(!i.enabled||i.durationMs<=0))return `opacity ${i.durationMs}ms ${i.easing}, transform ${i.durationMs}ms ${i.easing}`}function dt(i){let{phase:e,isZoomed:t,settings:r}=i;if(!r.enabled)return {phase:"visible",isZoomed:t,interactive:true,contentStyle:{}};let M=1,a="",v;switch(e){case "hiding":M=0,a=r.zoomInTransform,v=$e(r);break;case "hidden":M=0,a=r.zoomInTransform;break;case "showingStart":M=0,a=r.zoomOutTransform;break;case "showing":M=1,a="",v=$e(r);break;default:M=1,a="";break}return {phase:e,isZoomed:t,interactive:e==="visible",contentStyle:{opacity:M,transform:a,transition:v,willChange:"opacity, transform"}}}function Me(i){let{caption:e,isZoomed:t}=i,r=u.useMemo(()=>ft(e),[e?.zoomFade,e?.zoomFadeDurationMs,e?.zoomFadeEasing,e?.zoomInTransform,e?.zoomOutTransform]),[M,a]=u.useState(()=>r.enabled&&t?"hidden":"visible"),v=u.useRef(false),b=u.useRef(t),l=u.useRef(r.enabled);return u.useEffect(()=>{let w=b.current,P=l.current;if(b.current=t,l.current=r.enabled,!v.current){v.current=true,a(r.enabled&&t?"hidden":"visible");return}let h=0,p=0,c=0;return r.enabled?P!==r.enabled?(a(t?"hidden":"visible"),()=>{h&&cancelAnimationFrame(h),p&&cancelAnimationFrame(p),c&&clearTimeout(c);}):w===t?()=>{h&&cancelAnimationFrame(h),p&&cancelAnimationFrame(p),c&&clearTimeout(c);}:(t?(a("hiding"),r.durationMs<=0?a("hidden"):c=window.setTimeout(()=>{a("hidden");},r.durationMs+20)):(a("showingStart"),h=requestAnimationFrame(()=>{p=requestAnimationFrame(()=>{if(a("showing"),r.durationMs<=0){a("visible");return}c=window.setTimeout(()=>{a("visible");},r.durationMs+20);});})),()=>{h&&cancelAnimationFrame(h),p&&cancelAnimationFrame(p),c&&clearTimeout(c);}):(a("visible"),()=>{h&&cancelAnimationFrame(h),p&&cancelAnimationFrame(p),c&&clearTimeout(c);})},[t,r.enabled,r.durationMs]),u.useMemo(()=>dt({phase:M,isZoomed:t,settings:r}),[M,t,r])}function pt(i){if(i.ctrlKey)return true;let e=Math.abs(i.deltaX),t=Math.abs(i.deltaY);if(e<1&&t<1)return false;let r=e/t;return r>=.8&&r<=1.2}function Ge(i){let{scaleRef:e,zoomCtx:t,zoomTo:r,isZoomed:M,currentImage:a,imageRefs:v,fullscreenSliderApi:b,rebuildPanBodies:l,baseFitSize:w,boundsForCurrent:P,ScrollBounds:h,boundsX:p,boundsY:c,offX:D,offY:R,tgtX:C,tgtY:Z,bodyX:O,bodyY:z,animRef:E,panDuration:y,findImgAtPoint:H,readDataIndex:x,distance:F,midpoint:I}=i,Y=u.useRef(false),j=u.useRef(false),pe=u.useRef(false),U=u.useRef(0),re=u.useRef(1),oe=u.useCallback((o,f)=>{if(!f.current||!o.ctrlKey)return;o.preventDefault(),b.current?.centerSlider(),e.current>1.01&&(Y.current=true);let{ctrlKey:m,deltaMode:d}=o,{deltaY:g}=o;d===1&&(g*=15);let B=1-g/(m?100:300),_=e.current*B;r(t,{destZoomLevel:_,centerPoint:{x:o.clientX,y:o.clientY},imageRef:f});},[b,e,r,t]),$=u.useCallback(o=>{if(!M||pt(o)||o.ctrlKey||!a.current)return;o.preventDefault(),l();let f=a.current,m=c$2(f)?.getBoundingClientRect()??f.getBoundingClientRect(),d=m.width,g=m.height,A=a$3(f);if(!A)return;let{baseW:B,baseH:_}=w(A,d,g),{x:G,y:q,povX:Re,povY:be}=P(e.current,B,_,d,g);p.current=h(G,D.current,C.current,O.current,Re,y),c.current=h(q,R.current,Z.current,z.current,be,y);let S=(D.current?.get()??0)-o.deltaX,J=(R.current?.get()??0)-o.deltaY;S=G.constrain(S),J=q.constrain(J),C.current?.set(S),Z.current?.set(J),O.current?.useDuration(0).useFriction(1),z.current?.useDuration(0).useFriction(1),E.current?.start();},[M,a,l,w,P,e,p,c,h,D,R,C,Z,O,z,E,y]);u.useEffect(()=>(window.addEventListener("wheel",$,{passive:false}),()=>window.removeEventListener("wheel",$)),[$]),u.useLayoutEffect(()=>{function o(f){let m=H(document,f.clientX,f.clientY);if(!m)return;let d=x(m);if(d==null)return;let g=v.current[d];g&&(a.current=g.current,oe(f,g));}return window.addEventListener("wheel",o,{passive:false}),()=>window.removeEventListener("wheel",o)},[H,x,v,a,oe]);let X=u.useCallback(o=>{if(o.touches.length!==2)return;o.preventDefault(),b.current?.centerSlider(),j.current=true;let[f,m]=[o.touches[0],o.touches[1]];U.current=F(f,m),re.current=e.current;},[F,b,e]),ie=u.useCallback((o,f)=>{if(!j.current||o.touches.length!==2)return;o.preventDefault();let[m,d]=[o.touches[0],o.touches[1]],A=F(m,d)/U.current,B=re.current*A,_=I(m,d);r(t,{destZoomLevel:B,centerPoint:_,imageRef:f});},[F,I,r,t]),L=u.useCallback(()=>{j.current&&(j.current=false,pe.current=true);},[]);return u.useLayoutEffect(()=>{function o(f){if(f.touches.length<2)return;let m=I(f.touches[0],f.touches[1]),d=H(document,m.x,m.y);if(!d)return;let g=x(d);if(g==null)return;let A=v.current[g];A&&(a.current=A.current,ie(f,A));}return window.addEventListener("touchstart",X,{passive:false}),window.addEventListener("touchmove",o,{passive:false}),window.addEventListener("touchend",L),window.addEventListener("touchcancel",L),()=>{window.removeEventListener("touchstart",X),window.removeEventListener("touchmove",o),window.removeEventListener("touchend",L),window.removeEventListener("touchcancel",L);}},[X,ie,L,I,H,x,v,a]),{isPinching:Y,isTouchPinching:j}}function Ke(i){let{setScale:e,zoomState:t,imageRefs:r,resetPan:M,stopPanMotion:a}=i;if(t.scaleRef.current===1)return;t.changingSlides.current=true,t.suppressLoopRef.current=false,a?.(),e(1),t.previousZoom.current={x:0,y:0},t.panRef.current={x:0,y:0},t.scaleRef.current=1;let v=i.transition??"transform 0.2s cubic-bezier(.4,0,.22,1)",b="translate3d(0, 0, 0) scale(1)",l=v.trim()==="none",w=l?null:v.match(/([\d.]+)s/),P=w?parseFloat(w[1])*1e3:300;r.current.forEach(p=>{let c=p.current;if(!c)return;let D=c.children[0];if(g$2(D))return;let R=a$3(c);if(!R)return;let C=R.style.transition,Z=C==="none"?"":C;if(R.style.transition=v,R.offsetWidth,R.style.transform=b,l){requestAnimationFrame(()=>{R.style.transition===v&&(R.style.transition=Z);});return}window.setTimeout(()=>{R.style.transition===v&&(R.style.transition="");},P+50);}),M?.();let h=i.unlockDelayMs??(l?0:P+50);window.setTimeout(()=>{t.changingSlides.current=false;},h);}function qe(i$1){let{fs:e$2,entriesObject:t,hasEntriesViewportOverlay:r,layout:M,resolveFsCaptionPlacement:a,windowSize:v,currentImage:b$3,scaleRef:l$1,setScale:w,previousZoom:P,suppressLoopRef:h$1,locX:p,prevX:c$2,offX:D,tgtX:R,locY:C,prevY:Z,offY:O,tgtY:z,bodyX:E,bodyY:y,boundsX:H,boundsY:x,animRef:F,panRef:I,imageRefs:Y,changingSlides:j$1,fullscreenSliderApi:pe,isZoomed:U,pointerDownRef:re,interactionModeRef:oe,axisRef:$,suppressNextClickRef:X,closingModal:ie}=i$1,L=u.useRef(false),o$1=u.useRef(null),f$3=u.useRef(null),m$1=u.useCallback(()=>{L.current=false,o$1.current=null,f$3.current=null;},[]),d$1=u.useMemo(()=>k(e$2.zoom),[e$2.zoom]),g$2=u.useCallback((n,s,N,Q,W,ae)=>{let V=f(v.width),De=g(v.height),ee=e$2.caption?.layout!=="overlay",it=e$2.caption?.layout==="overlay"&&(e$2.caption?.width!=null||e$2.caption?.height!=null),se=ee||it?a(e$2.caption?.placement,e$2.caption?.breakpoint,V):null,ce=e$2.caption?.width==null?void 0:a$1(e$2.caption.width,280,V,V),ue=e$2.caption?.height==null?void 0:a$1(e$2.caption.height,200,V,De),le=r?a(t.overlay?.placement,t.overlay?.breakpoint,V):null,Ce=!r||t.overlay?.width==null?void 0:a$1(t.overlay.width,280,V,V),Ze=!r||t.overlay?.height==null?void 0:a$1(t.overlay.height,200,V,De),at=(se==="left"?ee?ce??280:ce??0:0)+(le==="left"?Ce??0:0),st=(se==="right"?ee?ce??280:ce??0:0)+(le==="right"?Ce??0:0),ct=(se==="top"?ee?ue??200:ue??0:0)+(le==="top"?Ze??0:0),ut=(se==="bottom"?ee?ue??200:ue??0:0)+(le==="bottom"?Ze??0:0),me=!ae?.ignoreReserved;return h({scale:n,imgW:s,imgH:N,currentImageEl:b$3.current,viewW:Q,viewH:W,reservedLeft:me?at:0,reservedRight:me?st:0,reservedTop:me?ct:0,reservedBottom:me?ut:0})},[b$3,t.overlay,t.render?.overlay,e$2.caption,r,M,a,v.height,v.width]);u.useEffect(()=>{$.current=c();},[$]);let A=u.useCallback((n,s)=>{if(j$1.current||!b$3.current)return;let N=b(b$3.current);if(!N.length)return;let Q=`translate3d(${n}px, ${s}px, 0) scale(${l$1.current})`;N.forEach(W=>{W.style.transition&&(W.style.transition=""),W.style.transform=Q;});},[j$1,b$3,l$1]),B=u.useCallback(()=>{F.current?.stop(),E.current?.useDuration(0).useFriction(1).sync(),y.current?.useDuration(0).useFriction(1).sync();let n=0,s=0;p.current?.set(n),c$2.current?.set(n),D.current?.set(n),R.current?.set(n),C.current?.set(s),Z.current?.set(s),O.current?.set(s),z.current?.set(s);},[F,E,y,p,C,D,O,c$2,Z,R,z]),_=u.useCallback(()=>{F.current?.stop(),j$1.current=false,h$1.current=false,E.current?.resetVelocity(),E.current?.useBaseDuration(),E.current?.useBaseFriction(),E.current?.sync(),y.current?.resetVelocity(),y.current?.useBaseDuration(),y.current?.useBaseFriction(),y.current?.sync();},[F,E,y,j$1,h$1]),G=u.useCallback(()=>{j({currentImage:b$3,locX:p,prevX:c$2,offX:D,tgtX:R,locY:C,prevY:Z,offY:O,tgtY:z,bodyX:E,bodyY:y,boundsX:H,boundsY:x,ScrollBody:c$1,ScrollBounds:e,baseFitSize:a$2,boundsForCurrent:g$2,panDuration:e$2.zoom?.panDuration,panFriction:e$2.zoom?.panFriction,animRef:F});},[F,E,y,g$2,H,x,b$3,e$2.zoom?.panDuration,e$2.zoom?.panFriction,p,C,D,O,c$2,Z,R,z]),q=u.useCallback(n=>{m$1();let s=!!n?.disableImageTransition;Ke({setScale:w,zoomState:{previousZoom:P,panRef:I,scaleRef:l$1,suppressLoopRef:h$1,changingSlides:j$1},imageRefs:Y,resetPan:G,stopPanMotion:B,transition:s?"none":void 0,unlockDelayMs:s?0:void 0});},[j$1,Y,I,P,m$1,G,l$1,w,B,h$1]),Re=u.useCallback(()=>{q({disableImageTransition:!!e$2.effects?.crossfade?.drag});},[e$2.effects?.crossfade?.drag,q]),be=u.useCallback(()=>{m$1(),i({setScale:w,zoomState:{previousZoom:P,panRef:I,scaleRef:l$1},imageRefs:Y,resetPan:G});},[Y,I,P,m$1,G,l$1,w]),S=u.useMemo(()=>({fs:e$2,currentImage:b$3,scaleRef:l$1,setScale:w,previousZoom:P,suppressLoopRef:h$1,locX:p,prevX:c$2,offX:D,tgtX:R,locY:C,prevY:Z,offY:O,tgtY:z,bodyX:E,bodyY:y,boundsX:H,boundsY:x,Vector1D:b$1,ScrollBody:c$1,ScrollBounds:e,boundsForCurrent:g$2,renderPan:A,animRef:F,panRef:I,resetAllZoomDom:_}),[F,E,y,g$2,H,x,b$3,e$2,p,C,D,O,I,c$2,Z,P,_,A,l$1,w,h$1,R,z]),J=u.useCallback(()=>{g$1({fs:e$2,currentImage:b$3,scaleRef:l$1,locX:p,prevX:c$2,offX:D,tgtX:R,locY:C,prevY:Z,offY:O,tgtY:z,bodyX:E,bodyY:y,boundsX:H,boundsY:x,Vector1D:b$1,ScrollBody:c$1,ScrollBounds:e,boundsForCurrent:g$2});},[g$2,E,y,H,x,b$3,e$2,p,C,D,O,c$2,Z,l$1,R,z]),{isPinching:Je,isTouchPinching:Qe}=Ge({scaleRef:l$1,zoomCtx:S,zoomTo:d,isZoomed:U,currentImage:b$3,imageRefs:Y,fullscreenSliderApi:pe,rebuildPanBodies:J,baseFitSize:a$2,boundsForCurrent:g$2,ScrollBounds:e,boundsX:H,boundsY:x,offX:D,offY:O,tgtX:R,tgtY:z,bodyX:E,bodyY:y,animRef:F,panDuration:e$2.zoom?.panDuration,findImgAtPoint:f$2,readDataIndex:g$3,distance:c$3,midpoint:b$2}),et=Me({caption:{zoomFade:t.overlay?.zoomFade,zoomFadeDurationMs:t.overlay?.zoomFadeDurationMs,zoomFadeEasing:t.overlay?.zoomFadeEasing,zoomInTransform:t.overlay?.zoomInTransform,zoomOutTransform:t.overlay?.zoomOutTransform},isZoomed:U}),tt=Me({caption:e$2.caption,isZoomed:U}),we=f$1({fs:e$2,isZoomed:U,zoomCtx:S,currentImage:b$3,rebuildPanBodies:J,renderPan:A,handleZoomToggle:e$1,suppressNextClickRef:X,pointerDownRef:re,interactionModeRef:oe,boundsX:H,boundsY:x,bodyX:E,bodyY:y,locX:p,locY:C,prevX:c$2,prevY:Z,offX:D,offY:O,tgtX:R,tgtY:z,axisRef:$,animRef:F}),nt=u.useCallback((n,s)=>!d$1||!l(n)||l$1.current>1.01||!m(S,{imageRef:s,clientX:n.clientX,clientY:n.clientY,hover:d$1})?false:(L.current=true,o$1.current=n.pointerId??null,f$3.current=s,true),[d$1,l$1,S]),ve=u.useCallback((n$1,s)=>!d$1||!l(n$1)?false:L.current?o$1.current!=null&&n$1.pointerId!==o$1.current?false:n(S,{imageRef:s,clientX:n$1.clientX,clientY:n$1.clientY}):l$1.current>1.01||!m(S,{imageRef:s,clientX:n$1.clientX,clientY:n$1.clientY,hover:d$1})?false:(L.current=true,o$1.current=n$1.pointerId??null,f$3.current=s,true),[d$1,S]),he=u.useCallback((n,s)=>!d$1||!L.current||!l(n)||o$1.current!=null&&n.pointerId!==o$1.current?false:(m$1(),o(S,{imageRef:s,durationMs:d$1.zoomOutDurationMs})),[d$1,m$1,S]);u.useEffect(()=>{if(!d$1)return;function n(s){if(!l(s))return;let N=f$2(document,s.clientX,s.clientY),Q=g$3(N),W=Q==null?null:Y.current[Q];if(W?.current){f$3.current=W,ve(s,W);return}if(!L.current)return;let ae=f$3.current;if(!ae?.current){m$1();return}he(s,ae);}return window.addEventListener("pointermove",n,{passive:true}),()=>{window.removeEventListener("pointermove",n);}},[he,ve,d$1,Y,m$1]);let rt=u.useCallback((n,s)=>{if(L.current&&l(n)){X.current=true,n.preventDefault(),n.stopPropagation();return}we.handlePanPointerStart(n,s);},[we,X]),ot=u.useCallback((n,s)=>{if(L.current&&l(n)){X.current=true,n.preventDefault(),n.stopPropagation();return}e$1(S,n,s);},[X,S]);return u.useEffect(()=>{F.current&&(m$1(),F.current.stop(),w(1),P.current.x=0,P.current.y=0,I.current={x:0,y:0},l$1.current=1);},[F,ie,I,P,m$1,l$1,w]),{isPinching:Je,isTouchPinching:Qe,entryOverlayZoomMotion:et,captionZoomMotion:tt,handlePanPointerStart:rt,handleZoomToggle:ot,resetAllZoomDom:q,resetForSlideNavigation:Re,forceResetZoom:be,handleHoverPointerEnter:nt,handleHoverPointerMove:ve,handleHoverPointerLeave:he}}function Rt(i){return a("zoom-pan",{options:i?{zoom:i}:void 0,runtime:{useZoomPanRuntime:qe}})}export{Rt as fullscreenZoomPan};
|
|
1
|
+
import {l,h,j,a as a$2,i,g as g$1,q,f as f$1,e as e$1,m,n,o,p,d,c as c$3,b as b$2}from'./chunk-WUB37KRW.mjs';import {b,a as a$3,c as c$2,f as f$2,g as g$3}from'./chunk-ADIHG7AT.mjs';import {c}from'./chunk-P2GQPFSL.mjs';import {e,c as c$1,b as b$1}from'./chunk-HGY3QLCE.mjs';import {g as g$2}from'./chunk-UAEPMZQY.mjs';import {a as a$1}from'./chunk-B4CC5AGE.mjs';import {f,g}from'./chunk-HK2DPKES.mjs';import {a}from'./chunk-V7DPXRZF.mjs';import*as u from'react';var ft=300,dt="cubic-bezier(.4,0,.22,1)";function pt(i){return {enabled:i?.zoomFade!==false,durationMs:i?.zoomFadeDurationMs??ft,easing:i?.zoomFadeEasing??dt,zoomInTransform:i?.zoomInTransform??"",zoomOutTransform:i?.zoomOutTransform??""}}function Ke(i){if(!(!i.enabled||i.durationMs<=0))return `opacity ${i.durationMs}ms ${i.easing}, transform ${i.durationMs}ms ${i.easing}`}function Rt(i){let{phase:e,isZoomed:t,settings:r}=i;if(!r.enabled)return {phase:"visible",isZoomed:t,interactive:true,contentStyle:{}};let M=1,s="",b;switch(e){case "hiding":M=0,s=r.zoomInTransform,b=Ke(r);break;case "hidden":M=0,s=r.zoomInTransform;break;case "showingStart":M=0,s=r.zoomOutTransform;break;case "showing":M=1,s="",b=Ke(r);break;default:M=1,s="";break}return {phase:e,isZoomed:t,interactive:e==="visible",contentStyle:{opacity:M,transform:s,transition:b,willChange:"opacity, transform"}}}function we(i){let{caption:e,isZoomed:t}=i,r=u.useMemo(()=>pt(e),[e?.zoomFade,e?.zoomFadeDurationMs,e?.zoomFadeEasing,e?.zoomInTransform,e?.zoomOutTransform]),[M,s]=u.useState(()=>r.enabled&&t?"hidden":"visible"),b=u.useRef(false),R=u.useRef(t),f=u.useRef(r.enabled);return u.useEffect(()=>{let w=R.current,P=f.current;if(R.current=t,f.current=r.enabled,!b.current){b.current=true,s(r.enabled&&t?"hidden":"visible");return}let v=0,d=0,l=0;return r.enabled?P!==r.enabled?(s(t?"hidden":"visible"),()=>{v&&cancelAnimationFrame(v),d&&cancelAnimationFrame(d),l&&clearTimeout(l);}):w===t?()=>{v&&cancelAnimationFrame(v),d&&cancelAnimationFrame(d),l&&clearTimeout(l);}:(t?(s("hiding"),r.durationMs<=0?s("hidden"):l=window.setTimeout(()=>{s("hidden");},r.durationMs+20)):(s("showingStart"),v=requestAnimationFrame(()=>{d=requestAnimationFrame(()=>{if(s("showing"),r.durationMs<=0){s("visible");return}l=window.setTimeout(()=>{s("visible");},r.durationMs+20);});})),()=>{v&&cancelAnimationFrame(v),d&&cancelAnimationFrame(d),l&&clearTimeout(l);}):(s("visible"),()=>{v&&cancelAnimationFrame(v),d&&cancelAnimationFrame(d),l&&clearTimeout(l);})},[t,r.enabled,r.durationMs]),u.useMemo(()=>Rt({phase:M,isZoomed:t,settings:r}),[M,t,r])}function bt(i){if(i.ctrlKey)return true;let e=Math.abs(i.deltaX),t=Math.abs(i.deltaY);if(e<1&&t<1)return false;let r=e/t;return r>=.8&&r<=1.2}function qe(i){let{scaleRef:e,zoomCtx:t,zoomTo:r,isZoomed:M,currentImage:s,imageRefs:b,fullscreenSliderApi:R,rebuildPanBodies:f,baseFitSize:w,boundsForCurrent:P,ScrollBounds:v,boundsX:d,boundsY:l,offX:D,offY:p,tgtX:C,tgtY:Z,bodyX:O,bodyY:z,animRef:y,panDuration:g,syncWheelPanTarget:k,findImgAtPoint:L,readDataIndex:E,distance:x,midpoint:I}=i,W=u.useRef(false),$=u.useRef(false),K=u.useRef(false),ae=u.useRef(0),ie=u.useRef(1),q=u.useCallback((o,c)=>{if(!c.current||!o.ctrlKey)return;o.preventDefault(),R.current?.centerSlider(),e.current>1.01&&(W.current=true);let{ctrlKey:m,deltaMode:h}=o,{deltaY:F}=o;h===1&&(F*=15);let N=1-F/(m?100:300),X=e.current*N;r(t,{destZoomLevel:X,centerPoint:{x:o.clientX,y:o.clientY},imageRef:c});},[R,e,r,t]),B=u.useCallback(o=>{if(!M||bt(o)||o.ctrlKey||!s.current)return;o.preventDefault(),f();let c=s.current,m=c$2(c)?.getBoundingClientRect()??c.getBoundingClientRect(),h=m.width,F=m.height,j=a$3(c);if(!j)return;let{baseW:N,baseH:X}=w(j,h,F),{x:J,y:se,povX:ve,povY:S}=P(e.current,N,X,h,F);d.current=v(J,D.current,C.current,O.current,ve,g),l.current=v(se,p.current,Z.current,z.current,S,g);let Q={x:J.constrain((D.current?.get()??0)-o.deltaX),y:se.constrain((p.current?.get()??0)-o.deltaY)},ce=k?.(Q)??false;ce||(C.current?.set(Q.x),Z.current?.set(Q.y)),O.current?.useDuration(0).useFriction(1),z.current?.useDuration(0).useFriction(1),ce||y.current?.start();},[M,s,f,w,P,e,d,l,v,D,p,C,Z,O,z,y,g,k]);u.useEffect(()=>(window.addEventListener("wheel",B,{passive:false}),()=>window.removeEventListener("wheel",B)),[B]),u.useLayoutEffect(()=>{function o(c){let m=L(document,c.clientX,c.clientY);if(!m)return;let h=E(m);if(h==null)return;let F=b.current[h];F&&(s.current=F.current,q(c,F));}return window.addEventListener("wheel",o,{passive:false}),()=>window.removeEventListener("wheel",o)},[L,E,b,s,q]);let te=u.useCallback(o=>{if(o.touches.length!==2)return;o.preventDefault(),R.current?.centerSlider(),$.current=true;let[c,m]=[o.touches[0],o.touches[1]];ae.current=x(c,m),ie.current=e.current;},[x,R,e]),A=u.useCallback((o,c)=>{if(!$.current||o.touches.length!==2)return;o.preventDefault();let[m,h]=[o.touches[0],o.touches[1]],j=x(m,h)/ae.current,N=ie.current*j,X=I(m,h);r(t,{destZoomLevel:N,centerPoint:X,imageRef:c});},[x,I,r,t]),H=u.useCallback(()=>{$.current&&($.current=false,K.current=true);},[]);return u.useLayoutEffect(()=>{function o(c){if(c.touches.length<2)return;let m=I(c.touches[0],c.touches[1]),h=L(document,m.x,m.y);if(!h)return;let F=E(h);if(F==null)return;let j=b.current[F];j&&(s.current=j.current,A(c,j));}return window.addEventListener("touchstart",te,{passive:false}),window.addEventListener("touchmove",o,{passive:false}),window.addEventListener("touchend",H),window.addEventListener("touchcancel",H),()=>{window.removeEventListener("touchstart",te),window.removeEventListener("touchmove",o),window.removeEventListener("touchend",H),window.removeEventListener("touchcancel",H);}},[te,A,H,I,L,E,b,s]),{isPinching:W,isTouchPinching:$}}function Je(i){let{setScale:e,zoomState:t,imageRefs:r,resetPan:M,stopPanMotion:s}=i;if(t.scaleRef.current===1)return;t.changingSlides.current=true,t.suppressLoopRef.current=false,s?.(),e(1),t.previousZoom.current={x:0,y:0},t.panRef.current={x:0,y:0},t.scaleRef.current=1;let b=i.transition??"transform 0.2s cubic-bezier(.4,0,.22,1)",R="translate3d(0px, 0px, 0) scale(1)",f=b.trim()==="none",w=f?null:b.match(/([\d.]+)s/),P=w?parseFloat(w[1])*1e3:300;r.current.forEach(d=>{let l=d.current;if(!l)return;let D=l.children[0];if(g$2(D))return;let p=a$3(l);if(!p)return;let C=p.style.transition,Z=C==="none"?"":C;if(p.style.transition=b,p.offsetWidth,p.style.transform=R,f){requestAnimationFrame(()=>{p.style.transition===b&&(p.style.transition=Z);});return}window.setTimeout(()=>{p.style.transition===b&&(p.style.transition="");},P+50);}),M?.();let v=i.unlockDelayMs??(f?0:P+50);window.setTimeout(()=>{t.changingSlides.current=false;},v);}function Qe(i$1){let{fs:e$2,entriesObject:t,hasEntriesViewportOverlay:r,layout:M,resolveFsCaptionPlacement:s,windowSize:b$3,currentImage:R,scaleRef:f$3,setScale:w,previousZoom:P,suppressLoopRef:v,locX:d$1,prevX:l$1,offX:D,tgtX:p$1,locY:C,prevY:Z,offY:O,tgtY:z,bodyX:y,bodyY:g$2,boundsX:k,boundsY:L,animRef:E,panRef:x,imageRefs:I,changingSlides:W,fullscreenSliderApi:$,isZoomed:K,pointerDownRef:ae,interactionModeRef:ie,axisRef:q$1,suppressNextClickRef:B,closingModal:te}=i$1,A=u.useRef(false),H=u.useRef(null),o$1=u.useRef(null),c$2=u.useCallback(()=>{A.current=false,H.current=null,o$1.current=null;},[]),m$1=u.useMemo(()=>l(e$2.zoom),[e$2.zoom]),h$1=u.useCallback((n,a,V,ee,_,ue)=>{let U=f(b$3.width),Ce=g(b$3.height),ne=e$2.caption?.layout!=="overlay",st=e$2.caption?.layout==="overlay"&&(e$2.caption?.width!=null||e$2.caption?.height!=null),le=ne||st?s(e$2.caption?.placement,e$2.caption?.breakpoint,U):null,me=e$2.caption?.width==null?void 0:a$1(e$2.caption.width,280,U,U),fe=e$2.caption?.height==null?void 0:a$1(e$2.caption.height,200,U,Ce),de=r?s(t.overlay?.placement,t.overlay?.breakpoint,U):null,Ze=!r||t.overlay?.width==null?void 0:a$1(t.overlay.width,280,U,U),Se=!r||t.overlay?.height==null?void 0:a$1(t.overlay.height,200,U,Ce),ct=(le==="left"?ne?me??280:me??0:0)+(de==="left"?Ze??0:0),ut=(le==="right"?ne?me??280:me??0:0)+(de==="right"?Ze??0:0),lt=(le==="top"?ne?fe??200:fe??0:0)+(de==="top"?Se??0:0),mt=(le==="bottom"?ne?fe??200:fe??0:0)+(de==="bottom"?Se??0:0),pe=!ue?.ignoreReserved;return h({scale:n,imgW:a,imgH:V,currentImageEl:R.current,viewW:ee,viewH:_,reservedLeft:pe?ct:0,reservedRight:pe?ut:0,reservedTop:pe?lt:0,reservedBottom:pe?mt:0})},[R,t.overlay,t.render?.overlay,e$2.caption,r,M,s,b$3.height,b$3.width]);u.useEffect(()=>{q$1.current=c();},[q$1]);let F=u.useCallback((n,a)=>{if(W.current||!R.current)return;let V=b(R.current);if(!V.length)return;let ee=`translate3d(${n}px, ${a}px, 0) scale(${f$3.current})`;V.forEach(_=>{_.style.transition&&(_.style.transition=""),_.style.transform=ee;});},[W,R,f$3]),j$1=u.useCallback(()=>{E.current?.stop(),y.current?.useDuration(0).useFriction(1).sync(),g$2.current?.useDuration(0).useFriction(1).sync();let n=0,a=0;d$1.current?.set(n),l$1.current?.set(n),D.current?.set(n),p$1.current?.set(n),C.current?.set(a),Z.current?.set(a),O.current?.set(a),z.current?.set(a);},[E,y,g$2,d$1,C,D,O,l$1,Z,p$1,z]),N=u.useCallback(()=>{E.current?.stop(),W.current=false,v.current=false,y.current?.resetVelocity(),y.current?.useBaseDuration(),y.current?.useBaseFriction(),y.current?.sync(),g$2.current?.resetVelocity(),g$2.current?.useBaseDuration(),g$2.current?.useBaseFriction(),g$2.current?.sync();},[E,y,g$2,W,v]),X=u.useCallback(()=>{j({currentImage:R,locX:d$1,prevX:l$1,offX:D,tgtX:p$1,locY:C,prevY:Z,offY:O,tgtY:z,bodyX:y,bodyY:g$2,boundsX:k,boundsY:L,ScrollBody:c$1,ScrollBounds:e,baseFitSize:a$2,boundsForCurrent:h$1,panDuration:e$2.zoom?.panDuration,panFriction:e$2.zoom?.panFriction,animRef:E});},[E,y,g$2,h$1,k,L,R,e$2.zoom?.panDuration,e$2.zoom?.panFriction,d$1,C,D,O,l$1,Z,p$1,z]),J=u.useCallback(n=>{c$2();let a=!!n?.disableImageTransition;Je({setScale:w,zoomState:{previousZoom:P,panRef:x,scaleRef:f$3,suppressLoopRef:v,changingSlides:W},imageRefs:I,resetPan:X,stopPanMotion:j$1,transition:a?"none":void 0,unlockDelayMs:a?0:void 0});},[W,I,x,P,c$2,X,f$3,w,j$1,v]),se=u.useCallback(()=>{J({disableImageTransition:!!e$2.effects?.crossfade?.drag});},[e$2.effects?.crossfade?.drag,J]),ve=u.useCallback(()=>{c$2(),i({setScale:w,zoomState:{previousZoom:P,panRef:x,scaleRef:f$3},imageRefs:I,resetPan:X});},[I,x,P,c$2,X,f$3,w]),S=u.useMemo(()=>({fs:e$2,currentImage:R,scaleRef:f$3,setScale:w,previousZoom:P,suppressLoopRef:v,locX:d$1,prevX:l$1,offX:D,tgtX:p$1,locY:C,prevY:Z,offY:O,tgtY:z,bodyX:y,bodyY:g$2,boundsX:k,boundsY:L,Vector1D:b$1,ScrollBody:c$1,ScrollBounds:e,boundsForCurrent:h$1,renderPan:F,animRef:E,panRef:x,resetAllZoomDom:N}),[E,y,g$2,h$1,k,L,R,e$2,d$1,C,D,O,x,l$1,Z,P,N,F,f$3,w,v,p$1,z]),Q=u.useCallback(()=>{g$1({fs:e$2,currentImage:R,scaleRef:f$3,locX:d$1,prevX:l$1,offX:D,tgtX:p$1,locY:C,prevY:Z,offY:O,tgtY:z,bodyX:y,bodyY:g$2,boundsX:k,boundsY:L,Vector1D:b$1,ScrollBody:c$1,ScrollBounds:e,boundsForCurrent:h$1});},[h$1,y,g$2,k,L,R,e$2,d$1,C,D,O,l$1,Z,f$3,p$1,z]),ce=u.useCallback(n=>{if(!A.current)return false;let a=o$1.current;return a?.current?q(S,{imageRef:a,target:n,syncMode:"target"}):false},[S]),{isPinching:et,isTouchPinching:tt}=qe({scaleRef:f$3,zoomCtx:S,zoomTo:d,isZoomed:K,currentImage:R,imageRefs:I,fullscreenSliderApi:$,rebuildPanBodies:Q,baseFitSize:a$2,boundsForCurrent:h$1,ScrollBounds:e,boundsX:k,boundsY:L,offX:D,offY:O,tgtX:p$1,tgtY:z,bodyX:y,bodyY:g$2,animRef:E,panDuration:e$2.zoom?.panDuration,syncWheelPanTarget:ce,findImgAtPoint:f$2,readDataIndex:g$3,distance:c$3,midpoint:b$2}),nt=we({caption:{zoomFade:t.overlay?.zoomFade,zoomFadeDurationMs:t.overlay?.zoomFadeDurationMs,zoomFadeEasing:t.overlay?.zoomFadeEasing,zoomInTransform:t.overlay?.zoomInTransform,zoomOutTransform:t.overlay?.zoomOutTransform},isZoomed:K}),rt=we({caption:e$2.caption,isZoomed:K}),De=f$1({fs:e$2,isZoomed:K,zoomCtx:S,currentImage:R,rebuildPanBodies:Q,renderPan:F,handleZoomToggle:e$1,suppressNextClickRef:B,pointerDownRef:ae,interactionModeRef:ie,boundsX:k,boundsY:L,bodyX:y,bodyY:g$2,locX:d$1,locY:C,prevX:l$1,prevY:Z,offX:D,offY:O,tgtX:p$1,tgtY:z,axisRef:q$1,animRef:E}),ot=u.useCallback((n$1,a)=>!m$1||!m(n$1)||f$3.current>1.01||!n(S,{imageRef:a,clientX:n$1.clientX,clientY:n$1.clientY,hover:m$1})?false:(A.current=true,H.current=n$1.pointerId??null,o$1.current=a,true),[m$1,f$3,S]),he=u.useCallback((n$1,a)=>!m$1||!m(n$1)?false:A.current?H.current!=null&&n$1.pointerId!==H.current?false:o(S,{imageRef:a,clientX:n$1.clientX,clientY:n$1.clientY}):f$3.current>1.01||!n(S,{imageRef:a,clientX:n$1.clientX,clientY:n$1.clientY,hover:m$1})?false:(A.current=true,H.current=n$1.pointerId??null,o$1.current=a,true),[m$1,S]),ge=u.useCallback((n,a)=>!m$1||!A.current||!m(n)||H.current!=null&&n.pointerId!==H.current?false:(c$2(),p(S,{imageRef:a,durationMs:m$1.zoomOutDurationMs})),[m$1,c$2,S]);u.useEffect(()=>{if(!m$1)return;function n(a){if(!m(a))return;let V=f$2(document,a.clientX,a.clientY),ee=g$3(V),_=ee==null?null:I.current[ee];if(_?.current){o$1.current=_,he(a,_);return}if(!A.current)return;let ue=o$1.current;if(!ue?.current){c$2();return}ge(a,ue);}return window.addEventListener("pointermove",n,{passive:true}),()=>{window.removeEventListener("pointermove",n);}},[ge,he,m$1,I,c$2]);let at=u.useCallback((n,a)=>{if(A.current&&m(n)){B.current=true,n.preventDefault(),n.stopPropagation();return}De.handlePanPointerStart(n,a);},[De,B]),it=u.useCallback((n,a)=>{if(A.current&&m(n)){B.current=true,n.preventDefault(),n.stopPropagation();return}e$1(S,n,a);},[B,S]);return u.useEffect(()=>{E.current&&(c$2(),E.current.stop(),w(1),P.current.x=0,P.current.y=0,x.current={x:0,y:0},f$3.current=1);},[E,te,x,P,c$2,f$3,w]),{isPinching:et,isTouchPinching:tt,entryOverlayZoomMotion:nt,captionZoomMotion:rt,handlePanPointerStart:at,handleZoomToggle:it,resetAllZoomDom:J,resetForSlideNavigation:se,forceResetZoom:ve,handleHoverPointerEnter:ot,handleHoverPointerMove:he,handleHoverPointerLeave:ge}}function vt(i){return a("zoom-pan",{options:i?{zoom:i}:void 0,runtime:{useZoomPanRuntime:Qe}})}export{vt as fullscreenZoomPan};
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as Video}from'./chunk-OGJM6C5S.mjs';export{a as ZoomPanImage}from'./chunk-
|
|
1
|
+
export{a as Video}from'./chunk-OGJM6C5S.mjs';export{a as ZoomPanImage}from'./chunk-HLFWK42L.mjs';import'./chunk-4VHNCVVB.mjs';export{a as Masonry}from'./chunk-QTYAL6FT.mjs';import'./chunk-EFXHC36P.mjs';export{a as useImageDecodeReady}from'./chunk-XWQTD7UK.mjs';export{c as Reveal,b as useReveal}from'./chunk-RRBBXIE3.mjs';import'./chunk-C6PKH3FH.mjs';import'./chunk-PFEGIWQJ.mjs';import'./chunk-WUB37KRW.mjs';import'./chunk-ADIHG7AT.mjs';export{a as useFullscreenController}from'./chunk-26PS4IG4.mjs';import'./chunk-PZAXFO2B.mjs';import'./chunk-JJMFOLJZ.mjs';export{a as FullscreenThumbnailSlider}from'./chunk-AJHLDKVD.mjs';export{b as ThumbnailSlider,a as createThumbnailSyncBridge}from'./chunk-4QZCHWR5.mjs';import'./chunk-R6EGYRTJ.mjs';import'./chunk-P2GQPFSL.mjs';export{a as Grid}from'./chunk-RHLMEEWI.mjs';import'./chunk-RLT5FULN.mjs';export{l as Entries,j as flattenEntries}from'./chunk-QBGBTFT4.mjs';export{a as Slider}from'./chunk-OGQBQQGU.mjs';import'./chunk-LVMYHM4T.mjs';export{a as useSliderReady}from'./chunk-VWEQRZ24.mjs';import'./chunk-WS5Y5APY.mjs';export{c as Skeleton}from'./chunk-ZE6FIVKA.mjs';import'./chunk-DJFTY42G.mjs';import'./chunk-WE3JOHED.mjs';import'./chunk-Q7CX2MQ5.mjs';export{a as useMasonryReady}from'./chunk-ZCCYTID7.mjs';export{c as createSliderIndexChannel}from'./chunk-CEMJWOHJ.mjs';import'./chunk-4NT4UVB5.mjs';import'./chunk-ZSA3W246.mjs';import'./chunk-HGY3QLCE.mjs';import'./chunk-KPO3JTL2.mjs';import'./chunk-Y7NUGXTR.mjs';import'./chunk-A6MPGIEJ.mjs';import'./chunk-D3T6HIS2.mjs';import'./chunk-AKY343WN.mjs';import'./chunk-QE3NYNL4.mjs';import'./chunk-UUAWLGWO.mjs';import'./chunk-X4HEGEZV.mjs';export{a as useGridReady}from'./chunk-STRS7UNJ.mjs';import'./chunk-536MNOJH.mjs';import'./chunk-UAEPMZQY.mjs';import'./chunk-I3HJIUHX.mjs';import'./chunk-YOOKXYP6.mjs';import'./chunk-UP6P6CQS.mjs';import'./chunk-NHIKOJLU.mjs';import'./chunk-LVYED5ZM.mjs';import'./chunk-UML6FCOQ.mjs';export{b as GalleryCore,c as useGalleryCore}from'./chunk-WMG2LTLR.mjs';export{a as toMediaItems}from'./chunk-L2HRIINV.mjs';import'./chunk-B4CC5AGE.mjs';export{a as BREAKPOINT_MAP}from'./chunk-HK2DPKES.mjs';
|