@kaktos/flipbook-react 1.0.1 → 1.0.2
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/dist/react-flipbook.cjs +1 -1
- package/dist/react-flipbook.css +1 -1
- package/dist/react-flipbook.js +315 -311
- package/package.json +1 -1
package/dist/react-flipbook.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("react/jsx-runtime"),e=require("react");function he(c){if(c&&c.constructor===Array){var o=c.filter(function(b){return typeof b=="number"}).filter(function(b){return!isNaN(b)});if(c.length===6&&o.length===6){var s=$t();return s[0]=o[0],s[1]=o[1],s[4]=o[2],s[5]=o[3],s[12]=o[4],s[13]=o[5],s}else if(c.length===16&&o.length===16)return c}throw new TypeError("Expected a `number[]` with length 6 or 16.")}function $t(){for(var c=[],o=0;o<16;o++)o%5==0?c.push(1):c.push(0);return c}function _n(c,o){for(var s=he(c),b=he(o),x=[],v=0;v<4;v++)for(var j=[s[v],s[v+4],s[v+8],s[v+12]],L=0;L<4;L++){var I=L*4,F=[b[I],b[I+1],b[I+2],b[I+3]],C=j[0]*F[0]+j[1]*F[1]+j[2]*F[2]+j[3]*F[3];x[v+I]=C}return x}function Tn(c){var o=$t();return o[11]=-1/c,o}function Fn(c){var o=Math.PI/180*c,s=$t();return s[0]=s[10]=Math.cos(o),s[2]=s[8]=Math.sin(o),s[2]*=-1,s}function En(c){return"matrix3d("+he(c).join(", ")+")"}function Ye(c,o,s){var b=$t();return c!==void 0&&o!==void 0&&s!==void 0&&(b[12]=c,b[13]=o,b[14]=s),b}class ee{constructor(o){o?o instanceof ee?this.m=[...o.m]:this.m=[...o]:this.m=$t()}clone(){return new ee(this)}multiply(o){this.m=_n(this.m,o)}perspective(o){this.multiply(Tn(o))}transformX(o){return(o*this.m[0]+this.m[12])/(o*this.m[3]+this.m[15])}translate(o,s){this.multiply(Ye(o,s??0,0))}translate3d(o,s,b){this.multiply(Ye(o,s,b))}rotateY(o){this.multiply(Fn(o))}toString(){return En(this.m)}}function Dn(c,o,s){const[b,x]=e.useState(0),[v,j]=e.useState(0),[L,I]=e.useState(1),[F,C]=e.useState(0);return e.useEffect(()=>{const S=()=>{const $=c.current;if(!$)return;x($.clientWidth),j($.clientHeight);const g=$.clientWidth>$.clientHeight&&!o?2:1;I(g),g===2&&C(Q=>Q+1)};return window.addEventListener("resize",S,{passive:!0}),S(),()=>window.removeEventListener("resize",S)},[o,c]),{viewWidth:b,viewHeight:v,rawDisplayedPages:L,pageAlignmentTick:F}}function jn(c,o,s,b,x,v,j){const[L,I]=e.useState(null),[F,C]=e.useState(null),[S,$]=e.useState({}),g=e.useRef({}),Q=e.useRef({count:0,target:0,cb:null}),rt=e.useRef(new Set),ot=e.useCallback((f,d=!1)=>{if(d&&x>1&&!v){const i=o[f];if(i)return i}return c[f]??null},[c,o,x,v]),U=e.useCallback(f=>L===null||S[f]?f:(g.current[f]||(g.current[f]=null,rt.current.add(f)),j),[L,S,j]);e.useEffect(()=>{const f=rt.current;f.size!==0&&(f.forEach(d=>{if(g.current[d])return;const i=new Image;g.current[d]=i,i.onload=()=>{$(_=>({..._,[d]:!0}))},i.src=d}),f.clear())});const X=e.useCallback((f,d=!1)=>{const i=ot(f,d);return d&&x>1&&!v?i:i?U(i):null},[ot,U,x,v]),st=e.useCallback((f=!1)=>{for(let d=s-3;d<=s+3;d++)X(d);if(f)for(let d=s;d<s+b;d++){const i=o[d];if(i&&!g.current[i]){const _=new Image;g.current[i]=_,_.src=i}}},[s,b,o,X]),J=e.useCallback(f=>{const d=f.target;L===null&&(I(d.naturalWidth),C(d.naturalHeight));const i=Q.current;i.cb&&(i.count++,i.count>=i.target&&(i.cb(),i.cb=null))},[L]),tt=e.useCallback((f,d)=>{Q.current={count:0,target:f,cb:d}},[]);return{imageWidth:L,imageHeight:F,loadedImages:S,pageUrl:ot,loadImage:U,pageUrlLoading:X,preloadImages:st,onImageLoad:J,setImageLoadCallback:tt}}const zn="data:image/svg+xml,%3c?xml%20version='1.0'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='500'%20height='500'%20viewBox='0%200%20500%20500'%20fill='transparent'%20style='background-color:%20%23fff'%3e%3ccircle%20cx='250'%20cy='250'%20r='48'%20stroke='%23333'%20stroke-width='2'%20stroke-dasharray='271%2030'%20%3e%3canimateTransform%20attributeName='transform'%20attributeType='XML'%20type='rotate'%20from='0%20250%20250'%20to='360%20250%20250'%20dur='1s'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3c/svg%3e",On="_root_1ydjt_1",Zn="_viewport_1ydjt_8",Wn="_viewportZoom_1ydjt_14 _viewport_1ydjt_8",Nn="_viewportZoomDragToScroll_1ydjt_19 _viewportZoom_1ydjt_14 _viewport_1ydjt_8",$n="_container_1ydjt_24",Xn="_clickLeft_1ydjt_40 _clickToFlip_1ydjt_32",Hn="_clickRight_1ydjt_45 _clickToFlip_1ydjt_32",Bn="_boundingBox_1ydjt_50",Un="_page_1ydjt_55",Yn="_polygon_1ydjt_60",An="_polygonBlank_1ydjt_69 _polygon_1ydjt_60",Gn="_lighting_1ydjt_74",Kn="_srOnly_1ydjt_79",T={root:On,viewport:Zn,viewportZoom:Wn,viewportZoomDragToScroll:Nn,container:$n,clickLeft:Xn,clickRight:Hn,boundingBox:Bn,page:Un,polygon:Yn,polygonBlank:An,lighting:Gn,srOnly:Kn};function Ge(c){return c*c}function qn(c){return 1-Ge(1-c)}function Ae(c){return c<.5?Ge(c*2)/2:.5+qn((c-.5)*2)/2}const Nt={progress:0,direction:null,frontImage:null,backImage:null,auto:!1};function Vn(c,o){const{pages:s,pagesHiRes:b=[],flipDuration:x=1e3,zoomDuration:v=500,zooms:j=[1,2,4],perspective:L=2400,nPolygons:I=10,ambient:F=.4,gloss:C=.6,swipeMin:S=3,singlePage:$=!1,forwardDirection:g="right",centering:Q=!0,startPage:rt=null,loadingImage:ot=zn,clickToZoom:U=!0,dragToFlip:X=!0,wheel:st="scroll",page:J,onPageChange:tt}=c,f=j??[1],d=s[0]===null,{viewWidth:i,viewHeight:_,rawDisplayedPages:pt,pageAlignmentTick:ne}=Dn(o,$),[re,Xt]=e.useState(0),Mt=J!==void 0,E=Mt?J:re,H=e.useCallback(t=>{if(Mt){const r=typeof t=="function"?t(J):t;tt?.(r)}else Xt(t)},[Mt,J,tt]),[Ht,n]=e.useState(0),[wt,xt]=e.useState(1),[l,oe]=e.useState(f[0]),[Bt,se]=e.useState(0),[Lt,pe]=e.useState(!1),[M,B]=e.useState(Nt),[Ut,ae]=e.useState(null),[,me]=e.useState(0),h=pt===2&&(d&&(E===0||E===1))?1:pt,Ke=jn(s,b,E,h,l,Lt,ot),{imageWidth:mt,imageHeight:Yt,pageUrl:Ct,loadImage:qe,pageUrlLoading:Ve,preloadImages:At,onImageLoad:Qe,setImageLoadCallback:Gt}=Ke,St=e.useRef(null),be=e.useRef(null),bt=e.useRef(0),yt=e.useRef(null),Y=e.useRef(!1),Kt=e.useRef(!1),at=e.useRef(1/0),ct=e.useRef(-1/0),ye=e.useRef(0),ke=e.useRef(0),_t=e.useRef(0),Tt=e.useRef(0),Ft=e.useRef(!1),q=e.useRef(M);q.current=M;const kt=e.useRef(E);kt.current=E;const qt=e.useRef(h);qt.current=h;const Et=e.useRef(l);Et.current=l;const Vt=e.useRef(Bt);Vt.current=Bt;const Re=e.useRef(c.onFlipLeftStart);Re.current=c.onFlipLeftStart;const ve=e.useRef(c.onFlipLeftEnd);ve.current=c.onFlipLeftEnd;const Pe=e.useRef(c.onFlipRightStart);Pe.current=c.onFlipRightStart;const Ie=e.useRef(c.onFlipRightEnd);Ie.current=c.onFlipRightEnd;const Me=e.useRef(c.onZoomStart);Me.current=c.onZoomStart;const we=e.useRef(c.onZoomEnd);we.current=c.onZoomEnd;const Je=e.useRef(tt);Je.current=tt;const xe=e.useRef(H);xe.current=H;const ce=e.useRef(new Set),D=e.useCallback(t=>{const r=requestAnimationFrame(a=>{ce.current.delete(r),t(a)});return ce.current.add(r),r},[]),Le=d?s.length-1:s.length,Qt=d?Math.max(1,E):E+1,Ce=e.useRef({canFlipLeft:!1,canFlipRight:!1,canZoomIn:!1,canZoomOut:!1,page:0,numPages:0}),Se=e.useCallback(()=>{H(t=>h===1&&t===0&&s.length>0&&!s[0]?1:t)},[h,s,H]),_e=!M.direction&&E<s.length-h,Te=!M.direction&&E>=h&&!(h===1&&!Ct(Ht-1)),et=g==="left"?_e:Te,nt=g==="right"?_e:Te,it=!Lt&&Bt<f.length-1,lt=!Lt&&Bt>0;Ce.current={canFlipLeft:et,canFlipRight:nt,canZoomIn:it,canZoomOut:lt,page:Qt,numPages:Le};const ie=g==="right"||h===1?Ht:wt,le=g==="left"?Ht:wt,tn=!!Ct(ie),en=!!Ct(le)&&h===2,Fe=mt&&Yt?Math.min(i/h/mt,_/Yt,1):1,P=mt?Math.round(mt*Fe):0,ut=Yt?Math.round(Yt*Fe):0,A=(i-P*h)/2,ft=(_-ut)/2,nn=Math.ceil(P/I+1/l)+"px",rn=ut+"px",on=`${P}px ${ut}px`,sn=e.useMemo(()=>{if(!M.direction||h!==1)return 1;let t=M.progress;return M.direction!==g&&(t=1-t),t>.7?1-(t-.7)/.3:1},[M.direction,M.progress,h,g]),gt=(()=>{if(h===1)return A;const t=Ct(ie)?A:i/2;return M.direction?t<at.current?t:at.current:t})(),Dt=(()=>{if(h===1)return i-A;const t=Ct(le)?i-A:i/2;return M.direction?t>ct.current?t:ct.current:t})(),dt=Q?Math.round(i/2-(gt+Dt)/2):0,Ee=e.useRef(dt);Ee.current=dt;const De=e.useRef(h);e.useEffect(()=>{Ut===null&&mt!==null&&ae(dt)},[Ut,mt,dt]),e.useEffect(()=>{De.current!==h&&(De.current=h,ae(dt),Ft.current=!1)},[h,dt]);const jt=Math.round(Ut??0),an=yt.current?yt.current:U&&it?"zoom-in":U&<?"zoom-out":X?"grab":"auto",cn=!Y.current,ln=(Lt||l>1)&&cn?T.viewportZoomDragToScroll:Lt||l>1?T.viewportZoom:T.viewport,un=(()=>{const t=(Dt-gt)*l;return t<i?(gt+jt)*l-(i-t)/2:(gt+jt)*l})(),fn=(()=>{const t=(Dt-gt)*l;return t<i?(gt+jt)*l-(i-t)/2:(Dt+jt)*l-i})(),gn=(()=>{const t=ut*l;return t<_?ft*l-(_-t)/2:ft*l})(),dn=(()=>{const t=ut*l;return t<_?ft*l-(_-t)/2:(ft+ut)*l-_})(),je=Math.min(fn,Math.max(un,_t.current)),ze=Math.min(dn,Math.max(gn,Tt.current)),Oe=e.useCallback((t,r)=>{const a=[],u=[-.5,-.25,0,.25,.5];if(F<1){const p=1-F,m=u.map(y=>(1-Math.cos((t-r*y)/180*Math.PI))*p);a.push(`linear-gradient(to right,rgba(0,0,0,${m[0]}),rgba(0,0,0,${m[1]}) 25%,rgba(0,0,0,${m[2]}) 50%,rgba(0,0,0,${m[3]}) 75%,rgba(0,0,0,${m[4]}))`)}if(C>0){const y=u.map(k=>Math.max(Math.pow(Math.cos((t+30-r*k)/180*Math.PI),200),Math.pow(Math.cos((t-30-r*k)/180*Math.PI),200)));a.push(`linear-gradient(to right,rgba(255,255,255,${y[0]*C}),rgba(255,255,255,${y[1]*C}) 25%,rgba(255,255,255,${y[2]*C}) 50%,rgba(255,255,255,${y[3]*C}) 75%,rgba(255,255,255,${y[4]*C}))`)}return a.join(",")},[F,C]),ue=e.useCallback(t=>{const r=q.current;if(!r.direction)return[];if(!Number.isFinite(P)||P<=0||I<=0)return[];let a=r.progress,u=r.direction;if(!Number.isFinite(a))return[];a<0&&(a=0),a>1&&(a=1),h===1&&u!==g&&(a=1-a,u=g);const p=t==="front"?r.frontImage:r.backImage,m=P/I;let y=A,k=!1;h===1?g==="right"?t==="back"&&(k=!0,y=A-P):u==="left"?t==="back"?y=P-A:k=!0:t==="front"?y=P-A:k=!0:u==="left"?t==="back"?y=i/2:k=!0:t==="front"?y=i/2:k=!0;const R=new ee;R.translate(i/2),R.perspective(L),R.translate(-i/2),R.translate(y,ft);let z=0;a>.5&&(z=-(a-.5)*2*180),u==="left"&&(z=-z),t==="back"&&(z+=180),z&&(k&&R.translate(P),R.rotateY(z),k&&R.translate(-P));let w;a<.5?w=a*2*Math.PI:w=(1-(a-.5)*2)*Math.PI,w===0&&(w=1e-9);const ht=P/w;let W=0;const O=w/I;let N=O/2/Math.PI*180;const V=O/Math.PI*180;k&&(N=-w/Math.PI*180+V/2),t==="back"&&(N=-N);const Zt=t==="back"?-V:V;at.current=1/0,ct.current=-1/0;const K=[];for(let Jt=0;Jt<I;Jt++){const Cn=`${Jt/(I-1)*100}% 0px`,Wt=R.clone(),He=k?w-W:W;let de=Math.sin(He)*ht;k&&(de=P-de);let te=(1-Math.cos(He))*ht;t==="back"&&(te=-te),Wt.translate3d(de,0,te),Wt.rotateY(-N);const Be=Wt.transformX(0),Ue=Wt.transformX(m);ct.current=Math.max(Math.max(Be,Ue),ct.current),at.current=Math.min(Math.min(Be,Ue),at.current);const Sn=Oe(z-N,Zt);W+=O,N+=Zt,K.push({key:t+Jt,bgImage:p,lighting:Sn,bgPos:Cn,transform:Wt.toString(),z:Math.abs(Math.round(te))})}return K},[h,g,P,A,ft,i,L,I,Oe]),hn=e.useMemo(()=>M.direction?[...ue("front"),...ue("back")]:[],[M.direction,M.progress,M.frontImage,M.backImage,ue]),G=e.useCallback((t,r)=>{const a=kt.current,u=qt.current;let p=null,m=null;t!==g?u===1?(p=s[a-1]??null,m=null):(p=s[g==="right"||u===1?a:a+1]??null,m=s[a-u+1]??null):u===1?(p=s[a]??null,m=null):(p=s[g==="left"?a:a+1]??null,m=s[a+u]??null),B({progress:0,direction:t,frontImage:p,backImage:m,auto:!1}),D(()=>{D(()=>{t!==g?u===2&&n(a-u):u===1?n(a+u):xt(a+1+u),r&&fe(t)})})},[g,s,D]),fe=e.useCallback(t=>{const r=q.current,a=x*(1-r.progress),u=r.progress;B(R=>({...R,auto:!0}));const p=kt.current,m=s[0]!==null?p+1:Math.max(1,p);t==="left"?Re.current?.(m):Pe.current?.(m);let y=null;const k=R=>{y===null&&(y=R);const z=R-y;let w=u+z/a;w>1&&(w=1);const ht=Ae(w);if(B(W=>({...W,progress:ht})),w<1)D(k);else{const W=qt.current;let O;t!==g?O=kt.current-W:O=kt.current+W,xe.current(O);const N=s[0]!==null?O+1:Math.max(1,O);t==="left"?ve.current?.(N):Ie.current?.(N),W===1&&t===g?B(Nt):Gt(1,()=>{B(Nt)})}};D(k)},[x,g,s,Gt,D]),Ze=e.useCallback(()=>{const t=q.current,r=x*t.progress,a=t.progress;B(m=>({...m,auto:!0}));let u=null;const p=m=>{u===null&&(u=m);const y=m-u;let k=a-a*y/r;if(k<0&&(k=0),B(R=>({...R,progress:k})),k>0)D(p);else{const R=kt.current;n(R),xt(R+1);const z=qt.current,w=q.current.direction;z===1&&w!==g?B(Nt):Gt(1,()=>{B(Nt)})}};D(p)},[x,g,Gt,D]),pn=e.useCallback(()=>{et&&G("left",!0)},[et,G]),mn=e.useCallback(()=>{nt&&G("right",!0)},[nt,G]),Rt=e.useCallback((t,r)=>{const a=o.current;if(!a)return;let u,p;if(r){const V=a.getBoundingClientRect();u=r.pageX-V.left,p=r.pageY-V.top}else u=a.clientWidth/2,p=a.clientHeight/2;const m=Et.current,y=t,k=a.scrollLeft,R=a.scrollTop,z=u+k,w=p+R,ht=z/m*y-u,W=w/m*y-p;pe(!0),Me.current?.(t);let O=null;const N=V=>{O===null&&(O=V);const Zt=V-O;let K=Zt/v;K>1&&(K=1),K=Ae(K),oe(m+(y-m)*K),_t.current=k+(ht-k)*K,Tt.current=R+(W-R)*K,Zt<v?D(N):(we.current?.(t),pe(!1),oe(t),_t.current=ht,Tt.current=W)};D(N),y>1&&At(!0)},[v,o,At,D]),zt=e.useCallback(t=>{if(!it)return;const r=Vt.current+1;se(r),Rt(f[r],t)},[it,f,Rt]),Ot=e.useCallback(t=>{if(!lt)return;const r=Vt.current-1;se(r),Rt(f[r],t)},[lt,f,Rt]),We=e.useCallback(t=>{const r=(Vt.current+1)%f.length;se(r),Rt(f[r],t)},[f,Rt]),ge=e.useCallback(t=>{if(t===null||t===Qt)return;let r;s[0]===null?h===2&&t===1?r=0:r=t:r=t-1,(h===2&&r>0&&s[0]===null||h===2&&s[0]!==null)&&(r=r&-2),H(r),at.current=1/0,ct.current=-1/0},[Qt,s,h,H]),Ne=e.useRef(ge);Ne.current=ge;const $e=e.useCallback((t,r)=>{const a=o.current;a&&(a.scrollLeft=ye.current-t,a.scrollTop=ke.current-r,_t.current=a.scrollLeft,Tt.current=a.scrollTop)},[o]),vt=e.useCallback(t=>{if(St.current=t.pageX,be.current=t.pageY,bt.current=0,Et.current<=1)X&&(yt.current="grab");else{const r=o.current;r&&(ye.current=r.scrollLeft,ke.current=r.scrollTop),yt.current="all-scroll"}},[X,o]),Pt=e.useCallback(t=>{if(St.current===null)return!1;const r=t.pageX-St.current,a=t.pageY-be.current;if(bt.current=Math.max(bt.current,Math.abs(r)),bt.current=Math.max(bt.current,Math.abs(a)),Et.current>1)return Y.current||$e(r,a),!1;if(!X||Math.abs(a)>Math.abs(r)||!Number.isFinite(P)||P<=0)return!1;yt.current="grabbing",me(p=>p+1);const u=q.current;return r>0?(u.direction===null&&et&&r>=S&&G("left",!1),q.current.direction==="left"&&B(p=>({...p,progress:Math.min(r/P,1)}))):(u.direction===null&&nt&&r<=-S&&G("right",!1),q.current.direction==="right"&&B(p=>({...p,progress:Math.min(-r/P,1)}))),!0},[X,et,nt,S,G,P,$e]),It=e.useCallback(t=>{if(St.current===null)return;U&&bt.current<S&&We(t);const r=q.current;r.direction!==null&&!r.auto&&(r.progress>1/4?fe(r.direction):Ze()),St.current=null,yt.current=null,me(a=>a+1)},[U,S,We,fe,Ze]),bn=e.useCallback(t=>{Y.current=!0,vt(t.changedTouches[0])},[vt]),yn=e.useCallback(t=>{Pt(t.changedTouches[0])&&t.cancelable&&t.preventDefault()},[Pt]),kn=e.useCallback(t=>{It(t.changedTouches[0])},[It]),Rn=e.useCallback(t=>{if(Kt.current=!0,!Y.current&&t.button===0){vt(t);try{t.target.setPointerCapture(t.pointerId)}catch{}}},[vt]),vn=e.useCallback(t=>{Y.current||Pt(t)},[Pt]),Pn=e.useCallback(t=>{if(!Y.current){It(t);try{t.target.releasePointerCapture(t.pointerId)}catch{}}},[It]),In=e.useCallback(t=>{Y.current||Kt.current||t.button===0&&vt(t)},[vt]),Mn=e.useCallback(t=>{Y.current||Kt.current||Pt(t)},[Pt]),wn=e.useCallback(t=>{Y.current||Kt.current||It(t)},[It]),xn=e.useCallback(t=>{if(st==="scroll"&&Et.current>1&&!Y.current){const r=o.current;r&&(r.scrollLeft+=t.deltaX,r.scrollTop+=t.deltaY,_t.current=r.scrollLeft,Tt.current=r.scrollTop),t.cancelable&&t.preventDefault()}st==="zoom"&&(t.deltaY>=100?(Ot(t),t.cancelable&&t.preventDefault()):t.deltaY<=-100&&(zt(t),t.cancelable&&t.preventDefault()))},[st,o,Ot,zt]),Ln=e.useCallback(t=>{switch(t.key){case"ArrowLeft":t.preventDefault(),et&&G("left",!0);break;case"ArrowRight":t.preventDefault(),nt&&G("right",!0);break;case"+":case"=":t.preventDefault(),it&&zt();break;case"-":t.preventDefault(),lt&&Ot();break}},[et,nt,it,lt,G,zt,Ot]);e.useEffect(()=>{pt===2&&H(t=>{const r=t&-2;return r===0&&d?t:r}),at.current=1/0,ct.current=-1/0},[ne,pt,d,H]);const Xe=e.useRef(At);return Xe.current=At,e.useEffect(()=>{n(E),xt(E+1),Xe.current()},[E]),e.useEffect(()=>{if(Ft.current||Ut===null)return;Ft.current=!0;const t=()=>{D(()=>{ae(r=>{const a=Ee.current;if(r===null)return Ft.current=!1,a;const u=a-r;return Math.abs(u)<.5?(Ft.current=!1,a):(t(),r+u*.1)})})};t()},[dt,D]),e.useEffect(()=>{const t=o.current;t&&(t.scrollLeft=je)},[je,o]),e.useEffect(()=>{const t=o.current;t&&(t.scrollTop=ze)},[ze,o]),e.useEffect(()=>{Se()},[s,Se]),e.useEffect(()=>{Ne.current(rt)},[rt]),e.useEffect(()=>{oe(f[0])},[]),e.useEffect(()=>{const t=ce.current;return()=>{t.forEach(cancelAnimationFrame),t.clear()}},[]),{viewWidth:i,viewHeight:_,pageWidth:P,pageHeight:ut,xMargin:A,yMargin:ft,displayedPages:h,zoom:l,centerOffsetSmoothed:jt,page:Qt,numPages:Le,leftPage:ie,rightPage:le,showLeftPage:tn,showRightPage:en,pageUrlLoading:Ve,loadImage:qe,flip:M,flipOpacity:sn,polygonArray:hn,polygonWidth:nn,polygonHeight:rn,polygonBgSize:on,canFlipLeft:et,canFlipRight:nt,canZoomIn:it,canZoomOut:lt,boundingLeft:gt,boundingRight:Dt,cursor:an,viewportClass:ln,flipLeft:pn,flipRight:mn,zoomIn:zt,zoomOut:Ot,goToPage:ge,apiRef:Ce,handlers:{onTouchStart:bn,onTouchMove:yn,onTouchEnd:kn,onPointerDown:Rn,onPointerMove:vn,onPointerUp:Pn,onMouseDown:In,onMouseMove:Mn,onMouseUp:wn,onWheel:xn,onKeyDown:Ln},onImageLoad:Qe}}const Qn=e.forwardRef(function({pages:o,pagesHiRes:s,pageLabels:b,flipDuration:x,zoomDuration:v,zooms:j,perspective:L,nPolygons:I,ambient:F,gloss:C,swipeMin:S,singlePage:$,forwardDirection:g,centering:Q,startPage:rt,loadingImage:ot,clickToZoom:U,dragToFlip:X,wheel:st,page:J,onPageChange:tt,onFlipLeftStart:f,onFlipLeftEnd:d,onFlipRightStart:i,onFlipRightEnd:_,onZoomStart:pt,onZoomEnd:ne,children:re,className:Xt,...Mt},E){const H=e.useRef(null),n=Vn({pages:o,pagesHiRes:s,flipDuration:x,zoomDuration:v,zooms:j,perspective:L,nPolygons:I,ambient:F,gloss:C,swipeMin:S,singlePage:$,forwardDirection:g,centering:Q,startPage:rt,loadingImage:ot,clickToZoom:U,dragToFlip:X,wheel:st,page:J,onPageChange:tt,onFlipLeftStart:f,onFlipLeftEnd:d,onFlipRightStart:i,onFlipRightEnd:_,onZoomStart:pt,onZoomEnd:ne},H);e.useImperativeHandle(E,()=>({get flipLeft(){return n.flipLeft},get flipRight(){return n.flipRight},get zoomIn(){return n.zoomIn},get zoomOut(){return n.zoomOut},get goToPage(){return n.goToPage},get canFlipLeft(){return n.apiRef.current.canFlipLeft},get canFlipRight(){return n.apiRef.current.canFlipRight},get canZoomIn(){return n.apiRef.current.canZoomIn},get canZoomOut(){return n.apiRef.current.canZoomOut},get page(){return n.apiRef.current.page},get numPages(){return n.apiRef.current.numPages}}),[n.flipLeft,n.flipRight,n.zoomIn,n.zoomOut,n.goToPage,n.apiRef]);const wt=l=>b&&b[l]?b[l]:`Page ${l+1}`,xt=Xt?`${T.root} ${Xt}`:T.root;return Z.jsxs("div",{...Mt,className:xt,role:"document","aria-label":`Book viewer, page ${n.page} of ${n.numPages}`,"aria-roledescription":"flipbook",children:[re?.({canFlipLeft:n.canFlipLeft,canFlipRight:n.canFlipRight,canZoomIn:n.canZoomIn,canZoomOut:n.canZoomOut,page:n.page,numPages:n.numPages,flipLeft:n.flipLeft,flipRight:n.flipRight,zoomIn:n.zoomIn,zoomOut:n.zoomOut,goToPage:n.goToPage}),Z.jsx("div",{ref:H,className:n.viewportClass,style:{cursor:n.cursor==="grabbing"?"grabbing":"auto"},tabIndex:0,onKeyDown:n.handlers.onKeyDown,onTouchMove:n.handlers.onTouchMove,onPointerMove:n.handlers.onPointerMove,onMouseMove:n.handlers.onMouseMove,onTouchEnd:n.handlers.onTouchEnd,onTouchCancel:n.handlers.onTouchEnd,onPointerUp:n.handlers.onPointerUp,onPointerCancel:n.handlers.onPointerUp,onMouseUp:n.handlers.onMouseUp,onWheel:n.handlers.onWheel,children:Z.jsxs("div",{className:T.container,style:{transform:`scale(${n.zoom})`},children:[Z.jsx("div",{role:"button",tabIndex:n.canFlipLeft?0:-1,"aria-label":"Previous page","aria-disabled":!n.canFlipLeft,className:T.clickLeft,style:{cursor:n.canFlipLeft?"pointer":"auto"},onClick:n.flipLeft,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),n.flipLeft())}}),Z.jsx("div",{role:"button",tabIndex:n.canFlipRight?0:-1,"aria-label":"Next page","aria-disabled":!n.canFlipRight,className:T.clickRight,style:{cursor:n.canFlipRight?"pointer":"auto"},onClick:n.flipRight,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),n.flipRight())}}),Z.jsxs("div",{style:{transform:`translateX(${n.centerOffsetSmoothed}px)`},children:[n.showLeftPage&&Z.jsx("img",{className:T.page,style:{width:n.pageWidth+"px",height:n.pageHeight+"px",left:n.xMargin+"px",top:n.yMargin+"px"},src:n.pageUrlLoading(n.leftPage,!0)??void 0,alt:wt(n.leftPage),onLoad:n.onImageLoad}),n.showRightPage&&Z.jsx("img",{className:T.page,style:{width:n.pageWidth+"px",height:n.pageHeight+"px",left:n.viewWidth/2+"px",top:n.yMargin+"px"},src:n.pageUrlLoading(n.rightPage,!0)??void 0,alt:wt(n.rightPage),onLoad:n.onImageLoad}),Z.jsx("div",{style:{opacity:n.flipOpacity},children:n.polygonArray.map(l=>Z.jsx("div",{className:l.bgImage?T.polygon:T.polygonBlank,style:{backgroundImage:l.bgImage?`url(${n.loadImage(l.bgImage)})`:void 0,backgroundSize:n.polygonBgSize,backgroundPosition:l.bgPos,width:n.polygonWidth,height:n.polygonHeight,transform:l.transform,zIndex:l.z},children:l.lighting&&Z.jsx("div",{className:T.lighting,style:{backgroundImage:l.lighting}})},l.key))}),Z.jsx("div",{className:T.boundingBox,style:{left:n.boundingLeft+"px",top:n.yMargin+"px",width:n.boundingRight-n.boundingLeft+"px",height:n.pageHeight+"px",cursor:n.cursor},onTouchStart:n.handlers.onTouchStart,onPointerDown:n.handlers.onPointerDown,onMouseDown:n.handlers.onMouseDown})]})]})}),Z.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:T.srOnly,children:["Page ",n.page," of ",n.numPages]})]})});exports.Flipbook=Qn;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("react/jsx-runtime"),t=require("react");function ht(c){if(c&&c.constructor===Array){var o=c.filter(function(b){return typeof b=="number"}).filter(function(b){return!isNaN(b)});if(c.length===6&&o.length===6){var s=$e();return s[0]=o[0],s[1]=o[1],s[4]=o[2],s[5]=o[3],s[12]=o[4],s[13]=o[5],s}else if(c.length===16&&o.length===16)return c}throw new TypeError("Expected a `number[]` with length 6 or 16.")}function $e(){for(var c=[],o=0;o<16;o++)o%5==0?c.push(1):c.push(0);return c}function _n(c,o){for(var s=ht(c),b=ht(o),w=[],v=0;v<4;v++)for(var D=[s[v],s[v+4],s[v+8],s[v+12]],L=0;L<4;L++){var y=L*4,j=[b[y],b[y+1],b[y+2],b[y+3]],C=D[0]*j[0]+D[1]*j[1]+D[2]*j[2]+D[3]*j[3];w[v+y]=C}return w}function Tn(c){var o=$e();return o[11]=-1/c,o}function jn(c){var o=Math.PI/180*c,s=$e();return s[0]=s[10]=Math.cos(o),s[2]=s[8]=Math.sin(o),s[2]*=-1,s}function Fn(c){return"matrix3d("+ht(c).join(", ")+")"}function Yt(c,o,s){var b=$e();return c!==void 0&&o!==void 0&&s!==void 0&&(b[12]=c,b[13]=o,b[14]=s),b}class tt{constructor(o){o?o instanceof tt?this.m=[...o.m]:this.m=[...o]:this.m=$e()}clone(){return new tt(this)}multiply(o){this.m=_n(this.m,o)}perspective(o){this.multiply(Tn(o))}transformX(o){return(o*this.m[0]+this.m[12])/(o*this.m[3]+this.m[15])}translate(o,s){this.multiply(Yt(o,s??0,0))}translate3d(o,s,b){this.multiply(Yt(o,s,b))}rotateY(o){this.multiply(jn(o))}toString(){return Fn(this.m)}}function En(c,o,s){const[b,w]=t.useState(0),[v,D]=t.useState(0),[L,y]=t.useState(1),[j,C]=t.useState(0);return t.useEffect(()=>{const S=()=>{const X=c.current;if(!X)return;w(X.clientWidth),D(X.clientHeight);const g=X.clientWidth>X.clientHeight&&!o?2:1;y(g),g===2&&C(Q=>Q+1)};return window.addEventListener("resize",S,{passive:!0}),S(),()=>window.removeEventListener("resize",S)},[o,c]),{viewWidth:b,viewHeight:v,rawDisplayedPages:L,pageAlignmentTick:j}}function Dn(c,o,s,b,w,v,D){const[L,y]=t.useState(null),[j,C]=t.useState(null),[S,X]=t.useState({}),g=t.useRef({}),Q=t.useRef({count:0,target:0,cb:null}),re=t.useRef(new Set),oe=t.useCallback((f,d=!1)=>{if(d&&w>1&&!v){const i=o[f];if(i)return i}return c[f]??null},[c,o,w,v]),U=t.useCallback(f=>L===null||S[f]?f:(g.current[f]||(g.current[f]=null,re.current.add(f)),D),[L,S,D]);t.useEffect(()=>{const f=re.current;f.size!==0&&(f.forEach(d=>{if(g.current[d])return;const i=new Image;g.current[d]=i,i.onload=()=>{X(_=>({..._,[d]:!0}))},i.src=d}),f.clear())});const z=t.useCallback((f,d=!1)=>{const i=oe(f,d);return d&&w>1&&!v?i:i?U(i):null},[oe,U,w,v]),se=t.useCallback((f=!1)=>{for(let d=s-3;d<=s+3;d++)z(d);if(f)for(let d=s;d<s+b;d++){const i=o[d];if(i&&!g.current[i]){const _=new Image;g.current[i]=_,_.src=i}}},[s,b,o,z]),J=t.useCallback(f=>{const d=f.target;L===null&&(y(d.naturalWidth),C(d.naturalHeight));const i=Q.current;i.cb&&(i.count++,i.count>=i.target&&(i.cb(),i.cb=null))},[L]),ee=t.useCallback((f,d)=>{Q.current={count:0,target:f,cb:d}},[]);return{imageWidth:L,imageHeight:j,loadedImages:S,pageUrl:oe,loadImage:U,pageUrlLoading:z,preloadImages:se,onImageLoad:J,setImageLoadCallback:ee}}const zn="data:image/svg+xml,%3c?xml%20version='1.0'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='500'%20height='500'%20viewBox='0%200%20500%20500'%20fill='transparent'%20style='background-color:%20%23fff'%3e%3ccircle%20cx='250'%20cy='250'%20r='48'%20stroke='%23333'%20stroke-width='2'%20stroke-dasharray='271%2030'%20%3e%3canimateTransform%20attributeName='transform'%20attributeType='XML'%20type='rotate'%20from='0%20250%20250'%20to='360%20250%20250'%20dur='1s'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3c/svg%3e",On="_root_jjdx8_1",Zn="_viewport_jjdx8_8",Wn="_viewportZoom_jjdx8_16 _viewport_jjdx8_8",Nn="_viewportZoomDragToScroll_jjdx8_22 _viewportZoom_jjdx8_16 _viewport_jjdx8_8",$n="_container_jjdx8_27",Xn="_clickLeft_jjdx8_43 _clickToFlip_jjdx8_35",Hn="_clickRight_jjdx8_48 _clickToFlip_jjdx8_35",Bn="_boundingBox_jjdx8_53",Un="_page_jjdx8_58",Yn="_polygon_jjdx8_63",An="_polygonBlank_jjdx8_72 _polygon_jjdx8_63",Gn="_lighting_jjdx8_77",Kn="_srOnly_jjdx8_82",T={root:On,viewport:Zn,viewportZoom:Wn,viewportZoomDragToScroll:Nn,container:$n,clickLeft:Xn,clickRight:Hn,boundingBox:Bn,page:Un,polygon:Yn,polygonBlank:An,lighting:Gn,srOnly:Kn};function Gt(c){return c*c}function qn(c){return 1-Gt(1-c)}function At(c){return c<.5?Gt(c*2)/2:.5+qn((c-.5)*2)/2}const Ne={progress:0,direction:null,frontImage:null,backImage:null,auto:!1};function Vn(c,o){const{pages:s,pagesHiRes:b=[],flipDuration:w=1e3,zoomDuration:v=500,zooms:D=[1,2,4],perspective:L=2400,nPolygons:y=10,ambient:j=.4,gloss:C=.6,swipeMin:S=3,singlePage:X=!1,forwardDirection:g="right",centering:Q=!0,startPage:re=null,loadingImage:oe=zn,clickToZoom:U=!0,dragToFlip:z=!0,wheel:se="scroll",page:J,onPageChange:ee}=c,f=D??[1],d=s[0]===null,{viewWidth:i,viewHeight:_,rawDisplayedPages:pe,pageAlignmentTick:nt}=En(o,X),[rt,Xe]=t.useState(0),we=J!==void 0,F=we?J:rt,H=t.useCallback(e=>{if(we){const r=typeof e=="function"?e(J):e;ee?.(r)}else Xe(e)},[we,J,ee]),[He,n]=t.useState(0),[Le,Ce]=t.useState(1),[l,ot]=t.useState(f[0]),[Be,st]=t.useState(0),[Se,pt]=t.useState(!1),[I,B]=t.useState(Ne),[Ue,at]=t.useState(null),[,mt]=t.useState(0),h=pe===2&&(d&&(F===0||F===1))?1:pe,Kt=Dn(s,b,F,h,l,Se,oe),{imageWidth:me,imageHeight:Ye,pageUrl:_e,loadImage:qt,pageUrlLoading:Vt,preloadImages:Ae,onImageLoad:Qt,setImageLoadCallback:Ge}=Kt,be=t.useRef(null),bt=t.useRef(null),ke=t.useRef(0),xe=t.useRef(null),Y=t.useRef(!1),Ke=t.useRef(!1),ae=t.useRef(1/0),ce=t.useRef(-1/0),kt=t.useRef(0),xt=t.useRef(0),Te=t.useRef(0),je=t.useRef(0),Fe=t.useRef(!1),q=t.useRef(I);q.current=I;const Re=t.useRef(F);Re.current=F;const qe=t.useRef(h);qe.current=h;const ve=t.useRef(l);ve.current=l;const Ve=t.useRef(Be);Ve.current=Be;const Rt=t.useRef(c.onFlipLeftStart);Rt.current=c.onFlipLeftStart;const vt=t.useRef(c.onFlipLeftEnd);vt.current=c.onFlipLeftEnd;const Pt=t.useRef(c.onFlipRightStart);Pt.current=c.onFlipRightStart;const yt=t.useRef(c.onFlipRightEnd);yt.current=c.onFlipRightEnd;const It=t.useRef(c.onZoomStart);It.current=c.onZoomStart;const Mt=t.useRef(c.onZoomEnd);Mt.current=c.onZoomEnd;const Jt=t.useRef(ee);Jt.current=ee;const wt=t.useRef(H);wt.current=H;const ct=t.useRef(new Set),E=t.useCallback(e=>{const r=requestAnimationFrame(a=>{ct.current.delete(r),e(a)});return ct.current.add(r),r},[]),Lt=d?s.length-1:s.length,Qe=d?Math.max(1,F):F+1,Ct=t.useRef({canFlipLeft:!1,canFlipRight:!1,canZoomIn:!1,canZoomOut:!1,page:0,numPages:0}),St=t.useCallback(()=>{H(e=>h===1&&e===0&&s.length>0&&!s[0]?1:e)},[h,s,H]),_t=!I.direction&&F<s.length-h,Tt=!I.direction&&F>=h&&!(h===1&&!_e(He-1)),te=g==="left"?_t:Tt,ne=g==="right"?_t:Tt,ie=!Se&&Be<f.length-1,le=!Se&&Be>0;Ct.current={canFlipLeft:te,canFlipRight:ne,canZoomIn:ie,canZoomOut:le,page:Qe,numPages:Lt};const it=g==="right"||h===1?He:Le,lt=g==="left"?He:Le,en=!!_e(it),tn=!!_e(lt)&&h===2,jt=me&&Ye?Math.min(i/h/me,_/Ye,1):1,P=me?Math.round(me*jt):0,ue=Ye?Math.round(Ye*jt):0,A=(i-P*h)/2,fe=(_-ue)/2,nn=Math.ceil(P/y+1/l)+"px",rn=ue+"px",on=`${P}px ${ue}px`,sn=t.useMemo(()=>{if(!I.direction||h!==1)return 1;let e=I.progress;return I.direction!==g&&(e=1-e),e>.7?1-(e-.7)/.3:1},[I.direction,I.progress,h,g]),ge=(()=>{if(h===1)return A;const e=_e(it)?A:i/2;return I.direction?e<ae.current?e:ae.current:e})(),Ee=(()=>{if(h===1)return i-A;const e=_e(lt)?i-A:i/2;return I.direction?e>ce.current?e:ce.current:e})(),de=Q?Math.round(i/2-(ge+Ee)/2):0,Ft=t.useRef(de);Ft.current=de;const Et=t.useRef(h);t.useEffect(()=>{Ue===null&&me!==null&&at(de)},[Ue,me,de]),t.useEffect(()=>{Et.current!==h&&(Et.current=h,at(de),Fe.current=!1)},[h,de]);const De=Math.round(Ue??0),an=xe.current?xe.current:U&&ie?"zoom-in":U&&le?"zoom-out":z?"grab":"auto",cn=!Y.current,ln=(Se||l>1)&&cn?T.viewportZoomDragToScroll:Se||l>1?T.viewportZoom:T.viewport,un=(()=>{const e=(Ee-ge)*l;return e<i?(ge+De)*l-(i-e)/2:(ge+De)*l})(),fn=(()=>{const e=(Ee-ge)*l;return e<i?(ge+De)*l-(i-e)/2:(Ee+De)*l-i})(),gn=(()=>{const e=ue*l;return e<_?fe*l-(_-e)/2:fe*l})(),dn=(()=>{const e=ue*l;return e<_?fe*l-(_-e)/2:(fe+ue)*l-_})(),Dt=Math.min(fn,Math.max(un,Te.current)),zt=Math.min(dn,Math.max(gn,je.current)),Ot=t.useCallback((e,r)=>{const a=[],u=[-.5,-.25,0,.25,.5];if(j<1){const p=1-j,m=u.map(k=>(1-Math.cos((e-r*k)/180*Math.PI))*p);a.push(`linear-gradient(to right,rgba(0,0,0,${m[0]}),rgba(0,0,0,${m[1]}) 25%,rgba(0,0,0,${m[2]}) 50%,rgba(0,0,0,${m[3]}) 75%,rgba(0,0,0,${m[4]}))`)}if(C>0){const k=u.map(x=>Math.max(Math.pow(Math.cos((e+30-r*x)/180*Math.PI),200),Math.pow(Math.cos((e-30-r*x)/180*Math.PI),200)));a.push(`linear-gradient(to right,rgba(255,255,255,${k[0]*C}),rgba(255,255,255,${k[1]*C}) 25%,rgba(255,255,255,${k[2]*C}) 50%,rgba(255,255,255,${k[3]*C}) 75%,rgba(255,255,255,${k[4]*C}))`)}return a.join(",")},[j,C]),ut=t.useCallback(e=>{const r=q.current;if(!r.direction)return[];if(!Number.isFinite(P)||P<=0||y<=0)return[];let a=r.progress,u=r.direction;if(!Number.isFinite(a))return[];a<0&&(a=0),a>1&&(a=1),h===1&&u!==g&&(a=1-a,u=g);const p=e==="front"?r.frontImage:r.backImage,m=P/y;let k=A,x=!1;h===1?g==="right"?e==="back"&&(x=!0,k=A-P):u==="left"?e==="back"?k=P-A:x=!0:e==="front"?k=P-A:x=!0:u==="left"?e==="back"?k=i/2:x=!0:e==="front"?k=i/2:x=!0;const R=new tt;R.translate(i/2),R.perspective(L),R.translate(-i/2),R.translate(k,fe);let O=0;a>.5&&(O=-(a-.5)*2*180),u==="left"&&(O=-O),e==="back"&&(O+=180),O&&(x&&R.translate(P),R.rotateY(O),x&&R.translate(-P));let M;a<.5?M=a*2*Math.PI:M=(1-(a-.5)*2)*Math.PI,M===0&&(M=1e-9);const he=P/M;let N=0;const Z=M/y;let $=Z/2/Math.PI*180;const V=Z/Math.PI*180;x&&($=-M/Math.PI*180+V/2),e==="back"&&($=-$);const Ze=e==="back"?-V:V;ae.current=1/0,ce.current=-1/0;const K=[];for(let Je=0;Je<y;Je++){const Cn=`${Je/(y-1)*100}% 0px`,We=R.clone(),Ht=x?M-N:N;let dt=Math.sin(Ht)*he;x&&(dt=P-dt);let et=(1-Math.cos(Ht))*he;e==="back"&&(et=-et),We.translate3d(dt,0,et),We.rotateY(-$);const Bt=We.transformX(0),Ut=We.transformX(m);ce.current=Math.max(Math.max(Bt,Ut),ce.current),ae.current=Math.min(Math.min(Bt,Ut),ae.current);const Sn=Ot(O-$,Ze);N+=Z,$+=Ze,K.push({key:e+Je,bgImage:p,lighting:Sn,bgPos:Cn,transform:We.toString(),z:Math.abs(Math.round(et))})}return K},[h,g,P,A,fe,i,L,y,Ot]),hn=t.useMemo(()=>I.direction?[...ut("front"),...ut("back")]:[],[I.direction,I.progress,I.frontImage,I.backImage,ut]),G=t.useCallback((e,r)=>{const a=Re.current,u=qe.current;let p=null,m=null;e!==g?u===1?(p=s[a-1]??null,m=null):(p=s[g==="right"||u===1?a:a+1]??null,m=s[a-u+1]??null):u===1?(p=s[a]??null,m=null):(p=s[g==="left"?a:a+1]??null,m=s[a+u]??null),B({progress:0,direction:e,frontImage:p,backImage:m,auto:!1}),E(()=>{E(()=>{e!==g?u===2&&n(a-u):u===1?n(a+u):Ce(a+1+u),r&&ft(e)})})},[g,s,E]),ft=t.useCallback(e=>{const r=q.current,a=w*(1-r.progress),u=r.progress;B(R=>({...R,auto:!0}));const p=Re.current,m=s[0]!==null?p+1:Math.max(1,p);e==="left"?Rt.current?.(m):Pt.current?.(m);let k=null;const x=R=>{k===null&&(k=R);const O=R-k;let M=u+O/a;M>1&&(M=1);const he=At(M);if(B(N=>({...N,progress:he})),M<1)E(x);else{const N=qe.current;let Z;e!==g?Z=Re.current-N:Z=Re.current+N,wt.current(Z);const $=s[0]!==null?Z+1:Math.max(1,Z);e==="left"?vt.current?.($):yt.current?.($),N===1&&e===g?B(Ne):Ge(1,()=>{B(Ne)})}};E(x)},[w,g,s,Ge,E]),Zt=t.useCallback(()=>{const e=q.current,r=w*e.progress,a=e.progress;B(m=>({...m,auto:!0}));let u=null;const p=m=>{u===null&&(u=m);const k=m-u;let x=a-a*k/r;if(x<0&&(x=0),B(R=>({...R,progress:x})),x>0)E(p);else{const R=Re.current;n(R),Ce(R+1);const O=qe.current,M=q.current.direction;O===1&&M!==g?B(Ne):Ge(1,()=>{B(Ne)})}};E(p)},[w,g,Ge,E]),pn=t.useCallback(()=>{te&&G("left",!0)},[te,G]),mn=t.useCallback(()=>{ne&&G("right",!0)},[ne,G]),Pe=t.useCallback((e,r)=>{const a=o.current;if(!a)return;let u,p;if(r){const V=a.getBoundingClientRect();u=r.pageX-V.left,p=r.pageY-V.top}else u=a.clientWidth/2,p=a.clientHeight/2;const m=ve.current,k=e,x=a.scrollLeft,R=a.scrollTop,O=u+x,M=p+R,he=O/m*k-u,N=M/m*k-p;pt(!0),It.current?.(e);let Z=null;const $=V=>{Z===null&&(Z=V);const Ze=V-Z;let K=Ze/v;K>1&&(K=1),K=At(K),ot(m+(k-m)*K),Te.current=x+(he-x)*K,je.current=R+(N-R)*K,Ze<v?E($):(Mt.current?.(e),pt(!1),ot(e),Te.current=he,je.current=N)};E($),k>1&&Ae(!0)},[v,o,Ae,E]),ze=t.useCallback(e=>{if(!ie)return;const r=Ve.current+1;st(r),Pe(f[r],e)},[ie,f,Pe]),Oe=t.useCallback(e=>{if(!le)return;const r=Ve.current-1;st(r),Pe(f[r],e)},[le,f,Pe]),Wt=t.useCallback(e=>{const r=(Ve.current+1)%f.length;st(r),Pe(f[r],e)},[f,Pe]),gt=t.useCallback(e=>{if(e===null||e===Qe)return;let r;s[0]===null?h===2&&e===1?r=0:r=e:r=e-1,(h===2&&r>0&&s[0]===null||h===2&&s[0]!==null)&&(r=r&-2),H(r),ae.current=1/0,ce.current=-1/0},[Qe,s,h,H]),Nt=t.useRef(gt);Nt.current=gt;const $t=t.useCallback((e,r)=>{const a=o.current;a&&(a.scrollLeft=kt.current-e,a.scrollTop=xt.current-r,Te.current=a.scrollLeft,je.current=a.scrollTop)},[o]),ye=t.useCallback(e=>{if(be.current=e.pageX,bt.current=e.pageY,ke.current=0,ve.current<=1)z&&(xe.current="grab");else{const r=o.current;r&&(kt.current=r.scrollLeft,xt.current=r.scrollTop),xe.current="all-scroll"}},[z,o]),Ie=t.useCallback(e=>{if(be.current===null)return!1;const r=e.pageX-be.current,a=e.pageY-bt.current;if(ke.current=Math.max(ke.current,Math.abs(r)),ke.current=Math.max(ke.current,Math.abs(a)),ve.current>1)return Y.current||$t(r,a),!1;if(!z||Math.abs(a)>Math.abs(r)||!Number.isFinite(P)||P<=0)return!1;xe.current="grabbing",mt(p=>p+1);const u=q.current;return r>0?(u.direction===null&&te&&r>=S&&G("left",!1),q.current.direction==="left"&&B(p=>({...p,progress:Math.min(r/P,1)}))):(u.direction===null&&ne&&r<=-S&&G("right",!1),q.current.direction==="right"&&B(p=>({...p,progress:Math.min(-r/P,1)}))),!0},[z,te,ne,S,G,P,$t]),Me=t.useCallback(e=>{if(be.current===null)return;U&&ke.current<S&&Wt(e);const r=q.current;r.direction!==null&&!r.auto&&(r.progress>1/4?ft(r.direction):Zt()),be.current=null,xe.current=null,mt(a=>a+1)},[U,S,Wt,ft,Zt]),bn=t.useCallback(e=>{Y.current=!0,ye(e.changedTouches[0])},[ye]),kn=t.useCallback(e=>{if(Ie(e.changedTouches[0])){e.cancelable&&e.preventDefault();return}z&&ve.current<=1&&be.current!==null&&e.cancelable&&e.preventDefault()},[z,Ie]),xn=t.useCallback(e=>{Me(e.changedTouches[0])},[Me]),Rn=t.useCallback(e=>{if(Ke.current=!0,!Y.current&&e.button===0){ye(e);try{e.target.setPointerCapture(e.pointerId)}catch{}}},[ye]),vn=t.useCallback(e=>{Y.current||Ie(e)},[Ie]),Pn=t.useCallback(e=>{if(!Y.current){Me(e);try{e.target.releasePointerCapture(e.pointerId)}catch{}}},[Me]),yn=t.useCallback(e=>{Y.current||Ke.current||e.button===0&&ye(e)},[ye]),In=t.useCallback(e=>{Y.current||Ke.current||Ie(e)},[Ie]),Mn=t.useCallback(e=>{Y.current||Ke.current||Me(e)},[Me]),wn=t.useCallback(e=>{if(se==="scroll"&&ve.current>1&&!Y.current){const r=o.current;r&&(r.scrollLeft+=e.deltaX,r.scrollTop+=e.deltaY,Te.current=r.scrollLeft,je.current=r.scrollTop),e.cancelable&&e.preventDefault()}se==="zoom"&&(e.deltaY>=100?(Oe(e),e.cancelable&&e.preventDefault()):e.deltaY<=-100&&(ze(e),e.cancelable&&e.preventDefault()))},[se,o,Oe,ze]),Ln=t.useCallback(e=>{switch(e.key){case"ArrowLeft":e.preventDefault(),te&&G("left",!0);break;case"ArrowRight":e.preventDefault(),ne&&G("right",!0);break;case"+":case"=":e.preventDefault(),ie&&ze();break;case"-":e.preventDefault(),le&&Oe();break}},[te,ne,ie,le,G,ze,Oe]);t.useEffect(()=>{pe===2&&H(e=>{const r=e&-2;return r===0&&d?e:r}),ae.current=1/0,ce.current=-1/0},[nt,pe,d,H]);const Xt=t.useRef(Ae);return Xt.current=Ae,t.useEffect(()=>{n(F),Ce(F+1),Xt.current()},[F]),t.useEffect(()=>{if(Fe.current||Ue===null)return;Fe.current=!0;const e=()=>{E(()=>{at(r=>{const a=Ft.current;if(r===null)return Fe.current=!1,a;const u=a-r;return Math.abs(u)<.5?(Fe.current=!1,a):(e(),r+u*.1)})})};e()},[de,E]),t.useEffect(()=>{const e=o.current;e&&(e.scrollLeft=Dt)},[Dt,o]),t.useEffect(()=>{const e=o.current;e&&(e.scrollTop=zt)},[zt,o]),t.useEffect(()=>{St()},[s,St]),t.useEffect(()=>{Nt.current(re)},[re]),t.useEffect(()=>{ot(f[0])},[]),t.useEffect(()=>{const e=ct.current;return()=>{e.forEach(cancelAnimationFrame),e.clear()}},[]),{viewWidth:i,viewHeight:_,pageWidth:P,pageHeight:ue,xMargin:A,yMargin:fe,displayedPages:h,zoom:l,centerOffsetSmoothed:De,page:Qe,numPages:Lt,leftPage:it,rightPage:lt,showLeftPage:en,showRightPage:tn,pageUrlLoading:Vt,loadImage:qt,flip:I,flipOpacity:sn,polygonArray:hn,polygonWidth:nn,polygonHeight:rn,polygonBgSize:on,canFlipLeft:te,canFlipRight:ne,canZoomIn:ie,canZoomOut:le,boundingLeft:ge,boundingRight:Ee,cursor:an,viewportClass:ln,flipLeft:pn,flipRight:mn,zoomIn:ze,zoomOut:Oe,goToPage:gt,apiRef:Ct,handlers:{onTouchStart:bn,onTouchMove:kn,onTouchEnd:xn,onPointerDown:Rn,onPointerMove:vn,onPointerUp:Pn,onMouseDown:yn,onMouseMove:In,onMouseUp:Mn,onWheel:wn,onKeyDown:Ln},onImageLoad:Qt}}const Qn=t.forwardRef(function({pages:o,pagesHiRes:s,pageLabels:b,flipDuration:w,zoomDuration:v,zooms:D,perspective:L,nPolygons:y,ambient:j,gloss:C,swipeMin:S,singlePage:X,forwardDirection:g,centering:Q,startPage:re,loadingImage:oe,clickToZoom:U,dragToFlip:z,wheel:se,page:J,onPageChange:ee,onFlipLeftStart:f,onFlipLeftEnd:d,onFlipRightStart:i,onFlipRightEnd:_,onZoomStart:pe,onZoomEnd:nt,children:rt,className:Xe,...we},F){const H=t.useRef(null),n=Vn({pages:o,pagesHiRes:s,flipDuration:w,zoomDuration:v,zooms:D,perspective:L,nPolygons:y,ambient:j,gloss:C,swipeMin:S,singlePage:X,forwardDirection:g,centering:Q,startPage:re,loadingImage:oe,clickToZoom:U,dragToFlip:z,wheel:se,page:J,onPageChange:ee,onFlipLeftStart:f,onFlipLeftEnd:d,onFlipRightStart:i,onFlipRightEnd:_,onZoomStart:pe,onZoomEnd:nt},H);t.useImperativeHandle(F,()=>({get flipLeft(){return n.flipLeft},get flipRight(){return n.flipRight},get zoomIn(){return n.zoomIn},get zoomOut(){return n.zoomOut},get goToPage(){return n.goToPage},get canFlipLeft(){return n.apiRef.current.canFlipLeft},get canFlipRight(){return n.apiRef.current.canFlipRight},get canZoomIn(){return n.apiRef.current.canZoomIn},get canZoomOut(){return n.apiRef.current.canZoomOut},get page(){return n.apiRef.current.page},get numPages(){return n.apiRef.current.numPages}}),[n.flipLeft,n.flipRight,n.zoomIn,n.zoomOut,n.goToPage,n.apiRef]);const Le=l=>b&&b[l]?b[l]:`Page ${l+1}`,Ce=Xe?`${T.root} ${Xe}`:T.root;return W.jsxs("div",{...we,className:Ce,role:"document","aria-label":`Book viewer, page ${n.page} of ${n.numPages}`,"aria-roledescription":"flipbook",children:[rt?.({canFlipLeft:n.canFlipLeft,canFlipRight:n.canFlipRight,canZoomIn:n.canZoomIn,canZoomOut:n.canZoomOut,page:n.page,numPages:n.numPages,flipLeft:n.flipLeft,flipRight:n.flipRight,zoomIn:n.zoomIn,zoomOut:n.zoomOut,goToPage:n.goToPage}),W.jsx("div",{ref:H,className:n.viewportClass,style:{cursor:n.cursor==="grabbing"?"grabbing":"auto"},tabIndex:0,onKeyDown:n.handlers.onKeyDown,onTouchMove:n.handlers.onTouchMove,onPointerMove:n.handlers.onPointerMove,onMouseMove:n.handlers.onMouseMove,onTouchEnd:n.handlers.onTouchEnd,onTouchCancel:n.handlers.onTouchEnd,onPointerUp:n.handlers.onPointerUp,onPointerCancel:n.handlers.onPointerUp,onMouseUp:n.handlers.onMouseUp,onWheel:n.handlers.onWheel,children:W.jsxs("div",{className:T.container,style:{transform:`scale(${n.zoom})`},children:[W.jsx("div",{role:"button",tabIndex:n.canFlipLeft?0:-1,"aria-label":"Previous page","aria-disabled":!n.canFlipLeft,className:T.clickLeft,style:{cursor:n.canFlipLeft?"pointer":"auto"},onClick:n.flipLeft,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),n.flipLeft())}}),W.jsx("div",{role:"button",tabIndex:n.canFlipRight?0:-1,"aria-label":"Next page","aria-disabled":!n.canFlipRight,className:T.clickRight,style:{cursor:n.canFlipRight?"pointer":"auto"},onClick:n.flipRight,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),n.flipRight())}}),W.jsxs("div",{style:{transform:`translateX(${n.centerOffsetSmoothed}px)`},children:[n.showLeftPage&&W.jsx("img",{className:T.page,style:{width:n.pageWidth+"px",height:n.pageHeight+"px",left:n.xMargin+"px",top:n.yMargin+"px"},src:n.pageUrlLoading(n.leftPage,!0)??void 0,alt:Le(n.leftPage),onLoad:n.onImageLoad}),n.showRightPage&&W.jsx("img",{className:T.page,style:{width:n.pageWidth+"px",height:n.pageHeight+"px",left:n.viewWidth/2+"px",top:n.yMargin+"px"},src:n.pageUrlLoading(n.rightPage,!0)??void 0,alt:Le(n.rightPage),onLoad:n.onImageLoad}),W.jsx("div",{style:{opacity:n.flipOpacity},children:n.polygonArray.map(l=>W.jsx("div",{className:l.bgImage?T.polygon:T.polygonBlank,style:{backgroundImage:l.bgImage?`url(${n.loadImage(l.bgImage)})`:void 0,backgroundSize:n.polygonBgSize,backgroundPosition:l.bgPos,width:n.polygonWidth,height:n.polygonHeight,transform:l.transform,zIndex:l.z},children:l.lighting&&W.jsx("div",{className:T.lighting,style:{backgroundImage:l.lighting}})},l.key))}),W.jsx("div",{className:T.boundingBox,style:{left:n.boundingLeft+"px",top:n.yMargin+"px",width:n.boundingRight-n.boundingLeft+"px",height:n.pageHeight+"px",cursor:n.cursor},onTouchStart:n.handlers.onTouchStart,onPointerDown:n.handlers.onPointerDown,onMouseDown:n.handlers.onMouseDown})]})]})}),W.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:T.srOnly,children:["Page ",n.page," of ",n.numPages]})]})});exports.Flipbook=Qn;
|
package/dist/react-flipbook.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._root_jjdx8_1{display:flex;flex-direction:column;width:100%;height:100%}._viewport_jjdx8_8{width:100%;flex:1;min-height:0;touch-action:none;overscroll-behavior:contain}._viewportZoom_jjdx8_16{overflow:scroll;touch-action:pan-x pan-y}._viewportZoomDragToScroll_jjdx8_22{overflow:hidden}._container_jjdx8_27{position:relative;width:100%;height:100%;transform-origin:top left;-webkit-user-select:none;user-select:none}._clickToFlip_jjdx8_35{position:absolute;width:50%;height:100%;top:0;-webkit-user-select:none;user-select:none}._clickLeft_jjdx8_43{left:0}._clickRight_jjdx8_48{right:0}._boundingBox_jjdx8_53{position:absolute;-webkit-user-select:none;user-select:none}._page_jjdx8_58{position:absolute;backface-visibility:hidden}._polygon_jjdx8_63{position:absolute;top:0;left:0;background-repeat:no-repeat;backface-visibility:hidden;transform-origin:center left}._polygonBlank_jjdx8_72{background-color:var(--flipbook-blank-page-bg, #ddd)}._lighting_jjdx8_77{width:100%;height:100%}._srOnly_jjdx8_82{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}
|
package/dist/react-flipbook.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsxs as oe, jsx as tt } from "react/jsx-runtime";
|
|
2
|
-
import { useState as T, useEffect as
|
|
3
|
-
function
|
|
2
|
+
import { useState as T, useEffect as $, useRef as u, useCallback as f, useMemo as Ve, forwardRef as Cn, useImperativeHandle as En } from "react";
|
|
3
|
+
function ve(c) {
|
|
4
4
|
if (c && c.constructor === Array) {
|
|
5
|
-
var r = c.filter(function(
|
|
6
|
-
return typeof
|
|
7
|
-
}).filter(function(
|
|
8
|
-
return !isNaN(
|
|
5
|
+
var r = c.filter(function(v) {
|
|
6
|
+
return typeof v == "number";
|
|
7
|
+
}).filter(function(v) {
|
|
8
|
+
return !isNaN(v);
|
|
9
9
|
});
|
|
10
10
|
if (c.length === 6 && r.length === 6) {
|
|
11
11
|
var o = Bt();
|
|
@@ -20,28 +20,28 @@ function Bt() {
|
|
|
20
20
|
r % 5 == 0 ? c.push(1) : c.push(0);
|
|
21
21
|
return c;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
for (var o =
|
|
25
|
-
for (var
|
|
26
|
-
var
|
|
27
|
-
_[
|
|
23
|
+
function Zn(c, r) {
|
|
24
|
+
for (var o = ve(c), v = ve(r), _ = [], y = 0; y < 4; y++)
|
|
25
|
+
for (var Z = [o[y], o[y + 4], o[y + 8], o[y + 12]], R = 0; R < 4; R++) {
|
|
26
|
+
var w = R * 4, z = [v[w], v[w + 1], v[w + 2], v[w + 3]], F = Z[0] * z[0] + Z[1] * z[1] + Z[2] * z[2] + Z[3] * z[3];
|
|
27
|
+
_[y + w] = F;
|
|
28
28
|
}
|
|
29
29
|
return _;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function On(c) {
|
|
32
32
|
var r = Bt();
|
|
33
33
|
return r[11] = -1 / c, r;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function Wn(c) {
|
|
36
36
|
var r = Math.PI / 180 * c, o = Bt();
|
|
37
37
|
return o[0] = o[10] = Math.cos(r), o[2] = o[8] = Math.sin(r), o[2] *= -1, o;
|
|
38
38
|
}
|
|
39
39
|
function Nn(c) {
|
|
40
|
-
return "matrix3d(" +
|
|
40
|
+
return "matrix3d(" + ve(c).join(", ") + ")";
|
|
41
41
|
}
|
|
42
42
|
function qe(c, r, o) {
|
|
43
|
-
var
|
|
44
|
-
return c !== void 0 && r !== void 0 && o !== void 0 && (
|
|
43
|
+
var v = Bt();
|
|
44
|
+
return c !== void 0 && r !== void 0 && o !== void 0 && (v[12] = c, v[13] = r, v[14] = o), v;
|
|
45
45
|
}
|
|
46
46
|
class ie {
|
|
47
47
|
constructor(r) {
|
|
@@ -51,10 +51,10 @@ class ie {
|
|
|
51
51
|
return new ie(this);
|
|
52
52
|
}
|
|
53
53
|
multiply(r) {
|
|
54
|
-
this.m =
|
|
54
|
+
this.m = Zn(this.m, r);
|
|
55
55
|
}
|
|
56
56
|
perspective(r) {
|
|
57
|
-
this.multiply(
|
|
57
|
+
this.multiply(On(r));
|
|
58
58
|
}
|
|
59
59
|
transformX(r) {
|
|
60
60
|
return (r * this.m[0] + this.m[12]) / (r * this.m[3] + this.m[15]);
|
|
@@ -62,82 +62,82 @@ class ie {
|
|
|
62
62
|
translate(r, o) {
|
|
63
63
|
this.multiply(qe(r, o ?? 0, 0));
|
|
64
64
|
}
|
|
65
|
-
translate3d(r, o,
|
|
66
|
-
this.multiply(qe(r, o,
|
|
65
|
+
translate3d(r, o, v) {
|
|
66
|
+
this.multiply(qe(r, o, v));
|
|
67
67
|
}
|
|
68
68
|
rotateY(r) {
|
|
69
|
-
this.multiply(
|
|
69
|
+
this.multiply(Wn(r));
|
|
70
70
|
}
|
|
71
71
|
toString() {
|
|
72
72
|
return Nn(this.m);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
function $n(c, r, o) {
|
|
76
|
-
const [
|
|
77
|
-
return
|
|
76
|
+
const [v, _] = T(0), [y, Z] = T(0), [R, w] = T(1), [z, F] = T(0);
|
|
77
|
+
return $(() => {
|
|
78
78
|
const S = () => {
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
_(
|
|
82
|
-
const d =
|
|
83
|
-
|
|
79
|
+
const B = c.current;
|
|
80
|
+
if (!B) return;
|
|
81
|
+
_(B.clientWidth), Z(B.clientHeight);
|
|
82
|
+
const d = B.clientWidth > B.clientHeight && !r ? 2 : 1;
|
|
83
|
+
w(d), d === 2 && F((et) => et + 1);
|
|
84
84
|
};
|
|
85
85
|
return window.addEventListener("resize", S, { passive: !0 }), S(), () => window.removeEventListener("resize", S);
|
|
86
86
|
}, [r, c]), {
|
|
87
|
-
viewWidth:
|
|
88
|
-
viewHeight:
|
|
87
|
+
viewWidth: v,
|
|
88
|
+
viewHeight: y,
|
|
89
89
|
rawDisplayedPages: R,
|
|
90
|
-
pageAlignmentTick:
|
|
90
|
+
pageAlignmentTick: z
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
function Xn(c, r, o,
|
|
94
|
-
const [R,
|
|
93
|
+
function Xn(c, r, o, v, _, y, Z) {
|
|
94
|
+
const [R, w] = T(null), [z, F] = T(null), [S, B] = T({}), d = u({}), et = u({ count: 0, target: 0, cb: null }), ct = u(/* @__PURE__ */ new Set()), at = f(
|
|
95
95
|
(g, h = !1) => {
|
|
96
|
-
if (h && _ > 1 && !
|
|
96
|
+
if (h && _ > 1 && !y) {
|
|
97
97
|
const a = r[g];
|
|
98
98
|
if (a) return a;
|
|
99
99
|
}
|
|
100
100
|
return c[g] ?? null;
|
|
101
101
|
},
|
|
102
|
-
[c, r, _,
|
|
102
|
+
[c, r, _, y]
|
|
103
103
|
), A = f(
|
|
104
|
-
(g) => R === null || S[g] ? g : (d.current[g] || (d.current[g] = null, ct.current.add(g)),
|
|
105
|
-
[R, S,
|
|
104
|
+
(g) => R === null || S[g] ? g : (d.current[g] || (d.current[g] = null, ct.current.add(g)), Z),
|
|
105
|
+
[R, S, Z]
|
|
106
106
|
);
|
|
107
|
-
|
|
107
|
+
$(() => {
|
|
108
108
|
const g = ct.current;
|
|
109
109
|
g.size !== 0 && (g.forEach((h) => {
|
|
110
110
|
if (d.current[h]) return;
|
|
111
111
|
const a = new Image();
|
|
112
112
|
d.current[h] = a, a.onload = () => {
|
|
113
|
-
|
|
113
|
+
B((j) => ({ ...j, [h]: !0 }));
|
|
114
114
|
}, a.src = h;
|
|
115
115
|
}), g.clear());
|
|
116
116
|
});
|
|
117
|
-
const
|
|
117
|
+
const O = f(
|
|
118
118
|
(g, h = !1) => {
|
|
119
119
|
const a = at(g, h);
|
|
120
|
-
return h && _ > 1 && !
|
|
120
|
+
return h && _ > 1 && !y ? a : a ? A(a) : null;
|
|
121
121
|
},
|
|
122
|
-
[at, A, _,
|
|
122
|
+
[at, A, _, y]
|
|
123
123
|
), st = f(
|
|
124
124
|
(g = !1) => {
|
|
125
125
|
for (let h = o - 3; h <= o + 3; h++)
|
|
126
|
-
|
|
126
|
+
O(h);
|
|
127
127
|
if (g)
|
|
128
|
-
for (let h = o; h < o +
|
|
128
|
+
for (let h = o; h < o + v; h++) {
|
|
129
129
|
const a = r[h];
|
|
130
130
|
if (a && !d.current[a]) {
|
|
131
|
-
const
|
|
132
|
-
d.current[a] =
|
|
131
|
+
const j = new Image();
|
|
132
|
+
d.current[a] = j, j.src = a;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
},
|
|
136
|
-
[o,
|
|
136
|
+
[o, v, r, O]
|
|
137
137
|
), nt = f(
|
|
138
138
|
(g) => {
|
|
139
139
|
const h = g.target;
|
|
140
|
-
R === null && (
|
|
140
|
+
R === null && (w(h.naturalWidth), F(h.naturalHeight));
|
|
141
141
|
const a = et.current;
|
|
142
142
|
a.cb && (a.count++, a.count >= a.target && (a.cb(), a.cb = null));
|
|
143
143
|
},
|
|
@@ -150,17 +150,17 @@ function Xn(c, r, o, b, _, M, O) {
|
|
|
150
150
|
);
|
|
151
151
|
return {
|
|
152
152
|
imageWidth: R,
|
|
153
|
-
imageHeight:
|
|
153
|
+
imageHeight: z,
|
|
154
154
|
loadedImages: S,
|
|
155
155
|
pageUrl: at,
|
|
156
156
|
loadImage: A,
|
|
157
|
-
pageUrlLoading:
|
|
157
|
+
pageUrlLoading: O,
|
|
158
158
|
preloadImages: st,
|
|
159
159
|
onImageLoad: nt,
|
|
160
160
|
setImageLoadCallback: rt
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
|
-
const Hn = "data:image/svg+xml,%3c?xml%20version='1.0'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='500'%20height='500'%20viewBox='0%200%20500%20500'%20fill='transparent'%20style='background-color:%20%23fff'%3e%3ccircle%20cx='250'%20cy='250'%20r='48'%20stroke='%23333'%20stroke-width='2'%20stroke-dasharray='271%2030'%20%3e%3canimateTransform%20attributeName='transform'%20attributeType='XML'%20type='rotate'%20from='0%20250%20250'%20to='360%20250%20250'%20dur='1s'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3c/svg%3e", Bn = "
|
|
163
|
+
const Hn = "data:image/svg+xml,%3c?xml%20version='1.0'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='500'%20height='500'%20viewBox='0%200%20500%20500'%20fill='transparent'%20style='background-color:%20%23fff'%3e%3ccircle%20cx='250'%20cy='250'%20r='48'%20stroke='%23333'%20stroke-width='2'%20stroke-dasharray='271%2030'%20%3e%3canimateTransform%20attributeName='transform'%20attributeType='XML'%20type='rotate'%20from='0%20250%20250'%20to='360%20250%20250'%20dur='1s'%20repeatCount='indefinite'%20/%3e%3c/circle%3e%3c/svg%3e", Bn = "_root_jjdx8_1", Un = "_viewport_jjdx8_8", Yn = "_viewportZoom_jjdx8_16 _viewport_jjdx8_8", An = "_viewportZoomDragToScroll_jjdx8_22 _viewportZoom_jjdx8_16 _viewport_jjdx8_8", Gn = "_container_jjdx8_27", Kn = "_clickLeft_jjdx8_43 _clickToFlip_jjdx8_35", Vn = "_clickRight_jjdx8_48 _clickToFlip_jjdx8_35", qn = "_boundingBox_jjdx8_53", Qn = "_page_jjdx8_58", Jn = "_polygon_jjdx8_63", tr = "_polygonBlank_jjdx8_72 _polygon_jjdx8_63", er = "_lighting_jjdx8_77", nr = "_srOnly_jjdx8_82", D = {
|
|
164
164
|
root: Bn,
|
|
165
165
|
viewport: Un,
|
|
166
166
|
viewportZoom: Yn,
|
|
@@ -194,59 +194,59 @@ const Ht = {
|
|
|
194
194
|
function or(c, r) {
|
|
195
195
|
const {
|
|
196
196
|
pages: o,
|
|
197
|
-
pagesHiRes:
|
|
197
|
+
pagesHiRes: v = [],
|
|
198
198
|
flipDuration: _ = 1e3,
|
|
199
|
-
zoomDuration:
|
|
200
|
-
zooms:
|
|
199
|
+
zoomDuration: y = 500,
|
|
200
|
+
zooms: Z = [1, 2, 4],
|
|
201
201
|
perspective: R = 2400,
|
|
202
|
-
nPolygons:
|
|
203
|
-
ambient:
|
|
202
|
+
nPolygons: w = 10,
|
|
203
|
+
ambient: z = 0.4,
|
|
204
204
|
gloss: F = 0.6,
|
|
205
205
|
swipeMin: S = 3,
|
|
206
|
-
singlePage:
|
|
206
|
+
singlePage: B = !1,
|
|
207
207
|
forwardDirection: d = "right",
|
|
208
208
|
centering: et = !0,
|
|
209
209
|
startPage: ct = null,
|
|
210
210
|
loadingImage: at = Hn,
|
|
211
211
|
clickToZoom: A = !0,
|
|
212
|
-
dragToFlip:
|
|
212
|
+
dragToFlip: O = !0,
|
|
213
213
|
wheel: st = "scroll",
|
|
214
214
|
page: nt,
|
|
215
215
|
onPageChange: rt
|
|
216
|
-
} = c, g =
|
|
216
|
+
} = c, g = Z ?? [1], h = o[0] === null, { viewWidth: a, viewHeight: j, rawDisplayedPages: vt, pageAlignmentTick: ce } = $n(
|
|
217
217
|
r,
|
|
218
|
-
|
|
219
|
-
), [ae, Ut] = T(0),
|
|
218
|
+
B
|
|
219
|
+
), [ae, Ut] = T(0), Tt = nt !== void 0, C = Tt ? nt : ae, U = f(
|
|
220
220
|
(t) => {
|
|
221
|
-
if (
|
|
221
|
+
if (Tt) {
|
|
222
222
|
const n = typeof t == "function" ? t(nt) : t;
|
|
223
223
|
rt?.(n);
|
|
224
224
|
} else
|
|
225
225
|
Ut(t);
|
|
226
226
|
},
|
|
227
|
-
[
|
|
228
|
-
), [Yt, e] = T(0), [
|
|
227
|
+
[Tt, nt, rt]
|
|
228
|
+
), [Yt, e] = T(0), [Ft, St] = T(1), [s, se] = T(g[0]), [At, le] = T(0), [jt, Pe] = T(!1), [L, Y] = T(Ht), [Gt, ue] = T(null), [, Ie] = T(0), p = vt === 2 && (h && (C === 0 || C === 1)) ? 1 : vt, tn = Xn(
|
|
229
229
|
o,
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
v,
|
|
231
|
+
C,
|
|
232
232
|
p,
|
|
233
233
|
s,
|
|
234
|
-
|
|
234
|
+
jt,
|
|
235
235
|
at
|
|
236
|
-
), { imageWidth:
|
|
237
|
-
Q.current =
|
|
238
|
-
const Mt = u(
|
|
239
|
-
Mt.current =
|
|
236
|
+
), { imageWidth: Pt, imageHeight: Kt, pageUrl: Dt, loadImage: en, pageUrlLoading: nn, preloadImages: Vt, onImageLoad: rn, setImageLoadCallback: qt } = tn, It = u(null), xe = u(null), xt = u(0), yt = u(null), G = u(!1), Qt = u(!1), lt = u(1 / 0), ut = u(-1 / 0), ye = u(0), Me = u(0), zt = u(0), Ct = u(0), Et = u(!1), Q = u(L);
|
|
237
|
+
Q.current = L;
|
|
238
|
+
const Mt = u(C);
|
|
239
|
+
Mt.current = C;
|
|
240
240
|
const Jt = u(p);
|
|
241
241
|
Jt.current = p;
|
|
242
|
-
const
|
|
243
|
-
|
|
242
|
+
const wt = u(s);
|
|
243
|
+
wt.current = s;
|
|
244
244
|
const te = u(At);
|
|
245
245
|
te.current = At;
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
|
|
246
|
+
const we = u(c.onFlipLeftStart);
|
|
247
|
+
we.current = c.onFlipLeftStart;
|
|
248
|
+
const Le = u(c.onFlipLeftEnd);
|
|
249
|
+
Le.current = c.onFlipLeftEnd;
|
|
250
250
|
const ke = u(c.onFlipRightStart);
|
|
251
251
|
ke.current = c.onFlipRightStart;
|
|
252
252
|
const _e = u(c.onFlipRightEnd);
|
|
@@ -259,195 +259,195 @@ function or(c, r) {
|
|
|
259
259
|
on.current = rt;
|
|
260
260
|
const Fe = u(U);
|
|
261
261
|
Fe.current = U;
|
|
262
|
-
const fe = u(/* @__PURE__ */ new Set()),
|
|
262
|
+
const fe = u(/* @__PURE__ */ new Set()), E = f((t) => {
|
|
263
263
|
const n = requestAnimationFrame((i) => {
|
|
264
264
|
fe.current.delete(n), t(i);
|
|
265
265
|
});
|
|
266
266
|
return fe.current.add(n), n;
|
|
267
|
-
}, []), Se = h ? o.length - 1 : o.length, ee = h ? Math.max(1,
|
|
267
|
+
}, []), Se = h ? o.length - 1 : o.length, ee = h ? Math.max(1, C) : C + 1, je = u({
|
|
268
268
|
canFlipLeft: !1,
|
|
269
269
|
canFlipRight: !1,
|
|
270
270
|
canZoomIn: !1,
|
|
271
271
|
canZoomOut: !1,
|
|
272
272
|
page: 0,
|
|
273
273
|
numPages: 0
|
|
274
|
-
}),
|
|
274
|
+
}), De = f(() => {
|
|
275
275
|
U((t) => p === 1 && t === 0 && o.length > 0 && !o[0] ? 1 : t);
|
|
276
|
-
}, [p, o, U]),
|
|
277
|
-
|
|
278
|
-
const ge = d === "right" || p === 1 ? Yt :
|
|
279
|
-
if (!
|
|
280
|
-
let t =
|
|
281
|
-
return
|
|
282
|
-
}, [
|
|
276
|
+
}, [p, o, U]), ze = !L.direction && C < o.length - p, Ce = !L.direction && C >= p && !(p === 1 && !Dt(Yt - 1)), ot = d === "left" ? ze : Ce, it = d === "right" ? ze : Ce, ft = !jt && At < g.length - 1, gt = !jt && At > 0;
|
|
277
|
+
je.current = { canFlipLeft: ot, canFlipRight: it, canZoomIn: ft, canZoomOut: gt, page: ee, numPages: Se };
|
|
278
|
+
const ge = d === "right" || p === 1 ? Yt : Ft, de = d === "left" ? Yt : Ft, cn = !!Dt(ge), an = !!Dt(de) && p === 2, Ee = Pt && Kt ? Math.min(a / p / Pt, j / Kt, 1) : 1, M = Pt ? Math.round(Pt * Ee) : 0, dt = Kt ? Math.round(Kt * Ee) : 0, K = (a - M * p) / 2, ht = (j - dt) / 2, sn = Math.ceil(M / w + 1 / s) + "px", ln = dt + "px", un = `${M}px ${dt}px`, fn = Ve(() => {
|
|
279
|
+
if (!L.direction || p !== 1) return 1;
|
|
280
|
+
let t = L.progress;
|
|
281
|
+
return L.direction !== d && (t = 1 - t), t > 0.7 ? 1 - (t - 0.7) / 0.3 : 1;
|
|
282
|
+
}, [L.direction, L.progress, p, d]), pt = (() => {
|
|
283
283
|
if (p === 1) return K;
|
|
284
|
-
const t =
|
|
285
|
-
return
|
|
286
|
-
})(),
|
|
284
|
+
const t = Dt(ge) ? K : a / 2;
|
|
285
|
+
return L.direction ? t < lt.current ? t : lt.current : t;
|
|
286
|
+
})(), Zt = (() => {
|
|
287
287
|
if (p === 1) return a - K;
|
|
288
|
-
const t =
|
|
289
|
-
return
|
|
290
|
-
})(), mt = et ? Math.round(a / 2 - (pt +
|
|
291
|
-
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
Gt === null &&
|
|
295
|
-
}, [Gt,
|
|
296
|
-
|
|
288
|
+
const t = Dt(de) ? a - K : a / 2;
|
|
289
|
+
return L.direction ? t > ut.current ? t : ut.current : t;
|
|
290
|
+
})(), mt = et ? Math.round(a / 2 - (pt + Zt) / 2) : 0, Ze = u(mt);
|
|
291
|
+
Ze.current = mt;
|
|
292
|
+
const Oe = u(p);
|
|
293
|
+
$(() => {
|
|
294
|
+
Gt === null && Pt !== null && ue(mt);
|
|
295
|
+
}, [Gt, Pt, mt]), $(() => {
|
|
296
|
+
Oe.current !== p && (Oe.current = p, ue(mt), Et.current = !1);
|
|
297
297
|
}, [p, mt]);
|
|
298
|
-
const
|
|
299
|
-
const t = (
|
|
300
|
-
return t < a ? (pt +
|
|
298
|
+
const Ot = Math.round(Gt ?? 0), gn = yt.current ? yt.current : A && ft ? "zoom-in" : A && gt ? "zoom-out" : O ? "grab" : "auto", dn = !G.current, hn = (jt || s > 1) && dn ? D.viewportZoomDragToScroll : jt || s > 1 ? D.viewportZoom : D.viewport, pn = (() => {
|
|
299
|
+
const t = (Zt - pt) * s;
|
|
300
|
+
return t < a ? (pt + Ot) * s - (a - t) / 2 : (pt + Ot) * s;
|
|
301
301
|
})(), mn = (() => {
|
|
302
|
-
const t = (
|
|
303
|
-
return t < a ? (pt +
|
|
304
|
-
})(), yn = (() => {
|
|
305
|
-
const t = dt * s;
|
|
306
|
-
return t < D ? ht * s - (D - t) / 2 : ht * s;
|
|
302
|
+
const t = (Zt - pt) * s;
|
|
303
|
+
return t < a ? (pt + Ot) * s - (a - t) / 2 : (Zt + Ot) * s - a;
|
|
307
304
|
})(), bn = (() => {
|
|
308
305
|
const t = dt * s;
|
|
309
|
-
return t <
|
|
310
|
-
})(),
|
|
306
|
+
return t < j ? ht * s - (j - t) / 2 : ht * s;
|
|
307
|
+
})(), vn = (() => {
|
|
308
|
+
const t = dt * s;
|
|
309
|
+
return t < j ? ht * s - (j - t) / 2 : (ht + dt) * s - j;
|
|
310
|
+
})(), We = Math.min(mn, Math.max(pn, zt.current)), Ne = Math.min(vn, Math.max(bn, Ct.current)), $e = f(
|
|
311
311
|
(t, n) => {
|
|
312
312
|
const i = [], l = [-0.5, -0.25, 0, 0.25, 0.5];
|
|
313
|
-
if (
|
|
314
|
-
const m = 1 -
|
|
313
|
+
if (z < 1) {
|
|
314
|
+
const m = 1 - z, b = l.map((P) => (1 - Math.cos((t - n * P) / 180 * Math.PI)) * m);
|
|
315
315
|
i.push(
|
|
316
|
-
`linear-gradient(to right,rgba(0,0,0,${
|
|
316
|
+
`linear-gradient(to right,rgba(0,0,0,${b[0]}),rgba(0,0,0,${b[1]}) 25%,rgba(0,0,0,${b[2]}) 50%,rgba(0,0,0,${b[3]}) 75%,rgba(0,0,0,${b[4]}))`
|
|
317
317
|
);
|
|
318
318
|
}
|
|
319
319
|
if (F > 0) {
|
|
320
|
-
const
|
|
321
|
-
(
|
|
322
|
-
Math.pow(Math.cos((t + 30 - n *
|
|
323
|
-
Math.pow(Math.cos((t - 30 - n *
|
|
320
|
+
const P = l.map(
|
|
321
|
+
(I) => Math.max(
|
|
322
|
+
Math.pow(Math.cos((t + 30 - n * I) / 180 * Math.PI), 200),
|
|
323
|
+
Math.pow(Math.cos((t - 30 - n * I) / 180 * Math.PI), 200)
|
|
324
324
|
)
|
|
325
325
|
);
|
|
326
326
|
i.push(
|
|
327
|
-
`linear-gradient(to right,rgba(255,255,255,${
|
|
327
|
+
`linear-gradient(to right,rgba(255,255,255,${P[0] * F}),rgba(255,255,255,${P[1] * F}) 25%,rgba(255,255,255,${P[2] * F}) 50%,rgba(255,255,255,${P[3] * F}) 75%,rgba(255,255,255,${P[4] * F}))`
|
|
328
328
|
);
|
|
329
329
|
}
|
|
330
330
|
return i.join(",");
|
|
331
331
|
},
|
|
332
|
-
[
|
|
332
|
+
[z, F]
|
|
333
333
|
), he = f(
|
|
334
334
|
(t) => {
|
|
335
335
|
const n = Q.current;
|
|
336
336
|
if (!n.direction) return [];
|
|
337
|
-
if (!Number.isFinite(
|
|
337
|
+
if (!Number.isFinite(M) || M <= 0 || w <= 0)
|
|
338
338
|
return [];
|
|
339
339
|
let i = n.progress, l = n.direction;
|
|
340
340
|
if (!Number.isFinite(i)) return [];
|
|
341
341
|
i < 0 && (i = 0), i > 1 && (i = 1), p === 1 && l !== d && (i = 1 - i, l = d);
|
|
342
|
-
const m = t === "front" ? n.frontImage : n.backImage,
|
|
343
|
-
let
|
|
344
|
-
p === 1 ? d === "right" ? t === "back" && (
|
|
345
|
-
const
|
|
346
|
-
|
|
342
|
+
const m = t === "front" ? n.frontImage : n.backImage, b = M / w;
|
|
343
|
+
let P = K, I = !1;
|
|
344
|
+
p === 1 ? d === "right" ? t === "back" && (I = !0, P = K - M) : l === "left" ? t === "back" ? P = M - K : I = !0 : t === "front" ? P = M - K : I = !0 : l === "left" ? t === "back" ? P = a / 2 : I = !0 : t === "front" ? P = a / 2 : I = !0;
|
|
345
|
+
const x = new ie();
|
|
346
|
+
x.translate(a / 2), x.perspective(R), x.translate(-a / 2), x.translate(P, ht);
|
|
347
347
|
let W = 0;
|
|
348
|
-
i > 0.5 && (W = -(i - 0.5) * 2 * 180), l === "left" && (W = -W), t === "back" && (W += 180), W && (
|
|
348
|
+
i > 0.5 && (W = -(i - 0.5) * 2 * 180), l === "left" && (W = -W), t === "back" && (W += 180), W && (I && x.translate(M), x.rotateY(W), I && x.translate(-M));
|
|
349
349
|
let k;
|
|
350
350
|
i < 0.5 ? k = i * 2 * Math.PI : k = (1 - (i - 0.5) * 2) * Math.PI, k === 0 && (k = 1e-9);
|
|
351
|
-
const
|
|
352
|
-
let
|
|
353
|
-
const
|
|
354
|
-
let
|
|
355
|
-
const J =
|
|
356
|
-
|
|
351
|
+
const bt = M / k;
|
|
352
|
+
let X = 0;
|
|
353
|
+
const N = k / w;
|
|
354
|
+
let H = N / 2 / Math.PI * 180;
|
|
355
|
+
const J = N / Math.PI * 180;
|
|
356
|
+
I && (H = -k / Math.PI * 180 + J / 2), t === "back" && (H = -H);
|
|
357
357
|
const $t = t === "back" ? -J : J;
|
|
358
358
|
lt.current = 1 / 0, ut.current = -1 / 0;
|
|
359
359
|
const q = [];
|
|
360
|
-
for (let ne = 0; ne <
|
|
361
|
-
const
|
|
362
|
-
let
|
|
363
|
-
|
|
364
|
-
let re = (1 - Math.cos(Ae)) *
|
|
365
|
-
t === "back" && (re = -re), Xt.translate3d(
|
|
366
|
-
const Ge = Xt.transformX(0), Ke = Xt.transformX(
|
|
360
|
+
for (let ne = 0; ne < w; ne++) {
|
|
361
|
+
const Dn = `${ne / (w - 1) * 100}% 0px`, Xt = x.clone(), Ae = I ? k - X : X;
|
|
362
|
+
let be = Math.sin(Ae) * bt;
|
|
363
|
+
I && (be = M - be);
|
|
364
|
+
let re = (1 - Math.cos(Ae)) * bt;
|
|
365
|
+
t === "back" && (re = -re), Xt.translate3d(be, 0, re), Xt.rotateY(-H);
|
|
366
|
+
const Ge = Xt.transformX(0), Ke = Xt.transformX(b);
|
|
367
367
|
ut.current = Math.max(Math.max(Ge, Ke), ut.current), lt.current = Math.min(Math.min(Ge, Ke), lt.current);
|
|
368
|
-
const
|
|
369
|
-
|
|
368
|
+
const zn = $e(W - H, $t);
|
|
369
|
+
X += N, H += $t, q.push({
|
|
370
370
|
key: t + ne,
|
|
371
371
|
bgImage: m,
|
|
372
|
-
lighting:
|
|
373
|
-
bgPos:
|
|
372
|
+
lighting: zn,
|
|
373
|
+
bgPos: Dn,
|
|
374
374
|
transform: Xt.toString(),
|
|
375
375
|
z: Math.abs(Math.round(re))
|
|
376
376
|
});
|
|
377
377
|
}
|
|
378
378
|
return q;
|
|
379
379
|
},
|
|
380
|
-
[p, d,
|
|
381
|
-
),
|
|
380
|
+
[p, d, M, K, ht, a, R, w, $e]
|
|
381
|
+
), Pn = Ve(() => L.direction ? [...he("front"), ...he("back")] : [], [L.direction, L.progress, L.frontImage, L.backImage, he]), V = f(
|
|
382
382
|
(t, n) => {
|
|
383
383
|
const i = Mt.current, l = Jt.current;
|
|
384
|
-
let m = null,
|
|
385
|
-
t !== d ? l === 1 ? (m = o[i - 1] ?? null,
|
|
384
|
+
let m = null, b = null;
|
|
385
|
+
t !== d ? l === 1 ? (m = o[i - 1] ?? null, b = null) : (m = o[d === "right" || l === 1 ? i : i + 1] ?? null, b = o[i - l + 1] ?? null) : l === 1 ? (m = o[i] ?? null, b = null) : (m = o[d === "left" ? i : i + 1] ?? null, b = o[i + l] ?? null), Y({
|
|
386
386
|
progress: 0,
|
|
387
387
|
direction: t,
|
|
388
388
|
frontImage: m,
|
|
389
|
-
backImage:
|
|
389
|
+
backImage: b,
|
|
390
390
|
auto: !1
|
|
391
|
-
}),
|
|
392
|
-
|
|
393
|
-
t !== d ? l === 2 && e(i - l) : l === 1 ? e(i + l) :
|
|
391
|
+
}), E(() => {
|
|
392
|
+
E(() => {
|
|
393
|
+
t !== d ? l === 2 && e(i - l) : l === 1 ? e(i + l) : St(i + 1 + l), n && pe(t);
|
|
394
394
|
});
|
|
395
395
|
});
|
|
396
396
|
},
|
|
397
|
-
[d, o,
|
|
397
|
+
[d, o, E]
|
|
398
398
|
), pe = f(
|
|
399
399
|
(t) => {
|
|
400
400
|
const n = Q.current, i = _ * (1 - n.progress), l = n.progress;
|
|
401
|
-
Y((
|
|
402
|
-
const m = Mt.current,
|
|
403
|
-
t === "left" ?
|
|
404
|
-
let
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
const W =
|
|
401
|
+
Y((x) => ({ ...x, auto: !0 }));
|
|
402
|
+
const m = Mt.current, b = o[0] !== null ? m + 1 : Math.max(1, m);
|
|
403
|
+
t === "left" ? we.current?.(b) : ke.current?.(b);
|
|
404
|
+
let P = null;
|
|
405
|
+
const I = (x) => {
|
|
406
|
+
P === null && (P = x);
|
|
407
|
+
const W = x - P;
|
|
408
408
|
let k = l + W / i;
|
|
409
409
|
k > 1 && (k = 1);
|
|
410
|
-
const
|
|
411
|
-
if (Y((
|
|
412
|
-
|
|
410
|
+
const bt = Qe(k);
|
|
411
|
+
if (Y((X) => ({ ...X, progress: bt })), k < 1)
|
|
412
|
+
E(I);
|
|
413
413
|
else {
|
|
414
|
-
const
|
|
415
|
-
let
|
|
416
|
-
t !== d ?
|
|
417
|
-
const
|
|
418
|
-
t === "left" ?
|
|
414
|
+
const X = Jt.current;
|
|
415
|
+
let N;
|
|
416
|
+
t !== d ? N = Mt.current - X : N = Mt.current + X, Fe.current(N);
|
|
417
|
+
const H = o[0] !== null ? N + 1 : Math.max(1, N);
|
|
418
|
+
t === "left" ? Le.current?.(H) : _e.current?.(H), X === 1 && t === d ? Y(Ht) : qt(1, () => {
|
|
419
419
|
Y(Ht);
|
|
420
420
|
});
|
|
421
421
|
}
|
|
422
422
|
};
|
|
423
|
-
|
|
423
|
+
E(I);
|
|
424
424
|
},
|
|
425
|
-
[_, d, o, qt,
|
|
425
|
+
[_, d, o, qt, E]
|
|
426
426
|
), Xe = f(() => {
|
|
427
427
|
const t = Q.current, n = _ * t.progress, i = t.progress;
|
|
428
|
-
Y((
|
|
428
|
+
Y((b) => ({ ...b, auto: !0 }));
|
|
429
429
|
let l = null;
|
|
430
|
-
const m = (
|
|
431
|
-
l === null && (l =
|
|
432
|
-
const
|
|
433
|
-
let
|
|
434
|
-
if (
|
|
435
|
-
|
|
430
|
+
const m = (b) => {
|
|
431
|
+
l === null && (l = b);
|
|
432
|
+
const P = b - l;
|
|
433
|
+
let I = i - i * P / n;
|
|
434
|
+
if (I < 0 && (I = 0), Y((x) => ({ ...x, progress: I })), I > 0)
|
|
435
|
+
E(m);
|
|
436
436
|
else {
|
|
437
|
-
const
|
|
438
|
-
e(
|
|
437
|
+
const x = Mt.current;
|
|
438
|
+
e(x), St(x + 1);
|
|
439
439
|
const W = Jt.current, k = Q.current.direction;
|
|
440
440
|
W === 1 && k !== d ? Y(Ht) : qt(1, () => {
|
|
441
441
|
Y(Ht);
|
|
442
442
|
});
|
|
443
443
|
}
|
|
444
444
|
};
|
|
445
|
-
|
|
446
|
-
}, [_, d, qt,
|
|
445
|
+
E(m);
|
|
446
|
+
}, [_, d, qt, E]), In = f(() => {
|
|
447
447
|
ot && V("left", !0);
|
|
448
|
-
}, [ot, V]),
|
|
448
|
+
}, [ot, V]), xn = f(() => {
|
|
449
449
|
it && V("right", !0);
|
|
450
|
-
}, [it, V]),
|
|
450
|
+
}, [it, V]), Lt = f(
|
|
451
451
|
(t, n) => {
|
|
452
452
|
const i = r.current;
|
|
453
453
|
if (!i) return;
|
|
@@ -457,38 +457,38 @@ function or(c, r) {
|
|
|
457
457
|
l = n.pageX - J.left, m = n.pageY - J.top;
|
|
458
458
|
} else
|
|
459
459
|
l = i.clientWidth / 2, m = i.clientHeight / 2;
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
let
|
|
463
|
-
const
|
|
464
|
-
|
|
465
|
-
const $t = J -
|
|
466
|
-
let q = $t /
|
|
467
|
-
q > 1 && (q = 1), q = Qe(q), se(
|
|
460
|
+
const b = wt.current, P = t, I = i.scrollLeft, x = i.scrollTop, W = l + I, k = m + x, bt = W / b * P - l, X = k / b * P - m;
|
|
461
|
+
Pe(!0), Re.current?.(t);
|
|
462
|
+
let N = null;
|
|
463
|
+
const H = (J) => {
|
|
464
|
+
N === null && (N = J);
|
|
465
|
+
const $t = J - N;
|
|
466
|
+
let q = $t / y;
|
|
467
|
+
q > 1 && (q = 1), q = Qe(q), se(b + (P - b) * q), zt.current = I + (bt - I) * q, Ct.current = x + (X - x) * q, $t < y ? E(H) : (Te.current?.(t), Pe(!1), se(t), zt.current = bt, Ct.current = X);
|
|
468
468
|
};
|
|
469
|
-
|
|
469
|
+
E(H), P > 1 && Vt(!0);
|
|
470
470
|
},
|
|
471
|
-
[
|
|
472
|
-
),
|
|
471
|
+
[y, r, Vt, E]
|
|
472
|
+
), Wt = f(
|
|
473
473
|
(t) => {
|
|
474
474
|
if (!ft) return;
|
|
475
475
|
const n = te.current + 1;
|
|
476
|
-
le(n),
|
|
476
|
+
le(n), Lt(g[n], t);
|
|
477
477
|
},
|
|
478
|
-
[ft, g,
|
|
478
|
+
[ft, g, Lt]
|
|
479
479
|
), Nt = f(
|
|
480
480
|
(t) => {
|
|
481
481
|
if (!gt) return;
|
|
482
482
|
const n = te.current - 1;
|
|
483
|
-
le(n),
|
|
483
|
+
le(n), Lt(g[n], t);
|
|
484
484
|
},
|
|
485
|
-
[gt, g,
|
|
485
|
+
[gt, g, Lt]
|
|
486
486
|
), He = f(
|
|
487
487
|
(t) => {
|
|
488
488
|
const n = (te.current + 1) % g.length;
|
|
489
|
-
le(n),
|
|
489
|
+
le(n), Lt(g[n], t);
|
|
490
490
|
},
|
|
491
|
-
[g,
|
|
491
|
+
[g, Lt]
|
|
492
492
|
), me = f(
|
|
493
493
|
(t) => {
|
|
494
494
|
if (t === null || t === ee) return;
|
|
@@ -501,112 +501,116 @@ function or(c, r) {
|
|
|
501
501
|
const Ue = f(
|
|
502
502
|
(t, n) => {
|
|
503
503
|
const i = r.current;
|
|
504
|
-
i && (i.scrollLeft =
|
|
504
|
+
i && (i.scrollLeft = ye.current - t, i.scrollTop = Me.current - n, zt.current = i.scrollLeft, Ct.current = i.scrollTop);
|
|
505
505
|
},
|
|
506
506
|
[r]
|
|
507
|
-
),
|
|
507
|
+
), kt = f(
|
|
508
508
|
(t) => {
|
|
509
|
-
if (
|
|
510
|
-
|
|
509
|
+
if (It.current = t.pageX, xe.current = t.pageY, xt.current = 0, wt.current <= 1)
|
|
510
|
+
O && (yt.current = "grab");
|
|
511
511
|
else {
|
|
512
512
|
const n = r.current;
|
|
513
|
-
n && (
|
|
513
|
+
n && (ye.current = n.scrollLeft, Me.current = n.scrollTop), yt.current = "all-scroll";
|
|
514
514
|
}
|
|
515
515
|
},
|
|
516
|
-
[
|
|
517
|
-
),
|
|
516
|
+
[O, r]
|
|
517
|
+
), _t = f(
|
|
518
518
|
(t) => {
|
|
519
|
-
if (
|
|
520
|
-
const n = t.pageX -
|
|
521
|
-
if (
|
|
519
|
+
if (It.current === null) return !1;
|
|
520
|
+
const n = t.pageX - It.current, i = t.pageY - xe.current;
|
|
521
|
+
if (xt.current = Math.max(xt.current, Math.abs(n)), xt.current = Math.max(xt.current, Math.abs(i)), wt.current > 1)
|
|
522
522
|
return G.current || Ue(n, i), !1;
|
|
523
|
-
if (!
|
|
524
|
-
|
|
523
|
+
if (!O || Math.abs(i) > Math.abs(n) || !Number.isFinite(M) || M <= 0) return !1;
|
|
524
|
+
yt.current = "grabbing", Ie((m) => m + 1);
|
|
525
525
|
const l = Q.current;
|
|
526
526
|
return n > 0 ? (l.direction === null && ot && n >= S && V("left", !1), Q.current.direction === "left" && Y((m) => ({
|
|
527
527
|
...m,
|
|
528
|
-
progress: Math.min(n /
|
|
528
|
+
progress: Math.min(n / M, 1)
|
|
529
529
|
}))) : (l.direction === null && it && n <= -S && V("right", !1), Q.current.direction === "right" && Y((m) => ({
|
|
530
530
|
...m,
|
|
531
|
-
progress: Math.min(-n /
|
|
531
|
+
progress: Math.min(-n / M, 1)
|
|
532
532
|
}))), !0;
|
|
533
533
|
},
|
|
534
|
-
[
|
|
535
|
-
),
|
|
534
|
+
[O, ot, it, S, V, M, Ue]
|
|
535
|
+
), Rt = f(
|
|
536
536
|
(t) => {
|
|
537
|
-
if (
|
|
538
|
-
A &&
|
|
537
|
+
if (It.current === null) return;
|
|
538
|
+
A && xt.current < S && He(t);
|
|
539
539
|
const n = Q.current;
|
|
540
|
-
n.direction !== null && !n.auto && (n.progress > 1 / 4 ? pe(n.direction) : Xe()),
|
|
540
|
+
n.direction !== null && !n.auto && (n.progress > 1 / 4 ? pe(n.direction) : Xe()), It.current = null, yt.current = null, Ie((i) => i + 1);
|
|
541
541
|
},
|
|
542
542
|
[A, S, He, pe, Xe]
|
|
543
|
+
), yn = f(
|
|
544
|
+
(t) => {
|
|
545
|
+
G.current = !0, kt(t.changedTouches[0]);
|
|
546
|
+
},
|
|
547
|
+
[kt]
|
|
543
548
|
), Mn = f(
|
|
544
549
|
(t) => {
|
|
545
|
-
|
|
550
|
+
if (_t(t.changedTouches[0])) {
|
|
551
|
+
t.cancelable && t.preventDefault();
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
O && wt.current <= 1 && It.current !== null && t.cancelable && t.preventDefault();
|
|
546
555
|
},
|
|
547
|
-
[
|
|
556
|
+
[O, _t]
|
|
548
557
|
), wn = f(
|
|
549
558
|
(t) => {
|
|
550
|
-
|
|
559
|
+
Rt(t.changedTouches[0]);
|
|
551
560
|
},
|
|
552
|
-
[
|
|
561
|
+
[Rt]
|
|
553
562
|
), Ln = f(
|
|
554
|
-
(t) => {
|
|
555
|
-
kt(t.changedTouches[0]);
|
|
556
|
-
},
|
|
557
|
-
[kt]
|
|
558
|
-
), xn = f(
|
|
559
563
|
(t) => {
|
|
560
564
|
if (Qt.current = !0, !G.current && t.button === 0) {
|
|
561
|
-
|
|
565
|
+
kt(t);
|
|
562
566
|
try {
|
|
563
567
|
t.target.setPointerCapture(t.pointerId);
|
|
564
568
|
} catch {
|
|
565
569
|
}
|
|
566
570
|
}
|
|
567
571
|
},
|
|
568
|
-
[
|
|
572
|
+
[kt]
|
|
569
573
|
), kn = f(
|
|
570
574
|
(t) => {
|
|
571
|
-
G.current ||
|
|
575
|
+
G.current || _t(t);
|
|
572
576
|
},
|
|
573
|
-
[
|
|
577
|
+
[_t]
|
|
574
578
|
), _n = f(
|
|
575
579
|
(t) => {
|
|
576
580
|
if (!G.current) {
|
|
577
|
-
|
|
581
|
+
Rt(t);
|
|
578
582
|
try {
|
|
579
583
|
t.target.releasePointerCapture(t.pointerId);
|
|
580
584
|
} catch {
|
|
581
585
|
}
|
|
582
586
|
}
|
|
583
587
|
},
|
|
584
|
-
[
|
|
588
|
+
[Rt]
|
|
585
589
|
), Rn = f(
|
|
586
590
|
(t) => {
|
|
587
|
-
G.current || Qt.current || t.button === 0 &&
|
|
591
|
+
G.current || Qt.current || t.button === 0 && kt(t);
|
|
588
592
|
},
|
|
589
|
-
[
|
|
593
|
+
[kt]
|
|
590
594
|
), Tn = f(
|
|
591
595
|
(t) => {
|
|
592
|
-
G.current || Qt.current ||
|
|
596
|
+
G.current || Qt.current || _t(t);
|
|
593
597
|
},
|
|
594
|
-
[
|
|
598
|
+
[_t]
|
|
595
599
|
), Fn = f(
|
|
596
600
|
(t) => {
|
|
597
|
-
G.current || Qt.current ||
|
|
601
|
+
G.current || Qt.current || Rt(t);
|
|
598
602
|
},
|
|
599
|
-
[
|
|
603
|
+
[Rt]
|
|
600
604
|
), Sn = f(
|
|
601
605
|
(t) => {
|
|
602
|
-
if (st === "scroll" &&
|
|
606
|
+
if (st === "scroll" && wt.current > 1 && !G.current) {
|
|
603
607
|
const n = r.current;
|
|
604
608
|
n && (n.scrollLeft += t.deltaX, n.scrollTop += t.deltaY, zt.current = n.scrollLeft, Ct.current = n.scrollTop), t.cancelable && t.preventDefault();
|
|
605
609
|
}
|
|
606
|
-
st === "zoom" && (t.deltaY >= 100 ? (Nt(t), t.cancelable && t.preventDefault()) : t.deltaY <= -100 && (
|
|
610
|
+
st === "zoom" && (t.deltaY >= 100 ? (Nt(t), t.cancelable && t.preventDefault()) : t.deltaY <= -100 && (Wt(t), t.cancelable && t.preventDefault()));
|
|
607
611
|
},
|
|
608
|
-
[st, r, Nt,
|
|
609
|
-
),
|
|
612
|
+
[st, r, Nt, Wt]
|
|
613
|
+
), jn = f(
|
|
610
614
|
(t) => {
|
|
611
615
|
switch (t.key) {
|
|
612
616
|
case "ArrowLeft":
|
|
@@ -617,31 +621,31 @@ function or(c, r) {
|
|
|
617
621
|
break;
|
|
618
622
|
case "+":
|
|
619
623
|
case "=":
|
|
620
|
-
t.preventDefault(), ft &&
|
|
624
|
+
t.preventDefault(), ft && Wt();
|
|
621
625
|
break;
|
|
622
626
|
case "-":
|
|
623
627
|
t.preventDefault(), gt && Nt();
|
|
624
628
|
break;
|
|
625
629
|
}
|
|
626
630
|
},
|
|
627
|
-
[ot, it, ft, gt, V,
|
|
631
|
+
[ot, it, ft, gt, V, Wt, Nt]
|
|
628
632
|
);
|
|
629
|
-
|
|
630
|
-
|
|
633
|
+
$(() => {
|
|
634
|
+
vt === 2 && U((t) => {
|
|
631
635
|
const n = t & -2;
|
|
632
636
|
return n === 0 && h ? t : n;
|
|
633
637
|
}), lt.current = 1 / 0, ut.current = -1 / 0;
|
|
634
|
-
}, [ce,
|
|
638
|
+
}, [ce, vt, h, U]);
|
|
635
639
|
const Ye = u(Vt);
|
|
636
|
-
return Ye.current = Vt,
|
|
637
|
-
e(
|
|
638
|
-
}, [
|
|
640
|
+
return Ye.current = Vt, $(() => {
|
|
641
|
+
e(C), St(C + 1), Ye.current();
|
|
642
|
+
}, [C]), $(() => {
|
|
639
643
|
if (Et.current || Gt === null) return;
|
|
640
644
|
Et.current = !0;
|
|
641
645
|
const t = () => {
|
|
642
|
-
|
|
646
|
+
E(() => {
|
|
643
647
|
ue((n) => {
|
|
644
|
-
const i =
|
|
648
|
+
const i = Ze.current;
|
|
645
649
|
if (n === null)
|
|
646
650
|
return Et.current = !1, i;
|
|
647
651
|
const l = i - n;
|
|
@@ -650,19 +654,19 @@ function or(c, r) {
|
|
|
650
654
|
});
|
|
651
655
|
};
|
|
652
656
|
t();
|
|
653
|
-
}, [mt,
|
|
657
|
+
}, [mt, E]), $(() => {
|
|
654
658
|
const t = r.current;
|
|
655
|
-
t && (t.scrollLeft =
|
|
656
|
-
}, [
|
|
659
|
+
t && (t.scrollLeft = We);
|
|
660
|
+
}, [We, r]), $(() => {
|
|
657
661
|
const t = r.current;
|
|
658
662
|
t && (t.scrollTop = Ne);
|
|
659
|
-
}, [Ne, r]),
|
|
660
|
-
|
|
661
|
-
}, [o,
|
|
663
|
+
}, [Ne, r]), $(() => {
|
|
664
|
+
De();
|
|
665
|
+
}, [o, De]), $(() => {
|
|
662
666
|
Be.current(ct);
|
|
663
|
-
}, [ct]),
|
|
667
|
+
}, [ct]), $(() => {
|
|
664
668
|
se(g[0]);
|
|
665
|
-
}, []),
|
|
669
|
+
}, []), $(() => {
|
|
666
670
|
const t = fe.current;
|
|
667
671
|
return () => {
|
|
668
672
|
t.forEach(cancelAnimationFrame), t.clear();
|
|
@@ -670,14 +674,14 @@ function or(c, r) {
|
|
|
670
674
|
}, []), {
|
|
671
675
|
// Layout
|
|
672
676
|
viewWidth: a,
|
|
673
|
-
viewHeight:
|
|
674
|
-
pageWidth:
|
|
677
|
+
viewHeight: j,
|
|
678
|
+
pageWidth: M,
|
|
675
679
|
pageHeight: dt,
|
|
676
680
|
xMargin: K,
|
|
677
681
|
yMargin: ht,
|
|
678
682
|
displayedPages: p,
|
|
679
683
|
zoom: s,
|
|
680
|
-
centerOffsetSmoothed:
|
|
684
|
+
centerOffsetSmoothed: Ot,
|
|
681
685
|
// Pages
|
|
682
686
|
page: ee,
|
|
683
687
|
numPages: Se,
|
|
@@ -688,9 +692,9 @@ function or(c, r) {
|
|
|
688
692
|
pageUrlLoading: nn,
|
|
689
693
|
loadImage: en,
|
|
690
694
|
// Flip
|
|
691
|
-
flip:
|
|
695
|
+
flip: L,
|
|
692
696
|
flipOpacity: fn,
|
|
693
|
-
polygonArray:
|
|
697
|
+
polygonArray: Pn,
|
|
694
698
|
polygonWidth: sn,
|
|
695
699
|
polygonHeight: ln,
|
|
696
700
|
polygonBgSize: un,
|
|
@@ -701,98 +705,98 @@ function or(c, r) {
|
|
|
701
705
|
canZoomOut: gt,
|
|
702
706
|
// Bounds
|
|
703
707
|
boundingLeft: pt,
|
|
704
|
-
boundingRight:
|
|
708
|
+
boundingRight: Zt,
|
|
705
709
|
// Cursor
|
|
706
710
|
cursor: gn,
|
|
707
711
|
viewportClass: hn,
|
|
708
712
|
// Actions
|
|
709
|
-
flipLeft:
|
|
710
|
-
flipRight:
|
|
711
|
-
zoomIn:
|
|
713
|
+
flipLeft: In,
|
|
714
|
+
flipRight: xn,
|
|
715
|
+
zoomIn: Wt,
|
|
712
716
|
zoomOut: Nt,
|
|
713
717
|
goToPage: me,
|
|
714
718
|
// Stable ref for imperative API
|
|
715
|
-
apiRef:
|
|
719
|
+
apiRef: je,
|
|
716
720
|
// Event handlers
|
|
717
721
|
handlers: {
|
|
718
|
-
onTouchStart:
|
|
719
|
-
onTouchMove:
|
|
720
|
-
onTouchEnd:
|
|
721
|
-
onPointerDown:
|
|
722
|
+
onTouchStart: yn,
|
|
723
|
+
onTouchMove: Mn,
|
|
724
|
+
onTouchEnd: wn,
|
|
725
|
+
onPointerDown: Ln,
|
|
722
726
|
onPointerMove: kn,
|
|
723
727
|
onPointerUp: _n,
|
|
724
728
|
onMouseDown: Rn,
|
|
725
729
|
onMouseMove: Tn,
|
|
726
730
|
onMouseUp: Fn,
|
|
727
731
|
onWheel: Sn,
|
|
728
|
-
onKeyDown:
|
|
732
|
+
onKeyDown: jn
|
|
729
733
|
},
|
|
730
734
|
onImageLoad: rn
|
|
731
735
|
};
|
|
732
736
|
}
|
|
733
|
-
const sr =
|
|
737
|
+
const sr = Cn(
|
|
734
738
|
function({
|
|
735
739
|
pages: r,
|
|
736
740
|
pagesHiRes: o,
|
|
737
|
-
pageLabels:
|
|
741
|
+
pageLabels: v,
|
|
738
742
|
flipDuration: _,
|
|
739
|
-
zoomDuration:
|
|
740
|
-
zooms:
|
|
743
|
+
zoomDuration: y,
|
|
744
|
+
zooms: Z,
|
|
741
745
|
perspective: R,
|
|
742
|
-
nPolygons:
|
|
743
|
-
ambient:
|
|
746
|
+
nPolygons: w,
|
|
747
|
+
ambient: z,
|
|
744
748
|
gloss: F,
|
|
745
749
|
swipeMin: S,
|
|
746
|
-
singlePage:
|
|
750
|
+
singlePage: B,
|
|
747
751
|
forwardDirection: d,
|
|
748
752
|
centering: et,
|
|
749
753
|
startPage: ct,
|
|
750
754
|
loadingImage: at,
|
|
751
755
|
clickToZoom: A,
|
|
752
|
-
dragToFlip:
|
|
756
|
+
dragToFlip: O,
|
|
753
757
|
wheel: st,
|
|
754
758
|
page: nt,
|
|
755
759
|
onPageChange: rt,
|
|
756
760
|
onFlipLeftStart: g,
|
|
757
761
|
onFlipLeftEnd: h,
|
|
758
762
|
onFlipRightStart: a,
|
|
759
|
-
onFlipRightEnd:
|
|
760
|
-
onZoomStart:
|
|
763
|
+
onFlipRightEnd: j,
|
|
764
|
+
onZoomStart: vt,
|
|
761
765
|
onZoomEnd: ce,
|
|
762
766
|
children: ae,
|
|
763
767
|
className: Ut,
|
|
764
|
-
...
|
|
765
|
-
},
|
|
768
|
+
...Tt
|
|
769
|
+
}, C) {
|
|
766
770
|
const U = u(null), e = or({
|
|
767
771
|
pages: r,
|
|
768
772
|
pagesHiRes: o,
|
|
769
773
|
flipDuration: _,
|
|
770
|
-
zoomDuration:
|
|
771
|
-
zooms:
|
|
774
|
+
zoomDuration: y,
|
|
775
|
+
zooms: Z,
|
|
772
776
|
perspective: R,
|
|
773
|
-
nPolygons:
|
|
774
|
-
ambient:
|
|
777
|
+
nPolygons: w,
|
|
778
|
+
ambient: z,
|
|
775
779
|
gloss: F,
|
|
776
780
|
swipeMin: S,
|
|
777
|
-
singlePage:
|
|
781
|
+
singlePage: B,
|
|
778
782
|
forwardDirection: d,
|
|
779
783
|
centering: et,
|
|
780
784
|
startPage: ct,
|
|
781
785
|
loadingImage: at,
|
|
782
786
|
clickToZoom: A,
|
|
783
|
-
dragToFlip:
|
|
787
|
+
dragToFlip: O,
|
|
784
788
|
wheel: st,
|
|
785
789
|
page: nt,
|
|
786
790
|
onPageChange: rt,
|
|
787
791
|
onFlipLeftStart: g,
|
|
788
792
|
onFlipLeftEnd: h,
|
|
789
793
|
onFlipRightStart: a,
|
|
790
|
-
onFlipRightEnd:
|
|
791
|
-
onZoomStart:
|
|
794
|
+
onFlipRightEnd: j,
|
|
795
|
+
onZoomStart: vt,
|
|
792
796
|
onZoomEnd: ce
|
|
793
797
|
}, U);
|
|
794
|
-
|
|
795
|
-
|
|
798
|
+
En(
|
|
799
|
+
C,
|
|
796
800
|
() => ({
|
|
797
801
|
get flipLeft() {
|
|
798
802
|
return e.flipLeft;
|
|
@@ -832,12 +836,12 @@ const sr = En(
|
|
|
832
836
|
// only rebuild when action functions change
|
|
833
837
|
[e.flipLeft, e.flipRight, e.zoomIn, e.zoomOut, e.goToPage, e.apiRef]
|
|
834
838
|
);
|
|
835
|
-
const
|
|
839
|
+
const Ft = (s) => v && v[s] ? v[s] : `Page ${s + 1}`, St = Ut ? `${D.root} ${Ut}` : D.root;
|
|
836
840
|
return /* @__PURE__ */ oe(
|
|
837
841
|
"div",
|
|
838
842
|
{
|
|
839
|
-
...
|
|
840
|
-
className:
|
|
843
|
+
...Tt,
|
|
844
|
+
className: St,
|
|
841
845
|
role: "document",
|
|
842
846
|
"aria-label": `Book viewer, page ${e.page} of ${e.numPages}`,
|
|
843
847
|
"aria-roledescription": "flipbook",
|
|
@@ -877,7 +881,7 @@ const sr = En(
|
|
|
877
881
|
children: /* @__PURE__ */ oe(
|
|
878
882
|
"div",
|
|
879
883
|
{
|
|
880
|
-
className:
|
|
884
|
+
className: D.container,
|
|
881
885
|
style: { transform: `scale(${e.zoom})` },
|
|
882
886
|
children: [
|
|
883
887
|
/* @__PURE__ */ tt(
|
|
@@ -887,7 +891,7 @@ const sr = En(
|
|
|
887
891
|
tabIndex: e.canFlipLeft ? 0 : -1,
|
|
888
892
|
"aria-label": "Previous page",
|
|
889
893
|
"aria-disabled": !e.canFlipLeft,
|
|
890
|
-
className:
|
|
894
|
+
className: D.clickLeft,
|
|
891
895
|
style: {
|
|
892
896
|
cursor: e.canFlipLeft ? "pointer" : "auto"
|
|
893
897
|
},
|
|
@@ -904,7 +908,7 @@ const sr = En(
|
|
|
904
908
|
tabIndex: e.canFlipRight ? 0 : -1,
|
|
905
909
|
"aria-label": "Next page",
|
|
906
910
|
"aria-disabled": !e.canFlipRight,
|
|
907
|
-
className:
|
|
911
|
+
className: D.clickRight,
|
|
908
912
|
style: {
|
|
909
913
|
cursor: e.canFlipRight ? "pointer" : "auto"
|
|
910
914
|
},
|
|
@@ -924,7 +928,7 @@ const sr = En(
|
|
|
924
928
|
e.showLeftPage && /* @__PURE__ */ tt(
|
|
925
929
|
"img",
|
|
926
930
|
{
|
|
927
|
-
className:
|
|
931
|
+
className: D.page,
|
|
928
932
|
style: {
|
|
929
933
|
width: e.pageWidth + "px",
|
|
930
934
|
height: e.pageHeight + "px",
|
|
@@ -932,14 +936,14 @@ const sr = En(
|
|
|
932
936
|
top: e.yMargin + "px"
|
|
933
937
|
},
|
|
934
938
|
src: e.pageUrlLoading(e.leftPage, !0) ?? void 0,
|
|
935
|
-
alt:
|
|
939
|
+
alt: Ft(e.leftPage),
|
|
936
940
|
onLoad: e.onImageLoad
|
|
937
941
|
}
|
|
938
942
|
),
|
|
939
943
|
e.showRightPage && /* @__PURE__ */ tt(
|
|
940
944
|
"img",
|
|
941
945
|
{
|
|
942
|
-
className:
|
|
946
|
+
className: D.page,
|
|
943
947
|
style: {
|
|
944
948
|
width: e.pageWidth + "px",
|
|
945
949
|
height: e.pageHeight + "px",
|
|
@@ -947,14 +951,14 @@ const sr = En(
|
|
|
947
951
|
top: e.yMargin + "px"
|
|
948
952
|
},
|
|
949
953
|
src: e.pageUrlLoading(e.rightPage, !0) ?? void 0,
|
|
950
|
-
alt:
|
|
954
|
+
alt: Ft(e.rightPage),
|
|
951
955
|
onLoad: e.onImageLoad
|
|
952
956
|
}
|
|
953
957
|
),
|
|
954
958
|
/* @__PURE__ */ tt("div", { style: { opacity: e.flipOpacity }, children: e.polygonArray.map((s) => /* @__PURE__ */ tt(
|
|
955
959
|
"div",
|
|
956
960
|
{
|
|
957
|
-
className: s.bgImage ?
|
|
961
|
+
className: s.bgImage ? D.polygon : D.polygonBlank,
|
|
958
962
|
style: {
|
|
959
963
|
backgroundImage: s.bgImage ? `url(${e.loadImage(s.bgImage)})` : void 0,
|
|
960
964
|
backgroundSize: e.polygonBgSize,
|
|
@@ -967,7 +971,7 @@ const sr = En(
|
|
|
967
971
|
children: s.lighting && /* @__PURE__ */ tt(
|
|
968
972
|
"div",
|
|
969
973
|
{
|
|
970
|
-
className:
|
|
974
|
+
className: D.lighting,
|
|
971
975
|
style: { backgroundImage: s.lighting }
|
|
972
976
|
}
|
|
973
977
|
)
|
|
@@ -977,7 +981,7 @@ const sr = En(
|
|
|
977
981
|
/* @__PURE__ */ tt(
|
|
978
982
|
"div",
|
|
979
983
|
{
|
|
980
|
-
className:
|
|
984
|
+
className: D.boundingBox,
|
|
981
985
|
style: {
|
|
982
986
|
left: e.boundingLeft + "px",
|
|
983
987
|
top: e.yMargin + "px",
|
|
@@ -1004,7 +1008,7 @@ const sr = En(
|
|
|
1004
1008
|
role: "status",
|
|
1005
1009
|
"aria-live": "polite",
|
|
1006
1010
|
"aria-atomic": "true",
|
|
1007
|
-
className:
|
|
1011
|
+
className: D.srOnly,
|
|
1008
1012
|
children: [
|
|
1009
1013
|
"Page ",
|
|
1010
1014
|
e.page,
|