smartphoto 2.1.11 → 2.1.13
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 +5 -0
- package/css/smartphoto.css +24 -0
- package/css/smartphoto.min.css +1 -1
- package/js/jquery-smartphoto.js +179 -31
- package/js/jquery-smartphoto.min.js +2 -2
- package/js/smartphoto.js +179 -31
- package/js/smartphoto.min.js +2 -2
- package/lib/smartphoto.js +178 -30
- package/lib/smartphoto.mjs +178 -30
- package/lib/types/core/index.d.ts +5 -0
- package/lib/types/core/types.d.ts +2 -1
- package/lib/types/core/view.d.ts +1 -0
- package/lib/types/lib/util.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SmartPhoto v2.1.
|
|
2
|
+
* SmartPhoto v2.1.13
|
|
3
3
|
* (c) appleple
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
"use strict";(()=>{var K=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function xe(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let r=e[o];if(r){for(let s in r)if(Object.hasOwn(r,s)){let n=r[s];n&&typeof n=="object"?t[s]=xe((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var Ie=xe,Le=(t,e,i)=>{let o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,i)),t.dispatchEvent(o)},Ce=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},Z=()=>document.documentElement.clientWidth,ee=()=>{let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight},Te=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Se=t=>{let e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null},Re=.179,$e=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let u=n/255;return u<=.03928?u/12.92:((u+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Ae=t=>{let e=t.trim(),i=Se(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=Se(getComputedStyle(o).color),document.body.removeChild(o)}return i&&$e(i)>Re?"#000":"#fff"};var Ue={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:450};function Me(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Me(i)}),Object.freeze(t)}function He(t){return{options:Me(Ie({},Ue,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function q(t){return t.getAttribute("data-group")||"nogroup"}function me(t){return t.group||"nogroup"}function pe(t,e,i,o){let r=q(t),s=t.getAttribute("href"),n=t.querySelector("img"),u=s;n&&(n.getAttribute(e.lazyAttribute)?u=n.getAttribute(e.lazyAttribute):n.currentSrc?u=n.currentSrc:u=n.src);let p="";n!=null&&n.getAttribute("alt")?p=n.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let d=t.getAttribute("data-id");return{src:s,thumb:u,caption:t.getAttribute("data-caption"),alt:p,groupId:r,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:d||i,loaded:!1,processed:!1,element:t}}function ze(t,e,i){var d,v,y,P,S;let o=me(t),r=t.src,s=(d=t.thumb)!=null?d:r,n=(v=t.caption)!=null?v:null,u=(P=(y=t.alt)!=null?y:n)!=null?P:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:u,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(S=t.id)!=null?S:e,loaded:p,processed:!1,element:null}}function fe(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function A(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function z(t){var i;let e=A(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function ve(t){let e=A(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,r=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),r!==-1&&(t.viewer.prev=r,t.viewer.showPrevArrow=!0)}function we(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function te(t,e){let i=10**e;return Math.round(t*i)/i}function Q(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Oe(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,u,p,d;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(d=(o-s)/2,u=-1*d):(d=(s-o)/2,u=-1*d),{minX:te(n,6)*e.scaleSize,minY:te(u,6)*e.scaleSize,maxX:te(p,6)*e.scaleSize,maxY:te(d,6)*e.scaleSize}}function De(t,e,i,o,r){let s=i-(o+r);t.forEach(n=>{n.loaded&&(n.processed=!0,n.scale=s/n.height,n.height<s&&(n.scale=1),n.x=(n.scale-1)/2*n.width+(e-n.width*n.scale)/2,n.y=(n.scale-1)/2*n.height+(i-n.height*n.scale)/2,n.width*n.scale>e&&(n.scale=e/n.width,n.x=(n.scale-1)/2*n.width))})}function Ne(t){let e=z(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Ve(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function ge(t,e){let i=10**e;return Math.round(t*i)/i}function R(t){return{x:t.pageX,y:t.pageY}}function Be(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var je=10;function qe(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Xe(){return{width:Z(),height:ee()}}function Ye({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,u=null,p=null,d=null,v=0,y=!1,P=null,S=null,O=0,D=0,H=!1,Y=0,x=null,C=0,N=0;function c(){return K()}function $(a){let{width:h,height:E}=Xe();return Oe(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=Xe();return Q(a,h,E,c())}function oe(a,h){let E=z(t),g=$(E);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=g.minX:a===-1&&(t.viewer.photoPosX=g.maxX),h===1?t.viewer.photoPosY=g.minY:h===-1&&(t.viewer.photoPosY=g.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let re=setInterval(()=>{if(H||s||y||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=C,t.viewer.photoPosY+=N;let a=z(t);if(!a)return;let h=$(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,C*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,C*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,N*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,N*=-.2);let E=qe(C,N),g=E.force-t.options.registance;Math.abs(g)<.5||(C=Math.cos(E.theta)*g,N=Math.sin(E.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function V(a,h){(a>5||a<-5)&&(C+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(N+=h*.05)}function J(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||H||s||y||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?V(a.gamma,a.beta):h===90?V(a.beta,a.gamma):h===-90?V(-a.beta,-a.gamma):h===180&&V(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",J,{signal:i});function ne(){H=!0,s=!1,y=!1;let a=Array.from(o.values());Y=Be(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function se(a){let h=R(a);s=!0,n=!0,u=h,p=h,v=Date.now()}function ae(a){y=!0;let h=R(a);S=h,P=h}function le(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(g){}if(o.set(a.pointerId,R(a)),o.size>1){ne();return}if(t.viewer.scale){ae(a);return}se(a)}function he(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function ue(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function m(){let a=Array.from(o.values()),h=Be(a[0],a[1]),E=(h-Y)/100,g=t.viewer.scaleSize,L=t.viewer.photoPosX,T=t.viewer.photoPosY;t.viewer.scaleSize+=ge(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<g&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-g)*L,t.viewer.photoPosY=(1+t.viewer.scaleSize-g)*T);let X=z(t);if(X){let de=U(X);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>de}Y=h,he()}function l(a){let h=R(a),E=h.x-p.x,g=h.y-u.y;n&&(e.onSwipeStart(),n=!1,d=Math.abs(E)>Math.abs(g)?"horizontal":"vertical"),d==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=g,p=h,e.onSwipeMove()}function b(a){let h=R(a),E=h.x-S.x,g=h.y-S.y,L=ge(t.viewer.scaleSize*E,6),T=ge(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=L,O=L,t.viewer.photoPosY+=T,D=T,S=h,e.onPhotoDragMove()}function w(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,R(a)),H){m();return}if(y){b(a);return}l(a)}}function f(){H=!1,ue();let a=z(t);if(!a)return;let h=U(a);t.viewer.scaleSize>h||(t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scale=!1,t.viewer.scaleSize=1,t.viewer.hideUi=!1,e.onGestureEnd())}function I(){var be;s=!1;let a=u,h=p,E=Date.now(),g=r-E,L=h.x-a.x,T=h.y-a.y,X=L===0&&T===0;if(!c()&&X){e.onTap();return}if(Math.abs(g)<=500&&X){e.onTap();return}r=E;let de=(be=A(t))!=null?be:[];if(d==="horizontal"){let F="stay",Fe=Math.max(E-v,1),Pe=Math.abs(L)>=je&&Math.abs(L)/Fe>=t.options.swipeVelocity;(L>=t.options.swipeOffset||Pe&&L>0)&&t.viewer.currentIndex!==0?F="prev":(L<=-t.options.swipeOffset||Pe&&L<0)&&t.viewer.currentIndex!==de.length-1&&(F="next"),e.onSwipeEnd(F)}else{let F="stay";t.options.swipeBottomToClose&&T>=t.options.swipeOffset?F="close-bottom":t.options.swipeTopToClose&&T<=-t.options.swipeOffset&&(F="close-top"),e.onSwipeEnd(F)}}function W(){y=!1;let a=S,h=P;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=z(t);if(!E){e.onPhotoDragEnd(null);return}let g=$(E),L=t.options.swipeOffset*t.viewer.scaleSize,T=0,X=0;if(t.viewer.photoPosX>g.maxX?T=-1:t.viewer.photoPosX<g.minX&&(T=1),t.viewer.photoPosY>g.maxY?X=-1:t.viewer.photoPosY<g.minY&&(X=1),t.viewer.photoPosX-g.maxX>L&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>L&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}T===0&&X===0?(C=O/5,N=D/5):oe(T,X),e.onPhotoDragEnd(null)}function j(a){if(o.delete(a.pointerId),H){o.size<2&&f();return}if(y){W();return}s&&I()}function B(...a){for(let h of a)h.addEventListener("pointerdown",le,{signal:i}),h.addEventListener("pointermove",w,{signal:i}),h.addEventListener("pointerup",j,{signal:i}),h.addEventListener("pointercancel",j,{signal:i})}function G(){clearInterval(re),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:B,detach:G}}function ie(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function Ee(){let t=document.createElement("button");return t.type="button",t}function Qe(t){return t.replace(/"/g,'\\"')}function Ge({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let u=document.createElement("dialog");u.className=r.smartPhoto,u.setAttribute("aria-labelledby",`smartphoto-${t}-title`),u.style.display="none",u.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let d=document.createElement("div");d.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let y=document.createElement("span");y.className=r.smartPhotoCount;let P=document.createElement("h1");P.id=`smartphoto-${t}-title`,P.className=r.smartPhotoCaption,P.setAttribute("tabindex","-1");let S=document.createElement("button");S.className=r.smartPhotoDismiss,S.appendChild(ie(s.closeDialog)),S.addEventListener("click",()=>i.onDismiss(),{signal:o}),v.append(y,P,S);let O=document.createElement("div");O.className=r.smartPhotoContent,O.addEventListener("click",m=>{m.target===O&&i.onBackdropClick()},{signal:o});let D=document.createElement("ul");D.className=r.smartPhotoList,D.setAttribute("role","region"),D.setAttribute("aria-roledescription","carousel"),D.setAttribute("aria-label",s.carouselLabel),D.setAttribute("aria-live","polite"),D.setAttribute("aria-atomic","false"),d.append(v,O,D);let H=null,Y=null,x=null;if(e.arrows){H=document.createElement("ul"),H.className=r.smartPhotoArrows,Y=document.createElement("li"),Y.className=r.smartPhotoArrowLeft;let m=Ee();m.appendChild(ie(s.gotoPrevImage)),m.addEventListener("click",()=>i.onPrev(),{signal:o}),Y.appendChild(m),x=document.createElement("li"),x.className=r.smartPhotoArrowRight;let l=Ee();l.appendChild(ie(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),x.appendChild(l),H.append(Y,x),d.appendChild(H)}let C=null,N=null;e.nav&&(C=document.createElement("nav"),C.className=r.smartPhotoNav,C.setAttribute("aria-label","Choose slide to display"),N=document.createElement("ul"),C.appendChild(N),d.appendChild(C)),p.appendChild(d),u.appendChild(p),n.appendChild(u);let c={dialog:u,count:y,caption:P,dismiss:S,content:O,list:D,arrows:H,arrowLeft:Y,arrowRight:x,nav:C,navList:N,slides:new Map,imgClone:null};function $(){let m=document.createElement("div");m.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,m.appendChild(l),m}function U(m){var w,f;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let b=document.createElement("img");return b.className=r.smartPhotoImg,b.src=(w=m.src)!=null?w:"",b.alt=(f=m.alt)!=null?f:"",b.addEventListener("dragstart",I=>I.preventDefault(),{signal:o}),l.appendChild(b),{imgWrap:l,img:b}}function oe(m,l){var b;c.list.replaceChildren(),(b=c.navList)==null||b.replaceChildren(),c.slides=new Map,m.forEach(w=>{var W,j;let f=document.createElement("li");f.setAttribute("role","group"),f.setAttribute("aria-roledescription","slide"),f.setAttribute("aria-label",`${w.index+1} of ${m.length}`);let I={li:f,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(w.processed){let{imgWrap:B,img:G}=U(w);f.appendChild(B),I.imgWrap=B,I.img=G}else{let B=$();f.appendChild(B),I.loaderWrap=B}if(c.list.appendChild(f),c.slides.set(w,I),c.navList){let B=document.createElement("li"),G=Ee();G.style.backgroundImage=`url("${Qe((W=w.thumb)!=null?W:"")}")`;let a=w.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(ie(`go to ${(j=w.caption)!=null?j:""}`)),B.appendChild(G),c.navList.appendChild(B),I.navLink=G}}),J(l)}function re(m,l){var f;if(l.imgWrap||!m.processed)return l;let{imgWrap:b,img:w}=U(m);return(f=l.loaderWrap)==null||f.replaceWith(b),l.loaderWrap=null,l.imgWrap=b,l.img=w,l}function V(m){m&&document.activeElement&&m.contains(document.activeElement)&&c.caption.focus()}function J(m){let{viewer:l}=m;c.count.textContent=`${l.currentIndex+1}/${l.total}`,c.slides.forEach((b,w)=>{var W;let f=re(w,b),I=w.index===l.currentIndex;f.li.style.transform=`translate(${w.translateX}px,${w.translateY}px)`,f.li.classList.toggle("current",I),I?f.li.removeAttribute("aria-hidden"):f.li.setAttribute("aria-hidden","true"),I&&(c.caption.textContent=(W=w.caption)!=null?W:""),f.imgWrap&&f.img&&(f.imgWrap.style.transform=`translate(${w.x}px,${w.y}px) scale(${w.scale})`,f.img.style.width=`${w.width}px`,f.img.classList.toggle("active",l.appear),f.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),f.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),f.navLink&&(f.navLink.classList.toggle("current",I),I?f.navLink.setAttribute("aria-current","true"):f.navLink.removeAttribute("aria-current"))}),c.arrowLeft&&(l.showPrevArrow?c.arrowLeft.removeAttribute("aria-hidden"):(V(c.arrowLeft),c.arrowLeft.setAttribute("aria-hidden","true"))),c.arrowRight&&(l.showNextArrow?c.arrowRight.removeAttribute("aria-hidden"):(V(c.arrowRight),c.arrowRight.setAttribute("aria-hidden","true"))),c.arrows&&(l.hideUi&&V(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.nav&&(l.hideUi&&V(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ne(m){for(let[l,b]of c.slides)if(l.index===m.viewer.currentIndex)return b;return null}function se(m){let{viewer:l}=m,b=ne(m),w=b==null?void 0:b.img;w&&(w.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,w.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),c.nav&&(l.hideUi&&V(c.nav),c.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),c.arrows&&(l.hideUi&&V(c.arrows),c.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ae(m){let{viewer:l}=m;c.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,c.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function le(m){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=m.img,l.style.width=`${m.width}px`,l.style.height=`${m.height}px`,l.style.transform=`translate(${m.left}px,${m.top}px) scale(1)`,p.appendChild(l),c.imgClone=l}function he(){var m;(m=c.imgClone)==null||m.remove(),c.imgClone=null}function ue(){n.remove()}return{root:n,refs:c,render:J,syncSlides:oe,updatePhotoTransform:se,updateListTransform:ae,showAppearEffect:le,removeAppearEffect:he,destroy:ue}}var M=Z,k=ee;function _e(t){return t.length>0&&t[0]instanceof Element}function Je(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function ke(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var _=class{constructor(e,i){this.id=Je();this.abortController=new AbortController;this.isSmartPhoneFlag=K();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=q(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${k()}px`)};this.handleVisualViewportResize=()=>{this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!A(this.state))&&(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit())};this.handleResize=()=>{A(this.state)&&(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit())};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!A(this.state))return;this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=M(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==M()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=He(i!=null?i:{}),this.view=Ge({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Ye({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),this.applyAutoIconContrast(),window.visualViewport?window.visualViewport.addEventListener("resize",this.handleVisualViewportResize,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,r=s=>i.call(o,s);o.addEventListener(e,r,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){this.state.viewer.currentIndex=Number.parseInt(String(e),10),this.state.viewer.currentIndex||(this.state.viewer.currentIndex=0),this.slideList()}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=ke();location.hash&&this.setHash(""),window.scroll(i.x,i.y),this.syncDialog(),(o=this.lastTriggerElement)!=null&&o.isConnected&&this.lastTriggerElement.focus(),this.lastTriggerElement=null,this.doHideEffect(e).then(()=>{this.view.render(this.state),this.isFiringPublicCloseEvent=!0,this.fireEvent("close"),this.isFiringPublicCloseEvent=!1})}zoomPhoto(){let e=z(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(e,M(),k(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin")},300)))}zoomOutPhoto(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,d,v;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let r=this.state.groups.get(o);if(!(r!=null&&r.length))return;let s=typeof e=="number"?r[e]:r.find(y=>y.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,u=(v=(d=i.trigger)!=null?d:s.element)!=null?v:n;this.openPhoto(s,u)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!_e(e)){e.forEach(o=>{this.addSlideItem(o)});return}Array.from(typeof e=="string"?document.querySelectorAll(e):e).forEach(o=>{this.addElementItem(o)})}addElementItem(e){var s,n;let i=q(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=pe(e,this.state.options,o,M());return fe(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=me(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ze(e,o,M());return fe(this.state,r),this.loadAllFired.delete(i),r}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(d=>q(d)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(d=>{d.element&&s.set(d.element,d)});let n=i.length!==r.length,u=i.map((d,v)=>{let y=s.get(d);if(y)return y.index!==v&&(n=!0,y.index=v),y;n=!0;let P=pe(d,this.state.options,v,M());return this.itemsByElement.set(d,P),P});return r.forEach(d=>{d.element&&!o.has(d.element)&&this.itemsByElement.delete(d.element)}),we(u,M()),this.state.groups.set(e,u),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=A(this.state);e&&(this.view.syncSlides(e,this.state),this.syncedGroupId=this.state.viewer.currentGroup)}setHash(e){var o;if(!((o=window.history)!=null&&o.pushState)||!this.state.options.useHistoryApi)return;let i=`${location.pathname}${location.search}`;window.history.replaceState(null,"",e?`${i}#${e}`:i)}setHashByCurrentIndex(){let e=ke();this.setHash(Ne(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Ve(this.state,Ce(e)):null}setPosByCurrentIndex(){let e=z(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=A(this.state);e&&De(e,M(),k(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){we(A(this.state),M())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(){this.view.render(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=A(this.state);if(this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),ve(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=z(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(o,M(),k(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,u;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{o&&(o.style.viewTransitionName="");let p=this.currentImgElement();p&&(p.style.viewTransitionName="")},s=(u=document.startViewTransition)==null?void 0:u.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i});s==null||s.ready.catch(()=>{r()}),s==null||s.finished.then(r,r)}addAppearEffect(e,i){var O;let o=(O=e==null?void 0:e.querySelector("img"))!=null?O:null;if(!o){this.state.viewer.appear=!0;return}let r=Te(o),s=o.offsetWidth,n=o.offsetHeight,u=M(),p=k(),d=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=u/s:(s>=n?i.height<d?v=i.width/s:v=d/n:i.height<d?v=i.height/n:v=d/n,s*v>u&&(v=u/s));let y=(v-1)/2*s+(u-s*v)/2,P=(v-1)/2*n+(p-n*v)/2,S=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:S||i.src||"",afterX:y,afterY:P,scale:v}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let r=()=>{i.removeEventListener("transitionend",r,!0),o()};i.addEventListener("transitionend",r,!0),this.scheduleTimeout(()=>{i.style.transform=`translate(${e.afterX}px, ${e.afterY}px) scale(${e.scale})`},10)})}doOpen(e,i){if(this.state.options.showAnimation!==!1&&this.supportsViewTransition())this.openPhotoWithViewTransition(e);else if(this.state.options.showAnimation===!1)this.initPhoto(),this.state.viewer.appear=!0,this.commit();else{this.initPhoto(),this.addAppearEffect(e,i),this.commit();let o=this.state.viewer.appearEffect;o&&this.runAppearEffect(o).then(()=>{this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.appear=!0,this.commit()})}this.fireEvent("open"),this.resyncSizeAfterOpen()}resyncSizeAfterOpen(){let e=M(),i=k();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(M()===e&&k()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{let o=this.view.refs.dialog,r=this.currentImgElement(),s=k(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,u=()=>{this.finishHideEffect===u&&(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=u,r&&(r.style.transform=n),o.addEventListener("transitionend",u,!0),this.scheduleTimeout(u,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=A(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=z(this.state);this.state.viewer.onMove=!1,ve(this.state),this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}applyAutoIconContrast(){let e=this.view.refs.dialog,i=getComputedStyle(e);if(i.getPropertyValue("--smartphoto-icon-color").trim())return;let o=i.getPropertyValue("--smartphoto-backdrop-color").trim();o&&e.style.setProperty("--smartphoto-icon-color",Ae(o))}fireEvent(e){Le(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:()=>this.zoomPhoto(),onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},onPhotoDragMove:()=>this.view.updatePhotoTransform(this.state),onPhotoDragEnd:e=>{if(e==="zoom-out"){this.zoomOutPhoto();return}if(e==="prev"){this.gotoSlide(this.state.viewer.prev);return}if(e==="next"){this.gotoSlide(this.state.viewer.next);return}this.view.updatePhotoTransform(this.state)}}}};var We=_;var ye=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new We(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],ye);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&ye(e)}var ht=ye;})();
|
|
6
|
+
"use strict";(()=>{var Z=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0},Ie=()=>typeof window.webkitConvertPointFromNodeToPage=="function";function Le(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let r=e[o];if(r){for(let s in r)if(Object.hasOwn(r,s)){let n=r[s];n&&typeof n=="object"?t[s]=Le((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var Te=Le,Ce=(t,e,i)=>{let o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,i)),t.dispatchEvent(o)},Ae=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},ee=()=>document.documentElement.clientWidth,te=()=>{let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight},He=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var xe=t=>{let e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*[\d.]+\s*)?\)/);return e?[Number(e[1]),Number(e[2]),Number(e[3])]:null},Ue=.179,je=([t,e,i])=>{let[o,r,s]=[t,e,i].map(n=>{let c=n/255;return c<=.03928?c/12.92:((c+.055)/1.055)**2.4});return .2126*o+.7152*r+.0722*s},Me=t=>{let e=t.trim(),i=xe(e);if(!i){let o=document.createElement("div");if(o.style.color=e,!o.style.color)return"#fff";document.body.appendChild(o),i=xe(getComputedStyle(o).color),document.body.removeChild(o)}return i&&je(i)>Ue?"#000":"#fff"};var qe={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,useViewTransitionApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:450};function ze(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&ze(i)}),Object.freeze(t)}function Ve(t){return{options:ze(Te({},qe,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function Q(t){return t.getAttribute("data-group")||"nogroup"}function pe(t){return t.group||"nogroup"}function fe(t,e,i,o){let r=Q(t),s=t.getAttribute("href"),n=t.querySelector("img"),c=s;n&&(n.getAttribute(e.lazyAttribute)?c=n.getAttribute(e.lazyAttribute):n.currentSrc?c=n.currentSrc:c=n.src);let p="";n!=null&&n.getAttribute("alt")?p=n.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let u=t.getAttribute("data-id");return{src:s,thumb:c,caption:t.getAttribute("data-caption"),alt:p,groupId:r,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:u||i,loaded:!1,processed:!1,element:t}}function Oe(t,e,i){var u,f,b,P,H;let o=pe(t),r=t.src,s=(u=t.thumb)!=null?u:r,n=(f=t.caption)!=null?f:null,c=(P=(b=t.alt)!=null?b:n)!=null?P:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:c,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(H=t.id)!=null?H:e,loaded:p,processed:!1,element:null}}function ve(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function T(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function C(t){var i;let e=T(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function we(t){let e=T(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,r=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),r!==-1&&(t.viewer.prev=r,t.viewer.showPrevArrow=!0)}function ge(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function ie(t,e){let i=10**e;return Math.round(t*i)/i}function U(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Be(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,c,p,u;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(u=(o-s)/2,c=-1*u):(u=(s-o)/2,c=-1*u),{minX:ie(n,6)*e.scaleSize,minY:ie(c,6)*e.scaleSize,maxX:ie(p,6)*e.scaleSize,maxY:ie(u,6)*e.scaleSize}}function De(t,e,i,o,r){let s=i-(o+r);t.forEach(n=>{n.loaded&&(n.processed=!0,n.scale=s/n.height,n.height<s&&(n.scale=1),n.x=(n.scale-1)/2*n.width+(e-n.width*n.scale)/2,n.y=(n.scale-1)/2*n.height+(i-n.height*n.scale)/2,n.width*n.scale>e&&(n.scale=e/n.width,n.x=(n.scale-1)/2*n.width))})}function Ne(t){let e=C(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function Re(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function ye(t,e){let i=10**e;return Math.round(t*i)/i}function j(t){return{x:t.pageX,y:t.pageY}}function Xe(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var Qe=10;function _e(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Ye(){return{width:ee(),height:te()}}function Fe({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,c=null,p=null,u=null,f=0,b=null,P=!1,H=null,L=null,V=0,F=0,z=!1,R=0,x=null,O=0,d=0;function J(){return Z()}function $(l){let{width:h,height:y}=Ye();return Be(l,t.viewer,h,y)}function K(l){let{width:h,height:y}=Ye();return U(l,h,y,J())}function re(l,h){let y=C(t),g=$(y);t.viewer.elastic=!0,l===1?t.viewer.photoPosX=g.minX:l===-1&&(t.viewer.photoPosX=g.maxX),h===1?t.viewer.photoPosY=g.minY:h===-1&&(t.viewer.photoPosY=g.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let k=setInterval(()=>{if(z||s||P||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=O,t.viewer.photoPosY+=d;let l=C(t);if(!l)return;let h=$(l);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,O*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,O*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,d*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,d*=-.2);let y=_e(O,d),g=y.force-t.options.registance;Math.abs(g)<.5||(O=Math.cos(y.theta)*g,d=Math.sin(y.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function G(l,h){(l>5||l<-5)&&(O+=l*.05),t.options.verticalGravity&&(h>5||h<-5)&&(d+=h*.05)}function ne(l){if(!(l!=null&&l.gamma)||t.viewer.appearEffect||z||s||P||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?G(l.gamma,l.beta):h===90?G(l.beta,l.gamma):h===-90?G(-l.beta,-l.gamma):h===180&&G(-l.gamma,-l.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",ne,{signal:i});function se(){z=!0,s=!1,P=!1;let l=Array.from(o.values());R=Xe(l[0],l[1]),t.viewer.scale=!0,e.onGestureStart()}function ae(l){let h=j(l);s=!0,n=!0,c=h,p=h,f=Date.now(),b=l.target}function le(l){P=!0;let h=j(l);L=h,H=h}function he(l){var h,y;try{(y=(h=l.currentTarget).setPointerCapture)==null||y.call(h,l.pointerId)}catch(g){}if(o.set(l.pointerId,j(l)),o.size>1){se();return}if(t.viewer.scale){le(l);return}ae(l)}function ue(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function ce(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function m(){let l=Array.from(o.values()),h=Xe(l[0],l[1]),y=(h-R)/100,g=t.viewer.scaleSize,I=t.viewer.photoPosX,M=t.viewer.photoPosY;t.viewer.scaleSize+=ye(y,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<g&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-g)*I,t.viewer.photoPosY=(1+t.viewer.scaleSize-g)*M);let N=C(t);if(N){let de=K(N);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>de}R=h,ue()}function a(l){let h=j(l),y=h.x-p.x,g=h.y-c.y;n&&(e.onSwipeStart(),n=!1,u=Math.abs(y)>Math.abs(g)?"horizontal":"vertical"),u==="horizontal"?t.viewer.translateX+=y:t.viewer.translateY=g,p=h,e.onSwipeMove()}function E(l){let h=j(l),y=h.x-L.x,g=h.y-L.y,I=ye(t.viewer.scaleSize*y,6),M=ye(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=I,V=I,t.viewer.photoPosY+=M,F=M,L=h,e.onPhotoDragMove()}function w(l){if(o.has(l.pointerId)){if(o.set(l.pointerId,j(l)),z){m();return}if(P){E(l);return}a(l)}}function v(){z=!1,ce();let l=C(t);if(!l)return;let h=K(l);t.viewer.scaleSize>h||(t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scale=!1,t.viewer.scaleSize=1,t.viewer.hideUi=!1,e.onGestureEnd())}function S(){var be;s=!1;let l=c,h=p,y=Date.now(),g=r-y,I=h.x-l.x,M=h.y-l.y,N=I===0&&M===0;if(!J()&&N){e.onTap(b);return}if(Math.abs(g)<=500&&N){e.onTap(b);return}r=y;let de=(be=T(t))!=null?be:[];if(u==="horizontal"){let W="stay",$e=Math.max(y-f,1),Se=Math.abs(I)>=Qe&&Math.abs(I)/$e>=t.options.swipeVelocity;(I>=t.options.swipeOffset||Se&&I>0)&&t.viewer.currentIndex!==0?W="prev":(I<=-t.options.swipeOffset||Se&&I<0)&&t.viewer.currentIndex!==de.length-1&&(W="next"),e.onSwipeEnd(W)}else{let W="stay";t.options.swipeBottomToClose&&M>=t.options.swipeOffset?W="close-bottom":t.options.swipeTopToClose&&M<=-t.options.swipeOffset&&(W="close-top"),e.onSwipeEnd(W)}}function B(){P=!1;let l=L,h=H;if(l.x===h.x){e.onPhotoDragEnd("zoom-out");return}let y=C(t);if(!y){e.onPhotoDragEnd(null);return}let g=$(y),I=t.options.swipeOffset*t.viewer.scaleSize,M=0,N=0;if(t.viewer.photoPosX>g.maxX?M=-1:t.viewer.photoPosX<g.minX&&(M=1),t.viewer.photoPosY>g.maxY?N=-1:t.viewer.photoPosY<g.minY&&(N=1),t.viewer.photoPosX-g.maxX>I&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>I&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}M===0&&N===0?(O=V/5,d=F/5):re(M,N),e.onPhotoDragEnd(null)}function q(l){if(o.delete(l.pointerId),z){o.size<2&&v();return}if(P){B();return}s&&S()}function D(...l){for(let h of l)h.addEventListener("pointerdown",he,{signal:i}),h.addEventListener("pointermove",w,{signal:i}),h.addEventListener("pointerup",q,{signal:i}),h.addEventListener("pointercancel",q,{signal:i})}function X(){clearInterval(k),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:D,detach:X}}function oe(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function Ee(){let t=document.createElement("button");return t.type="button",t}function Je(t){return t.replace(/"/g,'\\"')}function ke({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let c=document.createElement("dialog");c.className=r.smartPhoto,c.setAttribute("aria-labelledby",`smartphoto-${t}-title`),c.style.display="none",c.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let u=document.createElement("div");u.className=r.smartPhotoInner;let f=document.createElement("div");f.className=r.smartPhotoHeader;let b=document.createElement("span");b.className=r.smartPhotoCount;let P=document.createElement("h1");P.id=`smartphoto-${t}-title`,P.className=r.smartPhotoCaption,P.setAttribute("tabindex","-1");let H=document.createElement("button");H.className=r.smartPhotoDismiss,H.appendChild(oe(s.closeDialog)),H.addEventListener("click",()=>i.onDismiss(),{signal:o}),f.append(b,P,H);let L=document.createElement("div");L.className=r.smartPhotoContent,L.addEventListener("click",m=>{m.target===L&&i.onBackdropClick()},{signal:o});let V=document.createElement("ul");V.className=r.smartPhotoList,V.setAttribute("role","region"),V.setAttribute("aria-roledescription","carousel"),V.setAttribute("aria-label",s.carouselLabel),V.setAttribute("aria-live","polite"),V.setAttribute("aria-atomic","false"),u.append(f,L,V);let F=null,z=null,R=null;if(e.arrows){F=document.createElement("ul"),F.className=r.smartPhotoArrows,z=document.createElement("li"),z.className=r.smartPhotoArrowLeft;let m=Ee();m.appendChild(oe(s.gotoPrevImage)),m.addEventListener("click",()=>i.onPrev(),{signal:o}),z.appendChild(m),R=document.createElement("li"),R.className=r.smartPhotoArrowRight;let a=Ee();a.appendChild(oe(s.gotoNextImage)),a.addEventListener("click",()=>i.onNext(),{signal:o}),R.appendChild(a),F.append(z,R),u.appendChild(F)}let x=null,O=null;e.nav&&(x=document.createElement("nav"),x.className=r.smartPhotoNav,x.setAttribute("aria-label","Choose slide to display"),O=document.createElement("ul"),x.appendChild(O),u.appendChild(x)),p.appendChild(u),c.appendChild(p),n.appendChild(c);let d={dialog:c,count:b,caption:P,dismiss:H,content:L,list:V,arrows:F,arrowLeft:z,arrowRight:R,nav:x,navList:O,slides:new Map,imgClone:null};function J(){let m=document.createElement("div");m.className=r.smartPhotoLoaderWrap;let a=document.createElement("span");return a.className=r.smartPhotoLoader,m.appendChild(a),m}function $(m){var w,v;let a=document.createElement("div");a.className=r.smartPhotoImgWrap;let E=document.createElement("img");return E.className=r.smartPhotoImg,E.src=(w=m.src)!=null?w:"",E.alt=(v=m.alt)!=null?v:"",E.addEventListener("dragstart",S=>S.preventDefault(),{signal:o}),a.appendChild(E),{imgWrap:a,img:E}}function K(m,a){var E;d.list.replaceChildren(),(E=d.navList)==null||E.replaceChildren(),d.slides=new Map,m.forEach(w=>{var B,q;let v=document.createElement("li");v.setAttribute("role","group"),v.setAttribute("aria-roledescription","slide"),v.setAttribute("aria-label",`${w.index+1} of ${m.length}`);let S={li:v,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(w.processed){let{imgWrap:D,img:X}=$(w);v.appendChild(D),S.imgWrap=D,S.img=X}else{let D=J();v.appendChild(D),S.loaderWrap=D}if(d.list.appendChild(v),d.slides.set(w,S),d.navList){let D=document.createElement("li"),X=Ee();X.style.backgroundImage=`url("${Je((B=w.thumb)!=null?B:"")}")`;let l=w.index;X.addEventListener("click",()=>i.onNavigate(l),{signal:o}),X.appendChild(oe(`go to ${(q=w.caption)!=null?q:""}`)),D.appendChild(X),d.navList.appendChild(D),S.navLink=X}}),G(a)}function re(m,a){var v;if(a.imgWrap||!m.processed)return a;let{imgWrap:E,img:w}=$(m);return(v=a.loaderWrap)==null||v.replaceWith(E),a.loaderWrap=null,a.imgWrap=E,a.img=w,a}function k(m){m&&document.activeElement&&m.contains(document.activeElement)&&d.caption.focus()}function G(m){let{viewer:a}=m;d.count.textContent=`${a.currentIndex+1}/${a.total}`,d.slides.forEach((E,w)=>{var B;let v=re(w,E),S=w.index===a.currentIndex;v.li.style.transform=`translate(${w.translateX}px,${w.translateY}px)`,v.li.classList.toggle("current",S),S?v.li.removeAttribute("aria-hidden"):v.li.setAttribute("aria-hidden","true"),S&&(d.caption.textContent=(B=w.caption)!=null?B:""),v.imgWrap&&v.img&&(v.imgWrap.style.transform=`translate(${w.x}px,${w.y}px) scale(${w.scale})`,v.img.style.width=`${w.width}px`,S||(v.img.style.transform="translate(0px,0px) scale(1)"),v.img.classList.toggle("active",a.appear),v.img.classList.toggle(r.smartPhotoImgOnMove,a.scale),v.img.classList.toggle(r.smartPhotoImgElasticMove,a.elastic)),v.navLink&&(v.navLink.classList.toggle("current",S),S?v.navLink.setAttribute("aria-current","true"):v.navLink.removeAttribute("aria-current"))}),d.arrowLeft&&(a.showPrevArrow?d.arrowLeft.removeAttribute("aria-hidden"):(k(d.arrowLeft),d.arrowLeft.setAttribute("aria-hidden","true"))),d.arrowRight&&(a.showNextArrow?d.arrowRight.removeAttribute("aria-hidden"):(k(d.arrowRight),d.arrowRight.setAttribute("aria-hidden","true"))),d.arrows&&(a.hideUi&&k(d.arrows),d.arrows.setAttribute("aria-hidden",a.hideUi?"true":"false")),d.nav&&(a.hideUi&&k(d.nav),d.nav.setAttribute("aria-hidden",a.hideUi?"true":"false"))}function ne(m){for(let[a,E]of d.slides)if(a.index===m.viewer.currentIndex)return E;return null}function se(m){let{viewer:a}=m,E=ne(m),w=E==null?void 0:E.img;w&&(w.style.transform=`translate(${a.photoPosX}px,${a.photoPosY}px) scale(${a.scaleSize})`,w.classList.toggle(r.smartPhotoImgOnMove,a.scale),w.classList.toggle(r.smartPhotoImgElasticMove,a.elastic)),d.nav&&(a.hideUi&&k(d.nav),d.nav.setAttribute("aria-hidden",a.hideUi?"true":"false")),d.arrows&&(a.hideUi&&k(d.arrows),d.arrows.setAttribute("aria-hidden",a.hideUi?"true":"false"))}function ae(m){let{viewer:a}=m;d.list.style.transform=`translate(${a.translateX}px,${a.translateY}px)`,d.list.classList.toggle(r.smartPhotoListOnMove,a.onMove)}function le(m){for(let[a,E]of d.slides){if(a.index!==m.viewer.currentIndex)continue;let{img:w,imgWrap:v}=E;if(!w||!v||!a.width||!a.scale||a.scale>=1)return;let S=w.getBoundingClientRect();w.style.width=`${a.width*a.scale}px`,v.style.transform=`translate(${a.x}px,${a.y}px) scale(1)`;let B=w.getBoundingClientRect();v.style.transform=`translate(${a.x+S.left-B.left}px,${a.y+S.top-B.top}px) scale(1)`;return}}function he(m){let a=document.createElement("img");a.className=r.smartPhotoImgClone,a.src=m.img,a.style.width=`${m.width}px`,a.style.height=`${m.height}px`,a.style.transform=`translate(${m.left}px,${m.top}px) scale(1)`,p.appendChild(a),d.imgClone=a}function ue(){var m;(m=d.imgClone)==null||m.remove(),d.imgClone=null}function ce(){n.remove()}return{root:n,refs:d,render:G,syncSlides:K,updatePhotoTransform:se,applyViewTransitionLayout:le,updateListTransform:ae,showAppearEffect:he,removeAppearEffect:ue,destroy:ce}}var A=ee,Y=te;function Ke(t){return t.length>0&&t[0]instanceof Element}function Ze(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function Ge(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var _=class{constructor(e,i){this.id=Ze();this.abortController=new AbortController;this.isSmartPhoneFlag=Z();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.isViewTransitionActive=!1;this.pendingViewTransitionResync=!1;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=Q(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${Y()}px`)};this.handleVisualViewportResize=()=>{if(this.updateViewportHeight(),!(!this.isSmartPhoneFlag||!this.state.viewer.isOpen||!T(this.state))){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleResize=()=>{if(!(!this.state.viewer.isOpen||!T(this.state))){if(this.updateViewportHeight(),this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!this.state.viewer.isOpen||!T(this.state))return;if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=A(),i=500,o=r=>{this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(e!==A()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25))},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=Ve(i!=null?i:{}),this.view=ke({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Fe({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),this.applyAutoIconContrast(),window.visualViewport?window.visualViewport.addEventListener("resize",this.handleVisualViewportResize,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,r=s=>i.call(o,s);o.addEventListener(e,r,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){this.state.viewer.currentIndex=Number.parseInt(String(e),10),this.state.viewer.currentIndex||(this.state.viewer.currentIndex=0),this.slideList()}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=Ge();location.hash&&this.setHash(""),window.scroll(i.x,i.y),this.syncDialog(),(o=this.lastTriggerElement)!=null&&o.isConnected&&this.lastTriggerElement.focus(),this.lastTriggerElement=null,this.doHideEffect(e).then(()=>{this.view.render(this.state),this.isFiringPublicCloseEvent=!0,this.fireEvent("close"),this.isFiringPublicCloseEvent=!1})}zoomPhoto(){let e=C(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=U(e,A(),Y(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.isOpen&&(this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin"))},this.state.options.animationSpeed)))}canZoomCurrentPhoto(){let e=C(this.state);return!!e&&U(e,A(),Y(),this.isSmartPhoneFlag)>1}zoomOutPhoto(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,u,f;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let r=this.state.groups.get(o);if(!(r!=null&&r.length))return;let s=typeof e=="number"?r[e]:r.find(b=>b.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,c=(f=(u=i.trigger)!=null?u:s.element)!=null?f:n;this.openPhoto(s,c)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!Ke(e)){e.forEach(o=>{this.addSlideItem(o)});return}Array.from(typeof e=="string"?document.querySelectorAll(e):e).forEach(o=>{this.addElementItem(o)})}addElementItem(e){var s,n;let i=Q(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=fe(e,this.state.options,o,A());return ve(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=pe(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Oe(e,o,A());return ve(this.state,r),this.loadAllFired.delete(i),r}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(u=>Q(u)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(u=>{u.element&&s.set(u.element,u)});let n=i.length!==r.length,c=i.map((u,f)=>{let b=s.get(u);if(b)return b.index!==f&&(n=!0,b.index=f),b;n=!0;let P=fe(u,this.state.options,f,A());return this.itemsByElement.set(u,P),P});return r.forEach(u=>{u.element&&!o.has(u.element)&&this.itemsByElement.delete(u.element)}),ge(c,A()),this.state.groups.set(e,c),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=T(this.state);e&&(this.view.syncSlides(e,this.state),this.syncedGroupId=this.state.viewer.currentGroup)}setHash(e){var o;if(!((o=window.history)!=null&&o.pushState)||!this.state.options.useHistoryApi)return;let i=`${location.pathname}${location.search}`;window.history.replaceState(null,"",e?`${i}#${e}`:i)}setHashByCurrentIndex(){let e=Ge();this.setHash(Ne(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?Re(this.state,Ae(e)):null}setPosByCurrentIndex(){let e=C(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=T(this.state);e&&(De(e,A(),Y(),this.state.options.headerHeight,this.state.options.footerHeight),this.syncFillScale())}resetTranslateCurrent(){ge(T(this.state),A())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}currentLiElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.li;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;e.style.transition=this.state.options.showAnimation===!1?"none":"",this.state.viewer.isOpen&&!e.open?(e.style.removeProperty("display"),e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&(e.close(),e.style.display="none")}commit(){this.view.render(this.state),this.view.updatePhotoTransform(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.updateViewportHeight(),this.view.refs.dialog.style.opacity="";let e=T(this.state);this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),we(this.state)}syncFillScale(){if(this.state.options.resizeStyle!=="fill"||!this.isSmartPhoneFlag)return;let e=C(this.state);e&&(this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=U(e,A(),Y(),this.isSmartPhoneFlag))}supportsViewTransition(){return this.state.options.useViewTransitionApi&&typeof document.startViewTransition=="function"&&!Ie()}openPhotoWithViewTransition(e){var n,c;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{this.isViewTransitionActive=!1,o&&(o.style.viewTransitionName="");let p=this.currentImgElement();if(p&&(p.style.viewTransitionName=""),!this.state.viewer.isOpen){this.pendingViewTransitionResync=!1;return}if(this.pendingViewTransitionResync&&T(this.state)){this.pendingViewTransitionResync=!1,this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit();return}this.pendingViewTransitionResync=!1,this.view.render(this.state)},s=(c=document.startViewTransition)==null?void 0:c.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i,this.view.applyViewTransitionLayout(this.state)});s&&(this.isViewTransitionActive=!0,s.ready.catch(()=>{r()}),s.finished.then(r,r))}addAppearEffect(e,i){var L;let o=(L=e==null?void 0:e.querySelector("img"))!=null?L:null;if(!o){this.state.viewer.appear=!0;return}let r=He(o),s=o.offsetWidth,n=o.offsetHeight,c=A(),p=Y(),u=p-this.state.options.headerHeight-this.state.options.footerHeight,f=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?f=p/n:f=c/s:(s>=n?i.height<u?f=i.width/s:f=u/n:i.height<u?f=i.height/n:f=u/n,s*f>c&&(f=c/s));let b=(f-1)/2*s+(c-s*f)/2,P=(f-1)/2*n+(p-n*f)/2,H=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:H||i.src||"",afterX:b,afterY:P,scale:f}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let r=()=>{i.removeEventListener("transitionend",r,!0),o()};i.addEventListener("transitionend",r,!0),this.scheduleTimeout(()=>{i.style.transform=`translate(${e.afterX}px, ${e.afterY}px) scale(${e.scale})`},10)})}doOpen(e,i){if(this.state.options.showAnimation!==!1&&this.supportsViewTransition())this.openPhotoWithViewTransition(e);else if(this.state.options.showAnimation===!1)this.initPhoto(),this.state.viewer.appear=!0,this.commit();else{this.initPhoto(),this.addAppearEffect(e,i),this.commit();let o=this.state.viewer.appearEffect;o&&this.runAppearEffect(o).then(()=>{this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.appear=!0,this.commit()})}this.fireEvent("open"),this.resyncSizeAfterOpen()}resyncSizeAfterOpen(){let e=A(),i=Y();requestAnimationFrame(()=>{if(this.state.viewer.isOpen&&!(A()===e&&Y()===i)){if(this.isViewTransitionActive){this.pendingViewTransitionResync=!0;return}this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit()}})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{if(this.state.options.showAnimation===!1){i();return}let o=this.view.refs.dialog,r=C(this.state),s=r?this.currentLiElement():null,n=Y(),c=this.currentImgElement(),p=null;if(c){let f=getComputedStyle(c).transform;f&&f!=="none"&&(c.style.transform=f,p=c.style.transform)}if(s&&r){let f=e==="top"?-n:n;s.style.transform=`translate(${r.translateX}px,${r.translateY+f}px)`}let u=f=>{this.finishHideEffect===u&&(f&&f.target!==o||(this.finishHideEffect=null,o.removeEventListener("transitionend",u,!0),c&&p&&c.style.transform===p&&(c.style.transform=""),i()))};this.finishHideEffect=u,o.addEventListener("transitionend",u,!0),this.scheduleTimeout(u,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=T(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=C(this.state);this.state.viewer.onMove=!1,we(this.state),this.state.viewer.isOpen&&this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.state.viewer.isOpen&&(this.initPhoto(),this.commit())})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}applyAutoIconContrast(){let e=this.view.refs.dialog,i=getComputedStyle(e);if(i.getPropertyValue("--smartphoto-icon-color").trim())return;let o=i.getPropertyValue("--smartphoto-backdrop-color").trim();o&&e.style.setProperty("--smartphoto-icon-color",Me(o))}fireEvent(e){Ce(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:e=>{let i=this.currentImgElement();!!i&&e instanceof Node&&i.contains(e)&&this.canZoomCurrentPhoto()?this.zoomPhoto():this.hidePhoto()},onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},onPhotoDragMove:()=>this.view.updatePhotoTransform(this.state),onPhotoDragEnd:e=>{if(e==="zoom-out"){this.zoomOutPhoto();return}if(e==="prev"){this.gotoSlide(this.state.viewer.prev);return}if(e==="next"){this.gotoSlide(this.state.viewer.next);return}this.view.updatePhotoTransform(this.state)}}}};var We=_;var Pe=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new We(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],Pe);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&Pe(e)}var ct=Pe;})();
|
package/js/smartphoto.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SmartPhoto v2.1.
|
|
2
|
+
* SmartPhoto v2.1.13
|
|
3
3
|
* (c) appleple
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -34,6 +34,9 @@ var SmartPhoto = (() => {
|
|
|
34
34
|
const agent = navigator.userAgent;
|
|
35
35
|
return agent.indexOf("iPhone") > 0 || agent.indexOf("iPad") > 0 || agent.indexOf("ipod") > 0 || agent.indexOf("Android") > 0;
|
|
36
36
|
};
|
|
37
|
+
var isWebKit = () => {
|
|
38
|
+
return typeof window.webkitConvertPointFromNodeToPage === "function";
|
|
39
|
+
};
|
|
37
40
|
function deepExtend(out, ...args) {
|
|
38
41
|
var _a;
|
|
39
42
|
out = out || {};
|
|
@@ -172,6 +175,7 @@ var SmartPhoto = (() => {
|
|
|
172
175
|
verticalGravity: false,
|
|
173
176
|
useOrientationApi: false,
|
|
174
177
|
useHistoryApi: true,
|
|
178
|
+
useViewTransitionApi: true,
|
|
175
179
|
swipeTopToClose: false,
|
|
176
180
|
swipeBottomToClose: true,
|
|
177
181
|
swipeOffset: 100,
|
|
@@ -459,6 +463,7 @@ var SmartPhoto = (() => {
|
|
|
459
463
|
let oldPos = null;
|
|
460
464
|
let moveDir = null;
|
|
461
465
|
let swipeStartTime = 0;
|
|
466
|
+
let tapTarget = null;
|
|
462
467
|
let photoSwipable = false;
|
|
463
468
|
let firstPhotoPos = null;
|
|
464
469
|
let oldPhotoPos = null;
|
|
@@ -589,6 +594,7 @@ var SmartPhoto = (() => {
|
|
|
589
594
|
firstPos = pos;
|
|
590
595
|
oldPos = pos;
|
|
591
596
|
swipeStartTime = Date.now();
|
|
597
|
+
tapTarget = e.target;
|
|
592
598
|
}
|
|
593
599
|
function startPhotoDrag(e) {
|
|
594
600
|
photoSwipable = true;
|
|
@@ -730,11 +736,11 @@ var SmartPhoto = (() => {
|
|
|
730
736
|
const swipeHeight = last.y - first.y;
|
|
731
737
|
const noMove = swipeWidth === 0 && swipeHeight === 0;
|
|
732
738
|
if (!isSmartPhone2() && noMove) {
|
|
733
|
-
callbacks.onTap();
|
|
739
|
+
callbacks.onTap(tapTarget);
|
|
734
740
|
return;
|
|
735
741
|
}
|
|
736
742
|
if (Math.abs(offset) <= 500 && noMove) {
|
|
737
|
-
callbacks.onTap();
|
|
743
|
+
callbacks.onTap(tapTarget);
|
|
738
744
|
return;
|
|
739
745
|
}
|
|
740
746
|
tapSecond = now;
|
|
@@ -1059,6 +1065,9 @@ var SmartPhoto = (() => {
|
|
|
1059
1065
|
if (slideRefs.imgWrap && slideRefs.img) {
|
|
1060
1066
|
slideRefs.imgWrap.style.transform = `translate(${item.x}px,${item.y}px) scale(${item.scale})`;
|
|
1061
1067
|
slideRefs.img.style.width = `${item.width}px`;
|
|
1068
|
+
if (!isCurrent) {
|
|
1069
|
+
slideRefs.img.style.transform = "translate(0px,0px) scale(1)";
|
|
1070
|
+
}
|
|
1062
1071
|
slideRefs.img.classList.toggle("active", viewer.appear);
|
|
1063
1072
|
slideRefs.img.classList.toggle(
|
|
1064
1073
|
classNames.smartPhotoImgOnMove,
|
|
@@ -1142,6 +1151,23 @@ var SmartPhoto = (() => {
|
|
|
1142
1151
|
refs.list.style.transform = `translate(${viewer.translateX}px,${viewer.translateY}px)`;
|
|
1143
1152
|
refs.list.classList.toggle(classNames.smartPhotoListOnMove, viewer.onMove);
|
|
1144
1153
|
}
|
|
1154
|
+
function applyViewTransitionLayout(state) {
|
|
1155
|
+
for (const [item, slideRefs] of refs.slides) {
|
|
1156
|
+
if (item.index !== state.viewer.currentIndex) {
|
|
1157
|
+
continue;
|
|
1158
|
+
}
|
|
1159
|
+
const { img, imgWrap } = slideRefs;
|
|
1160
|
+
if (!img || !imgWrap || !item.width || !item.scale || item.scale >= 1) {
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
const before = img.getBoundingClientRect();
|
|
1164
|
+
img.style.width = `${item.width * item.scale}px`;
|
|
1165
|
+
imgWrap.style.transform = `translate(${item.x}px,${item.y}px) scale(1)`;
|
|
1166
|
+
const after = img.getBoundingClientRect();
|
|
1167
|
+
imgWrap.style.transform = `translate(${item.x + before.left - after.left}px,${item.y + before.top - after.top}px) scale(1)`;
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1145
1171
|
function showAppearEffect(effect) {
|
|
1146
1172
|
const clone = document.createElement("img");
|
|
1147
1173
|
clone.className = classNames.smartPhotoImgClone;
|
|
@@ -1166,6 +1192,7 @@ var SmartPhoto = (() => {
|
|
|
1166
1192
|
render,
|
|
1167
1193
|
syncSlides,
|
|
1168
1194
|
updatePhotoTransform,
|
|
1195
|
+
applyViewTransitionLayout,
|
|
1169
1196
|
updateListTransform,
|
|
1170
1197
|
showAppearEffect,
|
|
1171
1198
|
removeAppearEffect,
|
|
@@ -1202,6 +1229,13 @@ var SmartPhoto = (() => {
|
|
|
1202
1229
|
// doHideEffect() の後始末(画像に設定した translateY の除去と promise 解決)を
|
|
1203
1230
|
// transitionend を待たずに即時実行するための関数。後始末が済むと null に戻る
|
|
1204
1231
|
this.finishHideEffect = null;
|
|
1232
|
+
// 開く View Transition が進行中かどうか。進行中にリサイズ由来の再計算(commit)が
|
|
1233
|
+
// 走ると、モーフの目標位置は古いビューポート基準のままなのに実要素だけ新しい
|
|
1234
|
+
// 位置へ動いて「一旦ずれた位置に出てから正位置へ戻る」ように見え、さらに
|
|
1235
|
+
// モーフ用レイアウト(applyViewTransitionLayout)も巻き戻されてしまう。
|
|
1236
|
+
// そのため進行中はリサイズ再計算を保留し、finished 後にまとめて実行する
|
|
1237
|
+
this.isViewTransitionActive = false;
|
|
1238
|
+
this.pendingViewTransitionResync = false;
|
|
1205
1239
|
this.timeouts = [];
|
|
1206
1240
|
this.loadAllFired = /* @__PURE__ */ new Set();
|
|
1207
1241
|
this.syncedGroupId = null;
|
|
@@ -1260,16 +1294,24 @@ var SmartPhoto = (() => {
|
|
|
1260
1294
|
if (!this.isSmartPhoneFlag || !this.state.viewer.isOpen || !currentItems(this.state)) {
|
|
1261
1295
|
return;
|
|
1262
1296
|
}
|
|
1297
|
+
if (this.isViewTransitionActive) {
|
|
1298
|
+
this.pendingViewTransitionResync = true;
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1263
1301
|
this.resetTranslateCurrent();
|
|
1264
1302
|
this.setPosByCurrentIndex();
|
|
1265
1303
|
this.setSizeByScreen();
|
|
1266
1304
|
this.commit();
|
|
1267
1305
|
};
|
|
1268
1306
|
this.handleResize = () => {
|
|
1269
|
-
if (!currentItems(this.state)) {
|
|
1307
|
+
if (!this.state.viewer.isOpen || !currentItems(this.state)) {
|
|
1270
1308
|
return;
|
|
1271
1309
|
}
|
|
1272
1310
|
this.updateViewportHeight();
|
|
1311
|
+
if (this.isViewTransitionActive) {
|
|
1312
|
+
this.pendingViewTransitionResync = true;
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1273
1315
|
this.resetTranslateCurrent();
|
|
1274
1316
|
this.setPosByCurrentIndex();
|
|
1275
1317
|
this.setSizeByScreen();
|
|
@@ -1289,7 +1331,11 @@ var SmartPhoto = (() => {
|
|
|
1289
1331
|
}
|
|
1290
1332
|
};
|
|
1291
1333
|
this.handleOrientationChange = () => {
|
|
1292
|
-
if (!currentItems(this.state)) {
|
|
1334
|
+
if (!this.state.viewer.isOpen || !currentItems(this.state)) {
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
1337
|
+
if (this.isViewTransitionActive) {
|
|
1338
|
+
this.pendingViewTransitionResync = true;
|
|
1293
1339
|
return;
|
|
1294
1340
|
}
|
|
1295
1341
|
this.updateViewportHeight();
|
|
@@ -1302,6 +1348,9 @@ var SmartPhoto = (() => {
|
|
|
1302
1348
|
const timeout = 500;
|
|
1303
1349
|
const poll = (time) => {
|
|
1304
1350
|
this.scheduleTimeout(() => {
|
|
1351
|
+
if (!this.state.viewer.isOpen) {
|
|
1352
|
+
return;
|
|
1353
|
+
}
|
|
1305
1354
|
if (prevWidth !== getWindowWidth2()) {
|
|
1306
1355
|
this.updateViewportHeight();
|
|
1307
1356
|
this.resetTranslateCurrent();
|
|
@@ -1454,10 +1503,26 @@ var SmartPhoto = (() => {
|
|
|
1454
1503
|
this.state.viewer.photoPosY = 0;
|
|
1455
1504
|
this.view.updatePhotoTransform(this.state);
|
|
1456
1505
|
this.scheduleTimeout(() => {
|
|
1506
|
+
if (!this.state.viewer.isOpen) {
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1457
1509
|
this.state.viewer.scale = true;
|
|
1458
1510
|
this.view.updatePhotoTransform(this.state);
|
|
1459
1511
|
this.fireEvent("zoomin");
|
|
1460
|
-
},
|
|
1512
|
+
}, this.state.options.animationSpeed);
|
|
1513
|
+
}
|
|
1514
|
+
// zoomPhoto() と同じ「ズームの余地があるか」の判定(scaleBorder <= 1 なら
|
|
1515
|
+
// ズームしても見た目が変わらない)。zoomPhoto() 自体は公開 API の契約
|
|
1516
|
+
// (ズームできなければ何もしない)を保つ必要があるため、タップの
|
|
1517
|
+
// zoom-or-close 分岐(§7)用に判定だけを切り出している
|
|
1518
|
+
canZoomCurrentPhoto() {
|
|
1519
|
+
const item = currentItem(this.state);
|
|
1520
|
+
return !!item && scaleBorder(
|
|
1521
|
+
item,
|
|
1522
|
+
getWindowWidth2(),
|
|
1523
|
+
getWindowHeight2(),
|
|
1524
|
+
this.isSmartPhoneFlag
|
|
1525
|
+
) > 1;
|
|
1461
1526
|
}
|
|
1462
1527
|
zoomOutPhoto() {
|
|
1463
1528
|
this.state.viewer.scaleSize = 1;
|
|
@@ -1668,6 +1733,7 @@ var SmartPhoto = (() => {
|
|
|
1668
1733
|
this.state.options.headerHeight,
|
|
1669
1734
|
this.state.options.footerHeight
|
|
1670
1735
|
);
|
|
1736
|
+
this.syncFillScale();
|
|
1671
1737
|
}
|
|
1672
1738
|
// resize/orientationchange ハンドラは呼び出し前に currentItems の存在を確認済み
|
|
1673
1739
|
resetTranslateCurrent() {
|
|
@@ -1681,9 +1747,18 @@ var SmartPhoto = (() => {
|
|
|
1681
1747
|
}
|
|
1682
1748
|
return null;
|
|
1683
1749
|
}
|
|
1750
|
+
currentLiElement() {
|
|
1751
|
+
for (const [item, slideRefs] of this.view.refs.slides) {
|
|
1752
|
+
if (item.index === this.state.viewer.currentIndex) {
|
|
1753
|
+
return slideRefs.li;
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
return null;
|
|
1757
|
+
}
|
|
1684
1758
|
// ---- 内部: dialog 制御(§8) ----
|
|
1685
1759
|
syncDialog() {
|
|
1686
1760
|
const { dialog, caption } = this.view.refs;
|
|
1761
|
+
dialog.style.transition = this.state.options.showAnimation === false ? "none" : "";
|
|
1687
1762
|
if (this.state.viewer.isOpen && !dialog.open) {
|
|
1688
1763
|
dialog.style.removeProperty("display");
|
|
1689
1764
|
dialog.showModal();
|
|
@@ -1695,6 +1770,7 @@ var SmartPhoto = (() => {
|
|
|
1695
1770
|
}
|
|
1696
1771
|
commit() {
|
|
1697
1772
|
this.view.render(this.state);
|
|
1773
|
+
this.view.updatePhotoTransform(this.state);
|
|
1698
1774
|
this.syncDialog();
|
|
1699
1775
|
}
|
|
1700
1776
|
// ---- 内部: 開く演出 ----
|
|
@@ -1713,20 +1789,34 @@ var SmartPhoto = (() => {
|
|
|
1713
1789
|
this.setPosByCurrentIndex();
|
|
1714
1790
|
this.setSizeByScreen();
|
|
1715
1791
|
setArrow(this.state);
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1792
|
+
}
|
|
1793
|
+
// resizeStyle: 'fill' はスマートフォンでのみ、画面を隙間なく覆うよう
|
|
1794
|
+
// scaleBorder() の倍率を viewer.scaleSize に適用する。fit用の item.scale に
|
|
1795
|
+
// 依存するため、setSizeByScreen() の末尾から必ず呼ばれる(個別に呼ぶ必要はない)
|
|
1796
|
+
syncFillScale() {
|
|
1797
|
+
if (this.state.options.resizeStyle !== "fill" || !this.isSmartPhoneFlag) {
|
|
1798
|
+
return;
|
|
1799
|
+
}
|
|
1800
|
+
const item = currentItem(this.state);
|
|
1801
|
+
if (!item) {
|
|
1802
|
+
return;
|
|
1726
1803
|
}
|
|
1804
|
+
this.state.viewer.scale = true;
|
|
1805
|
+
this.state.viewer.hideUi = true;
|
|
1806
|
+
this.state.viewer.scaleSize = scaleBorder(
|
|
1807
|
+
item,
|
|
1808
|
+
getWindowWidth2(),
|
|
1809
|
+
getWindowHeight2(),
|
|
1810
|
+
this.isSmartPhoneFlag
|
|
1811
|
+
);
|
|
1727
1812
|
}
|
|
1728
1813
|
supportsViewTransition() {
|
|
1729
|
-
return typeof document.startViewTransition === "function"
|
|
1814
|
+
return this.state.options.useViewTransitionApi && typeof document.startViewTransition === "function" && // WebKit には「view-transition-name 付き要素が root スナップショットから
|
|
1815
|
+
// 除外されず、モーフ中に最終位置へ二重描画される」実装バグがあり、開く演出が
|
|
1816
|
+
// 「一旦ずれた位置に出てから正位置へ戻る」ように乱れる。API 対応の有無では
|
|
1817
|
+
// 検出できないため、WebKit ではクローン演出(addAppearEffect)へフォールバック
|
|
1818
|
+
// する(§util.isWebKit)
|
|
1819
|
+
!isWebKit();
|
|
1730
1820
|
}
|
|
1731
1821
|
openPhotoWithViewTransition(trigger) {
|
|
1732
1822
|
var _a, _b;
|
|
@@ -1739,7 +1829,8 @@ var SmartPhoto = (() => {
|
|
|
1739
1829
|
if (thumbImg) {
|
|
1740
1830
|
thumbImg.style.viewTransitionName = transitionName;
|
|
1741
1831
|
}
|
|
1742
|
-
const
|
|
1832
|
+
const cleanup = () => {
|
|
1833
|
+
this.isViewTransitionActive = false;
|
|
1743
1834
|
if (thumbImg) {
|
|
1744
1835
|
thumbImg.style.viewTransitionName = "";
|
|
1745
1836
|
}
|
|
@@ -1747,6 +1838,21 @@ var SmartPhoto = (() => {
|
|
|
1747
1838
|
if (img) {
|
|
1748
1839
|
img.style.viewTransitionName = "";
|
|
1749
1840
|
}
|
|
1841
|
+
if (!this.state.viewer.isOpen) {
|
|
1842
|
+
this.pendingViewTransitionResync = false;
|
|
1843
|
+
return;
|
|
1844
|
+
}
|
|
1845
|
+
if (this.pendingViewTransitionResync && currentItems(this.state)) {
|
|
1846
|
+
this.pendingViewTransitionResync = false;
|
|
1847
|
+
this.updateViewportHeight();
|
|
1848
|
+
this.resetTranslateCurrent();
|
|
1849
|
+
this.setPosByCurrentIndex();
|
|
1850
|
+
this.setSizeByScreen();
|
|
1851
|
+
this.commit();
|
|
1852
|
+
return;
|
|
1853
|
+
}
|
|
1854
|
+
this.pendingViewTransitionResync = false;
|
|
1855
|
+
this.view.render(this.state);
|
|
1750
1856
|
};
|
|
1751
1857
|
const transition = (_b = document.startViewTransition) == null ? void 0 : _b.call(document, () => {
|
|
1752
1858
|
this.initPhoto();
|
|
@@ -1756,11 +1862,16 @@ var SmartPhoto = (() => {
|
|
|
1756
1862
|
thumbImg.style.viewTransitionName = "";
|
|
1757
1863
|
}
|
|
1758
1864
|
this.currentImgElement().style.viewTransitionName = transitionName;
|
|
1865
|
+
this.view.applyViewTransitionLayout(this.state);
|
|
1759
1866
|
});
|
|
1760
|
-
|
|
1761
|
-
|
|
1867
|
+
if (!transition) {
|
|
1868
|
+
return;
|
|
1869
|
+
}
|
|
1870
|
+
this.isViewTransitionActive = true;
|
|
1871
|
+
transition.ready.catch(() => {
|
|
1872
|
+
cleanup();
|
|
1762
1873
|
});
|
|
1763
|
-
transition
|
|
1874
|
+
transition.finished.then(cleanup, cleanup);
|
|
1764
1875
|
}
|
|
1765
1876
|
// doOpen() の呼び出し元でこの分岐に来る時点で showAnimation !== false が保証されている
|
|
1766
1877
|
addAppearEffect(trigger, item) {
|
|
@@ -1870,10 +1981,14 @@ var SmartPhoto = (() => {
|
|
|
1870
1981
|
if (getWindowWidth2() === winWidthBefore && getWindowHeight2() === winHeightBefore) {
|
|
1871
1982
|
return;
|
|
1872
1983
|
}
|
|
1984
|
+
if (this.isViewTransitionActive) {
|
|
1985
|
+
this.pendingViewTransitionResync = true;
|
|
1986
|
+
return;
|
|
1987
|
+
}
|
|
1873
1988
|
this.resetTranslateCurrent();
|
|
1874
1989
|
this.setPosByCurrentIndex();
|
|
1875
1990
|
this.setSizeByScreen();
|
|
1876
|
-
this.
|
|
1991
|
+
this.commit();
|
|
1877
1992
|
});
|
|
1878
1993
|
}
|
|
1879
1994
|
openPhoto(item, trigger) {
|
|
@@ -1895,25 +2010,42 @@ var SmartPhoto = (() => {
|
|
|
1895
2010
|
}
|
|
1896
2011
|
doHideEffect(dir) {
|
|
1897
2012
|
return new Promise((resolve) => {
|
|
2013
|
+
if (this.state.options.showAnimation === false) {
|
|
2014
|
+
resolve();
|
|
2015
|
+
return;
|
|
2016
|
+
}
|
|
1898
2017
|
const dialog = this.view.refs.dialog;
|
|
1899
|
-
const
|
|
2018
|
+
const item = currentItem(this.state);
|
|
2019
|
+
const li = item ? this.currentLiElement() : null;
|
|
1900
2020
|
const height = getWindowHeight2();
|
|
1901
|
-
const
|
|
1902
|
-
|
|
2021
|
+
const img = this.currentImgElement();
|
|
2022
|
+
let frozenTransform = null;
|
|
2023
|
+
if (img) {
|
|
2024
|
+
const rendered = getComputedStyle(img).transform;
|
|
2025
|
+
if (rendered && rendered !== "none") {
|
|
2026
|
+
img.style.transform = rendered;
|
|
2027
|
+
frozenTransform = img.style.transform;
|
|
2028
|
+
}
|
|
2029
|
+
}
|
|
2030
|
+
if (li && item) {
|
|
2031
|
+
const offsetY = dir === "top" ? -height : height;
|
|
2032
|
+
li.style.transform = `translate(${item.translateX}px,${item.translateY + offsetY}px)`;
|
|
2033
|
+
}
|
|
2034
|
+
const finish = (e) => {
|
|
1903
2035
|
if (this.finishHideEffect !== finish) {
|
|
1904
2036
|
return;
|
|
1905
2037
|
}
|
|
2038
|
+
if (e && e.target !== dialog) {
|
|
2039
|
+
return;
|
|
2040
|
+
}
|
|
1906
2041
|
this.finishHideEffect = null;
|
|
1907
2042
|
dialog.removeEventListener("transitionend", finish, true);
|
|
1908
|
-
if (img && img.style.transform ===
|
|
2043
|
+
if (img && frozenTransform && img.style.transform === frozenTransform) {
|
|
1909
2044
|
img.style.transform = "";
|
|
1910
2045
|
}
|
|
1911
2046
|
resolve();
|
|
1912
2047
|
};
|
|
1913
2048
|
this.finishHideEffect = finish;
|
|
1914
|
-
if (img) {
|
|
1915
|
-
img.style.transform = applied;
|
|
1916
|
-
}
|
|
1917
2049
|
dialog.addEventListener("transitionend", finish, true);
|
|
1918
2050
|
this.scheduleTimeout(finish, this.state.options.animationSpeed + 100);
|
|
1919
2051
|
});
|
|
@@ -1984,7 +2116,9 @@ var SmartPhoto = (() => {
|
|
|
1984
2116
|
const item = currentItem(this.state);
|
|
1985
2117
|
this.state.viewer.onMove = false;
|
|
1986
2118
|
setArrow(this.state);
|
|
1987
|
-
this.
|
|
2119
|
+
if (this.state.viewer.isOpen) {
|
|
2120
|
+
this.commit();
|
|
2121
|
+
}
|
|
1988
2122
|
if (this.state.viewer.oldIndex !== this.state.viewer.currentIndex) {
|
|
1989
2123
|
this.fireEvent("change");
|
|
1990
2124
|
}
|
|
@@ -2069,7 +2203,21 @@ var SmartPhoto = (() => {
|
|
|
2069
2203
|
}
|
|
2070
2204
|
this.slideList();
|
|
2071
2205
|
},
|
|
2072
|
-
|
|
2206
|
+
// 主要ライトボックスのデファクトスタンダード(PhotoSwipe: bgClickAction
|
|
2207
|
+
// 'close' / imageClickAction 'zoom-or-close'、Fancybox: backdropClick
|
|
2208
|
+
// 'close'、GLightbox: closeOnOutsideClick、lightGallery: closable)に合わせ、
|
|
2209
|
+
// 写真の上のタップはズーム、写真の外(背景)のタップは閉じる。ズームの
|
|
2210
|
+
// 余地がない(scaleBorder <= 1 で zoomPhoto() が何もしない)写真の上の
|
|
2211
|
+
// タップも、無反応にせず 'zoom-or-close' に倣って閉じる
|
|
2212
|
+
onTap: (target) => {
|
|
2213
|
+
const img = this.currentImgElement();
|
|
2214
|
+
const onPhoto = !!img && target instanceof Node && img.contains(target);
|
|
2215
|
+
if (onPhoto && this.canZoomCurrentPhoto()) {
|
|
2216
|
+
this.zoomPhoto();
|
|
2217
|
+
} else {
|
|
2218
|
+
this.hidePhoto();
|
|
2219
|
+
}
|
|
2220
|
+
},
|
|
2073
2221
|
onGestureStart: () => {
|
|
2074
2222
|
this.fireEvent("gesturestart");
|
|
2075
2223
|
this.view.updatePhotoTransform(this.state);
|