popupable 1.4.0 → 1.5.0
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 +1 -0
- package/dist/popupable.min.css +2 -2
- package/dist/popupable.min.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -219,6 +219,7 @@ Popups can be styled using CSS variables:
|
|
|
219
219
|
|
|
220
220
|
/* UI elements (header, footer, buttons) */
|
|
221
221
|
--popupable-ui-background: #0008; /* Header/footer/button background */
|
|
222
|
+
--popupable-text-color: #fff; /* Text and icon color */
|
|
222
223
|
|
|
223
224
|
/* Spacing */
|
|
224
225
|
--popupable-screen-padding: 40px; /* Minimum gap between image and viewport edge */
|
package/dist/popupable.min.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* popupable
|
|
3
|
-
* Version : 1.
|
|
3
|
+
* Version : 1.5.0
|
|
4
4
|
* License : MIT
|
|
5
5
|
* Copyright: 2026 Ewan Howell
|
|
6
6
|
*/
|
|
7
|
-
@property --popupable-screen-padding{syntax:"<length>";inherits:true;initial-value:40px}@property --popupable-background{syntax:"<color>";inherits:true;initial-value:#000B}@property --popupable-ui-background{syntax:"<color>";inherits:true;initial-value:#0008}@property --popupable-blur{syntax:"<length>";inherits:true;initial-value:6px}@property --popupable-open-duration{syntax:"<time>";inherits:true;initial-value:.25s}@property --popupable-open-easing{syntax:"*";inherits:true;initial-value:ease}@property --popupable-switch-duration{syntax:"<time>";inherits:true;initial-value:.25s}@property --popupable-switch-easing{syntax:"*";inherits:true;initial-value:ease}[data-popupable],[data-popupable] *{cursor:pointer!important}.popupable-hide{visibility:hidden!important}.popupable-loading,.popupable-loading *{cursor:wait!important}.popupable-block-touch *{touch-action:none!important}.popupable-container{position:fixed;inset:0;transition:background var(--popupable-open-duration) ease,backdrop-filter var(--popupable-open-duration) ease;z-index:2147483646;user-select:none;pointer-events:none;touch-action:none}.popupable-container.popupable-active{z-index:2147483647;background:var(--popupable-background);backdrop-filter:blur(var(--popupable-blur))}.popupable-container>*{pointer-events:none}.popupable-container *{-
|
|
7
|
+
@property --popupable-screen-padding{syntax:"<length>";inherits:true;initial-value:40px}@property --popupable-background{syntax:"<color>";inherits:true;initial-value:#000B}@property --popupable-ui-background{syntax:"<color>";inherits:true;initial-value:#0008}@property --popupable-blur{syntax:"<length>";inherits:true;initial-value:6px}@property --popupable-open-duration{syntax:"<time>";inherits:true;initial-value:.25s}@property --popupable-open-easing{syntax:"*";inherits:true;initial-value:ease}@property --popupable-switch-duration{syntax:"<time>";inherits:true;initial-value:.25s}@property --popupable-switch-easing{syntax:"*";inherits:true;initial-value:ease}@property --popupable-text-color{syntax:"<color>";inherits:true;initial-value:#fff}[data-popupable],[data-popupable] *{cursor:pointer!important}.popupable-hide{visibility:hidden!important}.popupable-loading,.popupable-loading *{cursor:wait!important}.popupable-block-touch *{touch-action:none!important}.popupable-container{position:fixed;inset:0;transition:background var(--popupable-open-duration) ease,backdrop-filter var(--popupable-open-duration) ease;z-index:2147483646;user-select:none;pointer-events:none;touch-action:none}.popupable-container.popupable-active{z-index:2147483647;background:var(--popupable-background);backdrop-filter:blur(var(--popupable-blur))}.popupable-container>*{pointer-events:none}.popupable-container *{box-sizing:border-box;color:var(--popupable-text-color);-webkit-tap-highlight-color:transparent}.popupable-container.popupable-open,.popupable-container.popupable-open>*{pointer-events:initial}.popupable-clones{transition:transform var(--popupable-switch-duration) var(--popupable-switch-easing)}.popupable-clone-container{position:fixed;transition:all var(--popupable-open-duration) var(--popupable-open-easing);pointer-events:initial;overflow:hidden;transform:translateX(calc(var(--popupable-view-width) * var(--popupable-offset-multiplier)));transform-origin:0 0}.popupable-clone-container.popupable-transparent::before{content:"";position:absolute;inset:0;background-image:conic-gradient(#313131 .25turn,#1e1e1e .25turn .5turn,#313131 .5turn .75turn,#1e1e1e .75turn);background-size:32px 32px;background-attachment:fixed;z-index:-1;opacity:0;transition:opacity var(--popupable-open-duration) var(--popupable-open-easing);image-rendering:pixelated}.popupable-fade .popupable-clone-container{opacity:0}.popupable-container.popupable-active .popupable-clone-container{border-radius:0!important;opacity:1}.popupable-container.popupable-active .popupable-clone-container.popupable-transparent::before{opacity:1}.popupable-container.popupable-open .popupable-clone-container{transition:transform var(--popupable-switch-duration) var(--popupable-switch-easing),translate var(--popupable-switch-duration) var(--popupable-switch-easing)}.popupable-clone,.popupable-clone-layer{width:100%;height:100%;position:absolute;inset:0;transition:opacity var(--popupable-open-duration) var(--popupable-open-easing)}.popupable-clone-layer{opacity:0;object-fit:cover}.popupable-crossfade.popupable-open .popupable-clone:not(:last-child){opacity:0}.popupable-container:not(.popupable-crossfade) .popupable-clone-layer,.popupable-crossfade.popupable-active .popupable-clone-layer{opacity:1}.popupable-viewport{position:fixed;left:var(--popupable-vv-left,0);top:var(--popupable-vv-top,0);width:calc(var(--popupable-vv-width,100vw) * var(--popupable-vv-scale,1));height:calc(var(--popupable-vv-height,100vh) * var(--popupable-vv-scale,1));transform-origin:top left;transform:scale(var(--popupable-vv-ui-scale,1));pointer-events:none!important}.popupable-button{width:40px;height:40px;display:flex;align-items:center;justify-content:center;transition:opacity var(--popupable-open-duration) var(--popupable-open-easing),transform var(--popupable-open-duration) var(--popupable-open-easing);cursor:pointer;position:relative;opacity:0}.popupable-button::before{content:"";position:absolute;inset:0;opacity:.5;background:var(--popupable-ui-background);transition:opacity .25s;border-radius:50%}.popupable-button svg{width:24px;height:24px;z-index:1}.popupable-container.popupable-open .popupable-button{transition:background .25s,opacity .25s,transform .25s}.popupable-button-container:hover .popupable-button::before,.popupable-button:hover::before{opacity:1}.popupable-button-container{position:absolute;padding:40px;cursor:pointer;z-index:1;pointer-events:auto}.popupable-next-container{top:50%;transform:translateY(-50%);right:calc(var(--popupable-screen-padding)/ 2)}.popupable-prev-container{top:50%;transform:translateY(-50%);left:calc(var(--popupable-screen-padding)/ 2)}.popupable-close-container{position:absolute;bottom:0;right:0;padding:20px;transform:translateY(100%)}.popupable-next{transform:translateX(40px)}.popupable-prev{transform:translateX(-40px)}.popupable-close{transform:translateY(40px)}.popupable-container.popupable-active .popupable-button{transform:initial}.popupable-container:not(.popupable-locked).popupable-active .popupable-button{opacity:1}.popupable-next-container:hover .popupable-button{transform:translateX(4px)}.popupable-prev-container:hover .popupable-button{transform:translateX(-4px)}.popupable-button-disabled,.popupable-button-inactive,.popupable-locked .popupable-button-container{pointer-events:none}.popupable-locked .popupable-button-container .popupable-button,:is(.popupable-button-disabled,.popupable-button-inactive) .popupable-button{opacity:0!important}.popupable-locked .popupable-next-container .popupable-next,.popupable-next-container:is(.popupable-button-disabled,.popupable-button-inactive) .popupable-next{transform:translateX(40px)}.popupable-locked .popupable-prev-container .popupable-prev,.popupable-prev-container:is(.popupable-button-disabled,.popupable-button-inactive) .popupable-prev{transform:translateX(-40px)}.popupable-footer,.popupable-header{position:absolute;top:0;left:0;right:0;opacity:0;transition:opacity var(--popupable-open-duration) var(--popupable-open-easing),transform var(--popupable-open-duration) var(--popupable-open-easing);transform:translateY(-40px);background:var(--popupable-ui-background);pointer-events:auto}.popupable-footer{top:initial;bottom:0;transform:translateY(40px)}.popupable-container.popupable-active:not(.popupable-locked) .popupable-footer,.popupable-container.popupable-active:not(.popupable-locked) .popupable-header{opacity:1;transform:initial}.popupable-counter{padding:10px;text-align:center}.popupable-counter+.popupable-thumbnails,.popupable-thumbnails+.popupable-counter{border-top:1px solid #fff3}.popupable-content-container{display:grid;align-items:flex-end;transition:height var(--popupable-switch-duration) var(--popupable-switch-easing);overflow:hidden;position:relative}.popupable-content{grid-column:1;grid-row:1;text-align:center;padding:16px;display:flex;flex-direction:column;gap:8px;user-select:text;transition:opacity var(--popupable-switch-duration) var(--popupable-switch-easing),transform var(--popupable-switch-duration) var(--popupable-switch-easing);position:absolute;bottom:0;left:50%;transform:translateX(-50%);max-width:100%;width:max-content}.popupable-title{font-size:32px;font-weight:600}.popupable-content-before{pointer-events:none;opacity:0;transform:translateX(calc(-50% - 80px))}.popupable-content-after{pointer-events:none;opacity:0;transform:translateX(calc(-50% + 80px))}.popupable-content-container:not(:first-child) .popupable-content{padding-top:17px}.popupable-content-container:not(:last-child) .popupable-content{padding-bottom:17px}.popupable-content-container:not(:first-child)::before{content:"";position:absolute;height:1px;top:0;left:0;right:0;background-color:#fff3}.popupable-footer .popupable-content-container:not(:last-child)::after,.popupable-header .popupable-content-container:not(:nth-last-child(2))::after{content:"";position:absolute;height:1px;bottom:0;left:0;right:0;background-color:#fff3}.popupable-thumbnails{display:flex;gap:10px;padding:10px;justify-content:safe center;overflow:hidden;scrollbar-width:none;touch-action:pan-x}.popupable-thumbnails.popupable-thumbnails-dragging{cursor:grabbing}.popupable-thumbnail{width:64px;height:64px;object-fit:cover;opacity:.65;cursor:pointer;transition:opacity .2s,outline-color .2s;outline:2px solid #0000;outline-offset:-2px;flex:0 0 auto}.popupable-thumbnail:hover{opacity:1}.popupable-thumbnail.popupable-thumbnail-active{opacity:1;outline-color:#fffa}.popupable-zoomable{cursor:zoom-in}.popupable-zoomed{cursor:zoom-out}@media (max-width:768px){:root{--popupable-screen-padding:14px}.popupable-button{width:42px;height:42px}.popupable-next-container,.popupable-prev-container{padding:36px}.popupable-button svg{width:25px;height:25px}.popupable-counter{padding:8px}.popupable-content{padding:14px;gap:6px}.popupable-content-container:not(:first-child) .popupable-content{padding-top:15px}.popupable-content-container:not(:last-child) .popupable-content{padding-bottom:15px}.popupable-title{font-size:28px}.popupable-thumbnail{width:48px;height:48px}}
|
package/dist/popupable.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* popupable
|
|
3
|
-
* Version : 1.
|
|
3
|
+
* Version : 1.5.0
|
|
4
4
|
* License : MIT
|
|
5
5
|
* Copyright: 2026 Ewan Howell
|
|
6
6
|
*/
|
|
7
|
-
{let e,t,n,o=0;const a=3;let i,s,r,l;function triggerHaptic(){if("function"!=typeof navigator.vibrate){if(!i){i=document.createElement("label"),i.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;pointer-events:none";const e=document.createElement("input");e.type="checkbox",e.setAttribute("switch",""),i.append(e),document.body.append(i)}i.click()}else navigator.vibrate([10])}function disableScroll(){window.addEventListener("wheel",prevent,{passive:!1}),window.addEventListener("touchmove",prevent,{passive:!1}),window.addEventListener("keydown",blockKeys,!0)}function enableScroll(){window.removeEventListener("wheel",prevent),window.removeEventListener("touchmove",prevent),window.removeEventListener("keydown",blockKeys,!0)}function prevent(e){e.preventDefault()}function blockKeys(e){["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&e.preventDefault()}function calcExpandedRect(t){const n=t.original,o=visualViewport?.width||window.innerWidth,a=visualViewport?.height||window.innerHeight,i=visualViewport?.offsetTop||0,s=visualViewport?.offsetLeft||0,r=visualViewport?.scale||1,l=1/r,p=e.popup,c=(parseFloat(getComputedStyle(p).getPropertyValue("--popupable-screen-padding"))||40)/r,u=Math.max(0,o-2*c),d=a-2*c,b=Math.max(0,d);let f;if(t.maintainAspect){const e=n.getBoundingClientRect();f=e.width/e.height}else{const e=t.cloneLayer||n;f=e.naturalWidth/e.naturalHeight||1}let m=0,h=0;if(e.orderPlacement){const n=e.popup.querySelector(".popupable-counter"),o=n?n.getBoundingClientRect().height/l:0,a=e.thumbnailsContainer?e.thumbnailsContainer.getBoundingClientRect().height/l:0,i=e.contentContainer,s=t.content?t.content.getBoundingClientRect().height/l:i?.previousElementSibling&&i?.nextElementSibling&&parseFloat(getComputedStyle(i,"::after").height)||0,{counterTop:r,contentTop:p,thumbnailsTop:c,counterBottom:u,contentBottom:d,thumbnailsBottom:b}=e.orderPlacement;m=(r?o:0)+(p?s:0)+(c?a:0),h=(u?o:0)+(d?s:0)+(b?a:0)}const v=Math.max(0,a-m-h-2*c);let g=u,y=g/f;if(y>b&&(y=b,g=y*f),y>v&&(y=v,g=y*f),t.noUpscale){const e=t.cloneLayer||n,o=e.naturalWidth,a=e.naturalHeight;if(o&&a){const e=o/r,t=a/r,n=Math.min(1,e/g,t/y);n<1&&(g*=n,y*=n)}}let w=i+c+(b-y)/2;const L=i+a-h-c-y;return w=Math.min(w,L),w=Math.max(w,i+m+c),{top:w,left:s+c+(u-g)/2,width:g,height:y}}function setCloneToOriginalRect(t,n){const o=calcExpandedRect(e),a=popupableAnimTypes[e.animation](n,o);return t.style.top=a.top+"px",t.style.left=a.left+"px",t.style.width=a.width+"px",t.style.height=a.height+"px",a}function openPopupable(e){if("open"===e.state)return;e.state="open",triggerHaptic();const{cloneContainer:t,popup:n,transition:o,group:a,listeners:i}=e;n.classList.add("popupable-active"),e.clearNavInactive?.(),updateExpandedSize(),e.closingContainer?.removeEventListener("transitionend",o.listener);const s=e.closingContainer??t;o.listener=t=>{if(!t||t.target===t.currentTarget){if(s.removeEventListener("transitionend",o.listener),n.classList.add("popupable-open"),a)for(const e of a)e.cloneContainer.style.display=null;for(const e of i)e.target.addEventListener(e.event,e.func,e.args);e.scheduleNavHide?.()}},o.duration?s.addEventListener("transitionend",o.listener):o.listener()}function closePopupable(){if(!e||"close"===e.state)return;o++,e.state="close",document.body.classList.add("popupable-block-touch"),setTimeout(()=>document.body.classList.remove("popupable-block-touch"),300);const{cloneContainer:n,original:a,popup:i,transition:s,group:r,listeners:l}=e;a.classList.remove("popupable-loading"),i.classList.remove("popupable-active"),i.classList.remove("popupable-open");const p=r?r[r.currentIndex].cloneContainer:n;if(e.closingContainer=p,setCloneToOriginalRect(p,a),r)for(const e of r)e.cloneContainer!==p&&(e.cloneContainer.style.display="none");for(const e of l)e.target.removeEventListener(e.event,e.func);n.removeEventListener("transitionend",s.listener);const c=e;s.listener=n=>{n&&n.target!==n.currentTarget||(p.removeEventListener("transitionend",s.listener),a.classList.remove("popupable-hide"),i.remove(),c===e&&(enableScroll(),t=e,e=null))},s.duration?p.addEventListener("transitionend",s.listener):s.listener()}function updateExpandedSize(){if(!e||"close"===e.state)return;const t=visualViewport?.width||window.innerWidth,n=visualViewport?.height||window.innerHeight,o=visualViewport?.offsetTop||0,a=visualViewport?.offsetLeft||0,i=visualViewport?.scale||1;document.documentElement.style.setProperty("--popupable-view-width",t+"px"),e.popup.style.setProperty("--popupable-vv-width",t+"px"),e.popup.style.setProperty("--popupable-vv-height",n+"px"),e.popup.style.setProperty("--popupable-vv-top",o+"px"),e.popup.style.setProperty("--popupable-vv-left",a+"px"),e.popup.style.setProperty("--popupable-vv-scale",i),e.popup.style.setProperty("--popupable-vv-ui-scale",1/i);const s=1/i;let r;r=e.group?e.group:[e];for(const e of r){const{top:t,left:n,width:o,height:a}=calcExpandedRect(e);e.cloneContainer.style.top=t+"px",e.cloneContainer.style.left=n+"px",e.cloneContainer.style.width=o+"px",e.cloneContainer.style.height=a+"px"}if(e.contentContainer){let t;if(t=e.group?e.group[e.group.currentIndex]:e,t.content){const n=t.content.getBoundingClientRect();e.contentContainer.style.height=n.height/s+"px"}else{const t=e.contentContainer,n=t.previousElementSibling&&t.nextElementSibling&&parseFloat(getComputedStyle(t,"::after").height)||0;t.style.height=n+"px"}}}function parsePopupableOrder(e){const t=["counter","image","content","thumbnails"],n=new Set(t),o=[];if(e)for(const t of e.split(",")){const e=t.trim().toLowerCase();e&&n.has(e)&&!o.includes(e)&&o.push(e)}for(const e of t)o.includes(e)||o.push(e);const a=o.indexOf("image");return{top:o.slice(0,a),bottom:o.slice(a+1)}}function cloneElement(e,t){const n=document.createElement("div");n.className="popupable-clone-container",e.hasAttribute("data-popupable-transparent")&&n.classList.add("popupable-transparent");const o=new Image;o.className="popupable-clone",o.src=t??e.currentSrc??e.src;const a=getComputedStyle(e);let i,s,r;if(n.style.borderRadius=a.borderRadius,o.style.objectFit=a.objectFit,o.style.objectPosition=a.objectPosition,o.style.imageRendering=a.imageRendering,o.style.background=a.background,n.append(o),(e.dataset.popupableSrc||t)&&(i=new Image,i.className="popupable-clone-layer",i.src=e.dataset.popupableSrc??e.currentSrc??e.src,i.style.imageRendering=a.imageRendering,n.append(i),"fill"===o.style.objectFit)){const t=e.getBoundingClientRect();e.naturalWidth&&e.naturalHeight&&Math.abs(t.width/t.height-e.naturalWidth/e.naturalHeight)<.01&&(o.style.objectFit="cover")}if(e.dataset.popupableTitle||e.dataset.popupableDescription){if(s=document.createElement("div"),s.classList="popupable-content",e.dataset.popupableTitle){const t=document.createElement("div");t.className="popupable-title",t.textContent=e.dataset.popupableTitle,s.append(t)}if(e.dataset.popupableDescription){const t=document.createElement("div");t.className="popupable-description",t.textContent=e.dataset.popupableDescription,s.append(t)}}return e.hasAttribute("data-popupable-zoomable")&&(r=!0,n.classList.add("popupable-zoomable")),{id:e.dataset.popupable,original:e,cloneContainer:n,clone:o,cloneLayer:i,maintainAspect:e.hasAttribute("data-popupable-maintain-aspect"),noUpscale:e.hasAttribute("data-popupable-no-upscale"),counter:e.hasAttribute("data-popupable-counter"),thumbnails:e.hasAttribute("data-popupable-thumbnails"),order:parsePopupableOrder(e.dataset.popupableOrder),animation:popupableAnimTypes[e.dataset.popupableAnim]?e.dataset.popupableAnim:"expand",ready:Promise.all([o,i].filter(Boolean).map(e=>e.decode().catch(()=>{}))),content:s,zoomable:r}}function handleMove(t){if("open"!==e?.state||!e.group||!s)return;if(!e.popup?.classList.contains("popupable-open"))return r=t.touches?.[0].clientX??t.clientX,void(l=t.touches?.[0].clientY??t.clientY);const n=e.group[e.group.currentIndex];n.cloneContainer.parentElement.style.transition="initial",n.cloneContainer.parentElement.style.transform=`translateX(${(t.touches?.[0].clientX??t.clientX)-r}px)`}window.popupableAnimTypes={expand(e){const t=e.getBoundingClientRect();return{top:visualViewport.offsetTop+t.top,left:visualViewport.offsetLeft+t.left,width:t.width,height:t.height,hideSource:!0,crossfade:!0}},pop:(e,{top:t,left:n,width:o,height:a})=>({top:t+.05*a,left:n+.05*o,width:.9*o,height:.9*a,fade:!0}),line:(e,{top:t,left:n,width:o,height:a})=>({top:t+a/2,left:n+.05*o,width:.9*o,height:0,fade:!0}),float:(e,{top:t,left:n,width:o,height:a})=>({top:t+40,left:n,width:o,height:a,fade:!0})},document.addEventListener("pointerdown",t=>{0===t.button&&(s||(n=t.target,r=t.clientX,l=t.clientY),s||"open"!==e?.state||t.target.closest(".popupable-header, .popupable-footer")||(s=!0))}),document.addEventListener("mousemove",handleMove),document.addEventListener("touchmove",handleMove,{passive:!0}),document.addEventListener("pointerup",async i=>{if(0!==i.button)return;if(s){s=!1;const K=e.group?e.group[e.group.currentIndex]:e;K.cloneContainer.parentElement.style.transition=null,K.cloneContainer.parentElement.style.transform=null;const Z=i.clientX-r,G=Math.abs(Z),J=i.clientY-l,Q=Math.abs(J);if("touch"===i.pointerType&&Q>56&&Q>1.1*G)return void closePopupable();if(e.group&&G>a){const ee=Math.max(0,Math.floor((G-window.innerWidth/2)/window.innerWidth));if(Z>32)for(let te=0;te<=ee;te++)e.goPrev();else if(Z<-32)for(let ne=0;ne<=ee;ne++)e.goNext();return void(e.blocked=!0)}}const p=i.target.closest(".popupable-viewport")&&!n.closest(".popupable-viewport");if(!p&&i.target!=n&&(!n.classList.contains("popupable-clone-container")||i.target!==t?.original)&&(!n.closest(".popupable-container")||i.target.closest(".popupable-container"))||Math.abs(i.clientX-r)>a||Math.abs(i.clientY-l)>a)return;const c=(p?n.closest("[data-popupable]"):null)||i.target.closest("[data-popupable]");if(!c){if(p)return void closePopupable();if(i.target.closest(".popupable-container"))return;return void(e&&("zoomed"===e.state?e.unzoom():closePopupable()))}if(i.preventDefault(),e&&"close"!==e.state&&e.original===c)return;e&&closePopupable();const u=++o;e={transition:{},listeners:[]};const d=e,b=document.createElement("div");b.className="popupable-clones";const f=cloneElement(c),{cloneContainer:m,content:h}=f;let v;if(c.dataset.popupableGroup){const oe=document.querySelectorAll(`[data-popupable-group="${c.dataset.popupableGroup}"]`);if(oe.length){v=[];for(const[ae,ie]of oe.entries())if(ie===c)v.push(f),v.currentIndex=ae,b.append(m);else{const se=cloneElement(ie,c.currentSrc??c.src);se.cloneContainer.style.display="none",v.push(se),b.append(se.cloneContainer)}for(const[re,le]of v.entries()){if(!le.content)continue;const pe=re-v.currentIndex;pe>0?le.content.classList.add("popupable-content-after"):pe<0&&le.content.classList.add("popupable-content-before")}}}else b.append(m);const g=document.createElement("div");g.className=`popupable-container popupable-anim-${f.animation}`,f.id&&(g.id=f.id);const y=document.createElement("div");let w,L,x,C,E,I,P,M,z,k,T;y.className="popupable-viewport",(h||v&&v.some(e=>e.content))&&(w=document.createElement("div"),w.classList="popupable-content-container");const S={};if(v){f.counter&&(C=document.createElement("div"),C.className="popupable-counter"),f.thumbnails&&(E=document.createElement("div"),E.className="popupable-thumbnails",I=v.map((e,t)=>{const n=new Image;return n.className="popupable-thumbnail",n.src=e.original.currentSrc??e.original.src,n.dataset.thumbnailIndex=t,E.append(n),n})),y.innerHTML=`\n <div class="popupable-button-container popupable-prev-container${v.currentIndex?"":" popupable-button-disabled"}">\n <div class="popupable-button popupable-prev">\n <svg width="24px" height="24px" viewBox="0 -960 960 960" fill="#fff">\n <path d="m313-440 224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"/>\n </svg>\n </div>\n </div>\n <div class="popupable-button-container popupable-next-container${v.currentIndex===v.length-1?" popupable-button-disabled":""}">\n <div class="popupable-button popupable-next">\n <svg width="24px" height="24px" viewBox="0 -960 960 960" fill="#fff">\n <path d="M647-440H160v-80h487L423-744l57-56 320 320-320 320-57-56 224-224Z"/>\n </svg>\n </div>\n </div>\n `;const ce=y.querySelector(".popupable-next-container"),ue=y.querySelector(".popupable-prev-container");let de,be,fe,me;const he=!(navigator.maxTouchPoints>0||window.matchMedia("(hover: none)").matches);function X(){ce.classList.remove("popupable-button-inactive"),ue.classList.remove("popupable-button-inactive"),e.scheduleNavHide()}if(e.scheduleNavHide=()=>{he&&(clearTimeout(de),me||(de=setTimeout(()=>{me||(ce.classList.add("popupable-button-inactive"),ue.classList.add("popupable-button-inactive"))},1500)))},e.clearNavInactive=()=>{ce.classList.remove("popupable-button-inactive"),ue.classList.remove("popupable-button-inactive")},T=async()=>{const t=v[v.currentIndex];await t.ready,v.currentIndex?ue.classList.remove("popupable-button-disabled"):ue.classList.add("popupable-button-disabled"),v.currentIndex===v.length-1?ce.classList.add("popupable-button-disabled"):ce.classList.remove("popupable-button-disabled");for(const[e,t]of v.entries()){const n=e-v.currentIndex;t.cloneContainer.style.setProperty("--popupable-offset-multiplier",n),t.cloneContainer.style.zIndex=-1*Math.abs(n),t.content&&(n?n>0?(t.content.classList.add("popupable-content-after"),t.content.classList.remove("popupable-content-before")):(t.content.classList.add("popupable-content-before"),t.content.classList.remove("popupable-content-after")):(t.content.classList.remove("popupable-content-before"),t.content.classList.remove("popupable-content-after")))}if(t.id?g.id=t.id:g.removeAttribute("id"),C&&(C.textContent=`${v.currentIndex+1} / ${v.length}`),I){for(const[e,t]of I.entries())t.classList.toggle("popupable-thumbnail-active",e===v.currentIndex);const e=I[v.currentIndex];requestAnimationFrame(()=>{if(!e||!E?.isConnected)return;const t=getComputedStyle(E),n=parseFloat(t.paddingLeft)||0,o=parseFloat(t.paddingRight)||0,a=E.scrollLeft+n,i=E.scrollLeft+E.clientWidth-o,s=e.offsetLeft,r=s+e.offsetWidth;let l=E.scrollLeft;s<a?l=Math.max(0,s-n):r>i&&(l=r-E.clientWidth+o),l!==E.scrollLeft&&(P?E.scrollTo({left:l,behavior:"smooth"}):E.scrollLeft=l),P=!0})}e.closeContainer.classList.toggle("popupable-button-inactive",!t.zoomable),updateExpandedSize()},M=()=>{v.currentIndex>=v.length-1||(v.currentIndex++,T())},z=()=>{v.currentIndex<=0||(v.currentIndex--,T())},e.listeners.push({target:ce,event:"click",func:()=>M()},{target:ue,event:"click",func:()=>z()},{target:document,event:"keydown",func:t=>{if("zoomed"!==e.state)switch(t.key){case"ArrowRight":case"ArrowDown":case"PageDown":case"d":case"s":M();break;case"ArrowLeft":case"ArrowUp":case"PageUp":case"a":case"w":z();break;case"Home":v.currentIndex=0,T();break;case"End":v.currentIndex=v.length-1,T();break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":v.currentIndex=Math.min(Math.max(Number(t.key),1)-1,v.length-1),T()}}},{target:document,event:"wheel",func:t=>{if("zoomed"===e.state)return;const n=performance.now();n-(k||0)<80||(t.deltaY>50?(k=n,M()):t.deltaY<-50&&(k=n,z()))},args:{passive:!0}}),E){let ve,ge,ye,we,Le,xe,Ce,Ee,Ie;function A(){Ie&&(cancelAnimationFrame(Ie),Ie=null)}function N(){if(A(),Math.abs(Ee)<.01)return;let e=performance.now();Ie=requestAnimationFrame(function t(n){if(!E.isConnected)return void A();const o=E.scrollWidth-E.clientWidth;if(o<=0)return void A();const a=Math.min(32,n-e);e=n;let i=E.scrollLeft+Ee*a;i<0&&(i=0),i>o&&(i=o),E.scrollLeft=i,E.scrollLeft<=.1&&Ee<0||E.scrollLeft>=o-.1&&Ee>0?A():(Ee*=Math.pow(.8,a/16.67),Math.abs(Ee)<=.002?A():Ie=requestAnimationFrame(t))})}e.listeners.push({target:E,event:"pointerdown",func:e=>{if(0!==e.button)return;const t=E.scrollWidth-E.clientWidth;ye=t>0,A(),ve=!0,ge=!1,we=e.clientX,Le=E.scrollLeft,xe=E.scrollLeft,Ce=performance.now(),Ee=0,ye&&E.classList.add("popupable-thumbnails-dragging"),E.setPointerCapture(e.pointerId)}},{target:E,event:"pointermove",func:e=>{if(!ve)return;const t=e.clientX-we;Math.abs(t)>a&&(ge=!0);const n=performance.now(),o=n-Ce,i=Le-t;if(E.scrollLeft=i,o>0){const e=(E.scrollLeft-xe)/o;Ee=.65*Ee+.35*e,xe=E.scrollLeft,Ce=n}}},{target:E,event:"pointerup",func:e=>{if(!ve)return;if(ve=!1,ye&&E.classList.remove("popupable-thumbnails-dragging"),E.hasPointerCapture(e.pointerId)&&E.releasePointerCapture(e.pointerId),ge)return performance.now()-Ce>10&&(Ee=0),void N();const t=document.elementFromPoint(e.clientX,e.clientY)?.closest?.(".popupable-thumbnail");t&&(v.currentIndex=Number(t.dataset.thumbnailIndex),T())}},{target:E,event:"pointercancel",func:e=>{ve&&(ve=!1,ye&&E.classList.remove("popupable-thumbnails-dragging"),E.hasPointerCapture(e.pointerId)&&E.releasePointerCapture(e.pointerId),A())}},{target:E,event:"wheel",func:e=>{e.stopPropagation(),e.preventDefault();const t=E.scrollWidth-E.clientWidth;if(t<=0)return;const n=Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.deltaY,o=E.scrollLeft<=.1,a=E.scrollLeft>=t-.1;if(o&&n<0||a&&n>0)return;o&&n>0&&Ee<0&&(Ee=0),a&&n<0&&Ee>0&&(Ee=0);Ee=(Ee||0)+.015*n,Ie||N()},args:{passive:!1}})}he&&(e.listeners.push({target:ce,event:"pointerenter",func:()=>{me=!0,X()}},{target:ue,event:"pointerenter",func:()=>{me=!0,X()}},{target:ce,event:"pointerleave",func:()=>{me=!1,e.scheduleNavHide()}},{target:ue,event:"pointerleave",func:()=>{me=!1,e.scheduleNavHide()}}),e.listeners.push({target:g,event:"pointermove",func:t=>{if("zoomed"!==e.state)return null==be||null==fe?(be=t.clientX,void(fe=t.clientY)):void(Math.abs(t.clientX-be)<a&&Math.abs(t.clientY-fe)<a||(be=t.clientX,fe=t.clientY,X()))},args:{passive:!0}}));for(const Pe of v)Pe.content&&w&&w.append(Pe.content)}else h&&w.append(h);const Y={counter:!!C,content:!!w,thumbnails:!!E},R=f.order.top.filter(e=>Y[e]),B=f.order.bottom.filter(e=>Y[e]);function H(e,t){e&&("counter"===t&&C?(S[e===L?"counterTop":"counterBottom"]=!0,e.append(C)):"content"===t&&w?(S[e===L?"contentTop":"contentBottom"]=!0,e.append(w)):"thumbnails"===t&&E&&(S[e===L?"thumbnailsTop":"thumbnailsBottom"]=!0,e.append(E)))}L=document.createElement("div"),L.className="popupable-header",x=document.createElement("div"),x.className="popupable-footer";for(const Me of R)H(L,Me);for(const ze of B)H(x,ze);y.append(L),y.append(x);const D=document.createElement("div");D.className="popupable-button-container popupable-close-container",D.innerHTML='<div class="popupable-button popupable-close"><svg width="24px" height="24px" viewBox="0 -960 960 960" fill="#fff"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg></div>',D.addEventListener("click",closePopupable),f.zoomable||D.classList.add("popupable-button-inactive"),L.append(D),g.append(b,y),Object.assign(d,f,{popup:g,group:v,contentContainer:w,thumbnailsContainer:E,orderPlacement:S,closeContainer:D,goNext:M,goPrev:z});const F=setTimeout(()=>{u===o&&c.classList.add("popupable-loading")},250);if(await d.ready,clearTimeout(F),c.classList.remove("popupable-loading"),u!==o||e!==d||"close"===d.state)return;m.style.transition="initial",document.body.append(g);const{hideSource:W,crossfade:V,fade:O}=setCloneToOriginalRect(m,c);W&&c.classList.add("popupable-hide"),V&&g.classList.add("popupable-crossfade"),O&&g.classList.add("popupable-fade"),disableScroll();const $=getComputedStyle(g);d.transition.duration=1e3*parseFloat($.transitionDuration)+1e3*parseFloat($.transitionDelay),g._state=d,m.style.transition=null,openPopupable(g._state),v&&T();let U,q=0;v&&g.addEventListener("dragstart",e=>e.preventDefault());const _=new Map;function j(e,t,n,o,i=[]){if("open"!==e.state)return;let r=0;const l=t.cloneContainer.parentElement,p=l.style.transform;if(p){const e=p.match(/translateX\((-?\d+(?:\.\d+)?)px\)/);e&&(r=Number(e[1])||0)}const c=Math.abs(r)>.5;s=!1,c?(t.cloneContainer.style.translate="0 0",t.cloneContainer.style.transition="translate var(--popupable-switch-duration), transform 0s",l.style.transition=null,l.style.transform=null,t.cloneContainer.style.translate=`${r}px 0`):(l.style.transition=null,l.style.transform=null),e.state="zoomed",g.classList.add("popupable-locked");let u,d,b=o;const f=new Map;let m,h,v,w,L,x,C,E,I,P,M=!1;const z=t.cloneContainer.getBoundingClientRect(),k=n?.clientX??z.left+z.width/2,T=n?.clientY??z.top+z.height/2;u=(k-z.left)*(1-b),d=(T-z.top)*(1-b);const S=()=>t.cloneContainer.style.transform=`translate(${u}px, ${d}px) scale(${b})`;function X(e,n,o){const a=b;var i;if(i=e,b=Math.min(6,Math.max(.5,i)),b===a)return!1;const s=t.cloneContainer.getBoundingClientRect(),r=b/a,l=n-s.left,p=o-s.top;return u+=l*(1-r),d+=p*(1-r),!0}function A(){if(1===f.size){const e=f.values().next().value;return m=e.id,h=e.x,v=e.y,w=null,L=null,void(x=null)}if(f.size>=2){m=null;const[e,t]=[...f.values()];return w=(e.x+t.x)/2,L=(e.y+t.y)/2,void(x=Math.hypot(t.x-e.x,t.y-e.y))}m=null,h=null,v=null,w=null,L=null,x=null}if(t.cloneContainer.classList.add("popupable-zoomed"),S(),i.length){c||(t.cloneContainer.style.transition="none"),P=!0;for(const e of i)f.set(e.id,{id:e.id,x:e.x,y:e.y}),g.setPointerCapture(e.id);A()}e.unzoom=()=>{e.state="open",g.classList.remove("popupable-locked");for(const e of f.keys())g.hasPointerCapture(e)&&g.releasePointerCapture(e);f.clear(),t.cloneContainer.classList.remove("popupable-zoomed"),t.cloneContainer.style.transition=null,t.cloneContainer.style.transform=null,t.cloneContainer.style.translate=null;for(const t of e.zoomListeners)t.target.removeEventListener(t.event,t.func)},e.zoomListeners=[{target:g,event:"pointerdown",func:e=>{0===e.button&&(t.cloneContainer.style.transition="none",g.setPointerCapture(e.pointerId),f.set(e.pointerId,{id:e.pointerId,x:e.clientX,y:e.clientY}),1===f.size?(C=e.target,E=e.clientX,I=e.clientY,P=!1):P=!0,A(),e.preventDefault())}},{target:g,event:"pointermove",func:e=>{const t=f.get(e.pointerId);if(t){if(t.x=e.clientX,t.y=e.clientY,!P&&(Math.abs(e.clientX-E)>a||Math.abs(e.clientY-I)>a)&&(P=!0),1===f.size&&m===e.pointerId){const t=e.clientX-h,n=e.clientY-v;if(!t&&!n)return;return u+=t,d+=n,h=e.clientX,v=e.clientY,void S()}if(f.size>=2){const[e,t]=[...f.values()],n=(e.x+t.x)/2,o=(e.y+t.y)/2,a=Math.hypot(t.x-e.x,t.y-e.y);if(!x)return w=n,L=o,void(x=a);u+=n-w,d+=o-L,X(b*(a/x),n,o),M=!0,w=n,L=o,x=a,S()}}}},{target:g,event:"pointerup",func:n=>{if(f.has(n.pointerId)){if(f.delete(n.pointerId),g.hasPointerCapture(n.pointerId)&&g.releasePointerCapture(n.pointerId),M&&b<=1.01&&f.size<2)return e.skipOpenTouchPointerUps=f.size,void e.unzoom();if(!f.size&&!P&&Math.abs(n.clientX-E)<a&&Math.abs(n.clientY-I)<a){if(C?.closest?.(".popupable-clone-container")===t.cloneContainer||(C===g||C===y))return void e.unzoom()}A()}}},{target:g,event:"pointercancel",func:e=>{f.has(e.pointerId)&&(f.delete(e.pointerId),g.hasPointerCapture(e.pointerId)&&g.releasePointerCapture(e.pointerId),A())}},{target:g,event:"wheel",func:e=>{t.cloneContainer.style.transition="none",X(b*Math.exp(.002*-e.deltaY),e.clientX,e.clientY)&&S()},args:{passive:!0}}];for(const t of e.zoomListeners)t.target.addEventListener(t.event,t.func,t.args)}e.listeners.push({target:g,event:"pointerdown",func:e=>{if("open"!==g._state.state||"touch"!==e.pointerType)return;const t=g._state,n=t.group?t.group[t.group.currentIndex]:t;e.target.closest(".popupable-clone-container")===n.cloneContainer&&(_.set(e.pointerId,{id:e.pointerId,x:e.clientX,y:e.clientY}),_.size>=2&&(j(t,n,e,1,[..._.values()].slice(0,2)),_.clear(),e.preventDefault()))}},{target:g,event:"pointermove",func:e=>{const t=_.get(e.pointerId);t&&(t.x=e.clientX,t.y=e.clientY)}},{target:g,event:"pointerup",func:e=>{_.delete(e.pointerId)}},{target:g,event:"pointercancel",func:e=>{_.delete(e.pointerId)}}),g.addEventListener("pointerup",t=>{if("zoomed"===g._state.state)return;if("touch"===t.pointerType&&(g._state.skipOpenTouchPointerUps||0)>0)return void g._state.skipOpenTouchPointerUps--;const o=performance.now(),a=null!=t.target.closest(".popupable-next-container, .popupable-prev-container");if(U&&o-q<250)return void(q=o);if(a?(U=!0,q=o):(U=!1,q=o),0!==t.button||!((t.target.classList.contains("popupable-clone")||t.target.classList.contains("popupable-clone-layer"))&&n.classList.contains("popupable-clone-container")||t.target==n&&(t.target.closest(".popupable-clone-container")||t.target.classList.contains("popupable-viewport")||t.target.classList.contains("popupable-container"))||t.target.classList.contains("popupable-container")&&n===e.original.parentElement))return;const i=g._state,s=i.group?i.group[i.group.currentIndex]:i;i.blocked&&(i.blocked=!1),"open"!==i.state?(t.stopPropagation(),e!==i&&(closePopupable(),e=i),openPopupable(e)):requestAnimationFrame(()=>{i.blocked?i.blocked=!1:s.zoomable&&(t.target.classList.contains("popupable-clone")||t.target.classList.contains("popupable-clone-layer"))?j(i,s,t,2):closePopupable()})})}),document.addEventListener("keydown",t=>{if("Escape"===t.key||"Backspace"===t.key||" "===t.key||"Delete"===t.key){if("zoomed"===e.state)return void e.unzoom();closePopupable()}}),window.addEventListener("resize",updateExpandedSize),visualViewport&&visualViewport.addEventListener("resize",updateExpandedSize)}
|
|
7
|
+
{let e,t,n,o=0;const a=3;let i,r,s,l;function triggerHaptic(){if("function"!=typeof navigator.vibrate){if(!i){i=document.createElement("label"),i.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;pointer-events:none";const e=document.createElement("input");e.type="checkbox",e.setAttribute("switch",""),i.append(e),document.body.append(i)}i.click()}else navigator.vibrate([10])}function disableScroll(){window.addEventListener("wheel",prevent,{passive:!1}),window.addEventListener("touchmove",prevent,{passive:!1}),window.addEventListener("keydown",blockKeys,!0)}function enableScroll(){window.removeEventListener("wheel",prevent),window.removeEventListener("touchmove",prevent),window.removeEventListener("keydown",blockKeys,!0)}function prevent(e){e.preventDefault()}function blockKeys(e){["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "].includes(e.key)&&e.preventDefault()}function calcExpandedRect(t){const n=t.original,o=visualViewport?.width||window.innerWidth,a=visualViewport?.height||window.innerHeight,i=visualViewport?.offsetTop||0,r=visualViewport?.offsetLeft||0,s=visualViewport?.scale||1,l=1/s,p=e.popup,c=(parseFloat(getComputedStyle(p).getPropertyValue("--popupable-screen-padding"))||40)/s,u=Math.max(0,o-2*c),d=a-2*c,b=Math.max(0,d);let f;if(t.maintainAspect){const e=n.getBoundingClientRect();f=e.width/e.height}else{const e=t.cloneLayer||n;f=e.naturalWidth/e.naturalHeight||1}let m=0,h=0;if(e.orderPlacement){const n=e.popup.querySelector(".popupable-counter"),o=n?n.getBoundingClientRect().height/l:0,a=e.thumbnailsContainer?e.thumbnailsContainer.getBoundingClientRect().height/l:0,i=e.contentContainer,r=t.content?t.content.getBoundingClientRect().height/l:i?.previousElementSibling&&i?.nextElementSibling&&parseFloat(getComputedStyle(i,"::after").height)||0,{counterTop:s,contentTop:p,thumbnailsTop:c,counterBottom:u,contentBottom:d,thumbnailsBottom:b}=e.orderPlacement;m=(s?o:0)+(p?r:0)+(c?a:0),h=(u?o:0)+(d?r:0)+(b?a:0)}const v=Math.max(0,a-m-h-2*c);let g=u,y=g/f;if(y>b&&(y=b,g=y*f),y>v&&(y=v,g=y*f),t.noUpscale){const e=t.cloneLayer||n,o=e.naturalWidth,a=e.naturalHeight;if(o&&a){const e=o/s,t=a/s,n=Math.min(1,e/g,t/y);n<1&&(g*=n,y*=n)}}let w=i+c+(b-y)/2;const L=i+a-h-c-y;return w=Math.min(w,L),w=Math.max(w,i+m+c),{top:w,left:r+c+(u-g)/2,width:g,height:y}}function setCloneToOriginalRect(t,n){const o=calcExpandedRect(e),a=popupableAnimTypes[e.animation](n,o);return t.style.top=a.top+"px",t.style.left=a.left+"px",t.style.width=a.width+"px",t.style.height=a.height+"px",a}function openPopupable(e){if("open"===e.state)return;e.state="open",triggerHaptic();const{cloneContainer:t,popup:n,transition:o,group:a,listeners:i}=e;n.classList.add("popupable-active"),e.clearNavInactive?.(),updateExpandedSize(),e.closingContainer?.removeEventListener("transitionend",o.listener);const r=e.closingContainer??t;o.listener=t=>{if(!t||t.target===t.currentTarget){if(r.removeEventListener("transitionend",o.listener),n.classList.add("popupable-open"),a)for(const e of a)e.cloneContainer.style.display=null;for(const e of i)e.target.addEventListener(e.event,e.func,e.args);e.scheduleNavHide?.()}},o.duration?r.addEventListener("transitionend",o.listener):o.listener()}function closePopupable(){if(!e||"close"===e.state)return;o++,e.state="close",document.body.classList.add("popupable-block-touch"),setTimeout(()=>document.body.classList.remove("popupable-block-touch"),300);const{cloneContainer:n,original:a,popup:i,transition:r,group:s,listeners:l}=e;a.classList.remove("popupable-loading"),i.classList.remove("popupable-active"),i.classList.remove("popupable-open");const p=s?s[s.currentIndex].cloneContainer:n;if(e.closingContainer=p,setCloneToOriginalRect(p,a),s)for(const e of s)e.cloneContainer!==p&&(e.cloneContainer.style.display="none");for(const e of l)e.target.removeEventListener(e.event,e.func);n.removeEventListener("transitionend",r.listener);const c=e;r.listener=n=>{n&&n.target!==n.currentTarget||(p.removeEventListener("transitionend",r.listener),a.classList.remove("popupable-hide"),i.remove(),c===e&&(enableScroll(),t=e,e=null))},r.duration?p.addEventListener("transitionend",r.listener):r.listener()}function updateExpandedSize(){if(!e||"close"===e.state)return;const t=visualViewport?.width||window.innerWidth,n=visualViewport?.height||window.innerHeight,o=visualViewport?.offsetTop||0,a=visualViewport?.offsetLeft||0,i=visualViewport?.scale||1;document.documentElement.style.setProperty("--popupable-view-width",t+"px"),e.popup.style.setProperty("--popupable-vv-width",t+"px"),e.popup.style.setProperty("--popupable-vv-height",n+"px"),e.popup.style.setProperty("--popupable-vv-top",o+"px"),e.popup.style.setProperty("--popupable-vv-left",a+"px"),e.popup.style.setProperty("--popupable-vv-scale",i),e.popup.style.setProperty("--popupable-vv-ui-scale",1/i);const r=1/i;let s;s=e.group?e.group:[e];for(const e of s){const{top:t,left:n,width:o,height:a}=calcExpandedRect(e);e.cloneContainer.style.top=t+"px",e.cloneContainer.style.left=n+"px",e.cloneContainer.style.width=o+"px",e.cloneContainer.style.height=a+"px"}if(e.contentContainer){let t;if(t=e.group?e.group[e.group.currentIndex]:e,t.content){const n=t.content.getBoundingClientRect();e.contentContainer.style.height=n.height/r+"px"}else{const t=e.contentContainer,n=t.previousElementSibling&&t.nextElementSibling&&parseFloat(getComputedStyle(t,"::after").height)||0;t.style.height=n+"px"}}}function parsePopupableOrder(e){const t=["counter","image","content","thumbnails"],n=new Set(t),o=[];if(e)for(const t of e.split(",")){const e=t.trim().toLowerCase();e&&n.has(e)&&!o.includes(e)&&o.push(e)}for(const e of t)o.includes(e)||o.push(e);const a=o.indexOf("image");return{top:o.slice(0,a),bottom:o.slice(a+1)}}function cloneElement(e,t){const n=document.createElement("div");n.className="popupable-clone-container",e.hasAttribute("data-popupable-transparent")&&n.classList.add("popupable-transparent");const o=new Image;o.className="popupable-clone",o.src=t??e.currentSrc??e.src;const a=getComputedStyle(e);let i,r,s;if(n.style.borderRadius=a.borderRadius,o.style.objectFit=a.objectFit,o.style.objectPosition=a.objectPosition,o.style.imageRendering=a.imageRendering,o.style.background=a.background,n.append(o),(e.dataset.popupableSrc||t)&&(i=new Image,i.className="popupable-clone-layer",i.src=e.dataset.popupableSrc||e.currentSrc||e.src,i.style.imageRendering=a.imageRendering,n.append(i),"fill"===o.style.objectFit)){const t=e.getBoundingClientRect();e.naturalWidth&&e.naturalHeight&&Math.abs(t.width/t.height-e.naturalWidth/e.naturalHeight)<.01&&(o.style.objectFit="cover")}if(e.dataset.popupableTitle||e.dataset.popupableDescription){if(r=document.createElement("div"),r.classList="popupable-content",e.dataset.popupableTitle){const t=document.createElement("div");t.className="popupable-title",t.textContent=e.dataset.popupableTitle,r.append(t)}if(e.dataset.popupableDescription){const t=document.createElement("div");t.className="popupable-description",t.textContent=e.dataset.popupableDescription,r.append(t)}}return e.hasAttribute("data-popupable-zoomable")&&(s=!0,n.classList.add("popupable-zoomable")),{id:e.dataset.popupable,original:e,cloneContainer:n,clone:o,cloneLayer:i,maintainAspect:e.hasAttribute("data-popupable-maintain-aspect"),noUpscale:e.hasAttribute("data-popupable-no-upscale"),counter:e.hasAttribute("data-popupable-counter"),thumbnails:e.hasAttribute("data-popupable-thumbnails"),order:parsePopupableOrder(e.dataset.popupableOrder),animation:popupableAnimTypes[e.dataset.popupableAnim]?e.dataset.popupableAnim:"expand",ready:Promise.all([o,i].filter(Boolean).map(e=>e.decode().catch(()=>{}))),content:r,zoomable:s}}function handleMove(t){if("open"!==e?.state||!e.group||!r)return;if(!e.popup?.classList.contains("popupable-open"))return s=t.touches?.[0].clientX??t.clientX,void(l=t.touches?.[0].clientY??t.clientY);const n=e.group[e.group.currentIndex];n.cloneContainer.parentElement.style.transition="initial",n.cloneContainer.parentElement.style.transform=`translateX(${(t.touches?.[0].clientX??t.clientX)-s}px)`}window.popupableAnimTypes={expand(e){const t=e.getBoundingClientRect();return{top:visualViewport.offsetTop+t.top,left:visualViewport.offsetLeft+t.left,width:t.width,height:t.height,hideSource:!0,crossfade:!0}},pop:(e,{top:t,left:n,width:o,height:a})=>({top:t+.05*a,left:n+.05*o,width:.9*o,height:.9*a,fade:!0}),line:(e,{top:t,left:n,width:o,height:a})=>({top:t+a/2,left:n+.05*o,width:.9*o,height:0,fade:!0}),float:(e,{top:t,left:n,width:o,height:a})=>({top:t+40,left:n,width:o,height:a,fade:!0})},document.addEventListener("pointerdown",t=>{0===t.button&&(r||(n=t.target,s=t.clientX,l=t.clientY),r||"open"!==e?.state||t.target.closest(".popupable-header, .popupable-footer")||(r=!0))}),document.addEventListener("mousemove",handleMove),document.addEventListener("touchmove",handleMove,{passive:!0}),document.addEventListener("pointerup",async i=>{if(0!==i.button)return;if(r){r=!1;const K=e.group?e.group[e.group.currentIndex]:e;K.cloneContainer.parentElement.style.transition=null,K.cloneContainer.parentElement.style.transform=null;const Z=i.clientX-s,G=Math.abs(Z),J=i.clientY-l,Q=Math.abs(J);if("touch"===i.pointerType&&Q>56&&Q>1.1*G)return void closePopupable();if(e.group&&G>a){const ee=Math.max(0,Math.floor((G-window.innerWidth/2)/window.innerWidth));if(Z>32)for(let te=0;te<=ee;te++)e.goPrev();else if(Z<-32)for(let ne=0;ne<=ee;ne++)e.goNext();return void(e.blocked=!0)}}const p=i.target.closest(".popupable-viewport")&&!n.closest(".popupable-viewport");if(!p&&i.target!=n&&(!n.classList.contains("popupable-clone-container")||i.target!==t?.original)&&(!n.closest(".popupable-container")||i.target.closest(".popupable-container"))||Math.abs(i.clientX-s)>a||Math.abs(i.clientY-l)>a)return;const c=(p?n.closest("[data-popupable]"):null)||i.target.closest("[data-popupable]");if(!c){if(p)return void closePopupable();if(i.target.closest(".popupable-container"))return;return void(e&&("zoomed"===e.state?e.unzoom():closePopupable()))}if(i.preventDefault(),e&&"close"!==e.state&&e.original===c)return;e&&closePopupable();const u=++o;e={transition:{},listeners:[]};const d=e,b=document.createElement("div");b.className="popupable-clones";const f=cloneElement(c),{cloneContainer:m,content:h}=f;let v;if(c.dataset.popupableGroup){const oe=document.querySelectorAll(`[data-popupable-group="${c.dataset.popupableGroup}"]`);if(oe.length){v=[];for(const[ae,ie]of oe.entries())if(ie===c)v.push(f),v.currentIndex=ae,b.append(m);else{const re=cloneElement(ie,c.currentSrc??c.src);re.cloneContainer.style.display="none",v.push(re),b.append(re.cloneContainer)}for(const[se,le]of v.entries()){if(!le.content)continue;const pe=se-v.currentIndex;pe>0?le.content.classList.add("popupable-content-after"):pe<0&&le.content.classList.add("popupable-content-before")}}}else b.append(m);const g=document.createElement("div");g.className=`popupable-container popupable-anim-${f.animation}`,f.id&&(g.id=f.id);const y=document.createElement("div");let w,L,x,C,E,I,P,M,z,k,T;y.className="popupable-viewport",(h||v&&v.some(e=>e.content))&&(w=document.createElement("div"),w.classList="popupable-content-container");const S={};if(v){f.counter&&(C=document.createElement("div"),C.className="popupable-counter"),f.thumbnails&&(E=document.createElement("div"),E.className="popupable-thumbnails",I=v.map((e,t)=>{const n=new Image;return n.className="popupable-thumbnail",n.src=e.original.currentSrc??e.original.src,n.dataset.thumbnailIndex=t,E.append(n),n})),y.innerHTML=`\n <div class="popupable-button-container popupable-prev-container${v.currentIndex?"":" popupable-button-disabled"}">\n <div class="popupable-button popupable-prev">\n <svg width="24px" height="24px" viewBox="0 -960 960 960" fill="currentColor">\n <path d="m313-440 224 224-57 56-320-320 320-320 57 56-224 224h487v80H313Z"/>\n </svg>\n </div>\n </div>\n <div class="popupable-button-container popupable-next-container${v.currentIndex===v.length-1?" popupable-button-disabled":""}">\n <div class="popupable-button popupable-next">\n <svg width="24px" height="24px" viewBox="0 -960 960 960" fill="currentColor">\n <path d="M647-440H160v-80h487L423-744l57-56 320 320-320 320-57-56 224-224Z"/>\n </svg>\n </div>\n </div>\n `;const ce=y.querySelector(".popupable-next-container"),ue=y.querySelector(".popupable-prev-container");let de,be,fe,me;const he=!(navigator.maxTouchPoints>0||window.matchMedia("(hover: none)").matches);function X(){ce.classList.remove("popupable-button-inactive"),ue.classList.remove("popupable-button-inactive"),e.scheduleNavHide()}if(e.scheduleNavHide=()=>{he&&(clearTimeout(de),me||(de=setTimeout(()=>{me||(ce.classList.add("popupable-button-inactive"),ue.classList.add("popupable-button-inactive"))},1500)))},e.clearNavInactive=()=>{ce.classList.remove("popupable-button-inactive"),ue.classList.remove("popupable-button-inactive")},T=async()=>{const t=v[v.currentIndex];await t.ready,v.currentIndex?ue.classList.remove("popupable-button-disabled"):ue.classList.add("popupable-button-disabled"),v.currentIndex===v.length-1?ce.classList.add("popupable-button-disabled"):ce.classList.remove("popupable-button-disabled");for(const[e,t]of v.entries()){const n=e-v.currentIndex;t.cloneContainer.style.setProperty("--popupable-offset-multiplier",n),t.cloneContainer.style.zIndex=-1*Math.abs(n),t.content&&(n?n>0?(t.content.classList.add("popupable-content-after"),t.content.classList.remove("popupable-content-before")):(t.content.classList.add("popupable-content-before"),t.content.classList.remove("popupable-content-after")):(t.content.classList.remove("popupable-content-before"),t.content.classList.remove("popupable-content-after")))}if(t.id?g.id=t.id:g.removeAttribute("id"),C&&(C.textContent=`${v.currentIndex+1} / ${v.length}`),I){for(const[e,t]of I.entries())t.classList.toggle("popupable-thumbnail-active",e===v.currentIndex);const e=I[v.currentIndex];requestAnimationFrame(()=>{if(!e||!E?.isConnected)return;const t=getComputedStyle(E),n=parseFloat(t.paddingLeft)||0,o=parseFloat(t.paddingRight)||0,a=E.scrollLeft+n,i=E.scrollLeft+E.clientWidth-o,r=e.offsetLeft,s=r+e.offsetWidth;let l=E.scrollLeft;r<a?l=Math.max(0,r-n):s>i&&(l=s-E.clientWidth+o),l!==E.scrollLeft&&(P?E.scrollTo({left:l,behavior:"smooth"}):E.scrollLeft=l),P=!0})}e.closeContainer.classList.toggle("popupable-button-inactive",!t.zoomable),updateExpandedSize()},M=()=>{v.currentIndex>=v.length-1||(v.currentIndex++,T())},z=()=>{v.currentIndex<=0||(v.currentIndex--,T())},e.listeners.push({target:ce,event:"click",func:()=>M()},{target:ue,event:"click",func:()=>z()},{target:document,event:"keydown",func:t=>{if("zoomed"!==e.state)switch(t.key){case"ArrowRight":case"ArrowDown":case"PageDown":case"d":case"s":M();break;case"ArrowLeft":case"ArrowUp":case"PageUp":case"a":case"w":z();break;case"Home":v.currentIndex=0,T();break;case"End":v.currentIndex=v.length-1,T();break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":v.currentIndex=Math.min(Math.max(Number(t.key),1)-1,v.length-1),T()}}},{target:document,event:"wheel",func:t=>{if("zoomed"===e.state)return;const n=performance.now();n-(k||0)<80||(t.deltaY>50?(k=n,M()):t.deltaY<-50&&(k=n,z()))},args:{passive:!0}}),E){let ve,ge,ye,we,Le,xe,Ce,Ee,Ie;function A(){Ie&&(cancelAnimationFrame(Ie),Ie=null)}function N(){if(A(),Math.abs(Ee)<.01)return;let e=performance.now();Ie=requestAnimationFrame(function t(n){if(!E.isConnected)return void A();const o=E.scrollWidth-E.clientWidth;if(o<=0)return void A();const a=Math.min(32,n-e);e=n;let i=E.scrollLeft+Ee*a;i<0&&(i=0),i>o&&(i=o),E.scrollLeft=i,E.scrollLeft<=.1&&Ee<0||E.scrollLeft>=o-.1&&Ee>0?A():(Ee*=Math.pow(.8,a/16.67),Math.abs(Ee)<=.002?A():Ie=requestAnimationFrame(t))})}e.listeners.push({target:E,event:"pointerdown",func:e=>{if(0!==e.button)return;const t=E.scrollWidth-E.clientWidth;ye=t>0,A(),ve=!0,ge=!1,we=e.clientX,Le=E.scrollLeft,xe=E.scrollLeft,Ce=performance.now(),Ee=0,ye&&E.classList.add("popupable-thumbnails-dragging"),E.setPointerCapture(e.pointerId)}},{target:E,event:"pointermove",func:e=>{if(!ve)return;const t=e.clientX-we;Math.abs(t)>a&&(ge=!0);const n=performance.now(),o=n-Ce,i=Le-t;if(E.scrollLeft=i,o>0){const e=(E.scrollLeft-xe)/o;Ee=.65*Ee+.35*e,xe=E.scrollLeft,Ce=n}}},{target:E,event:"pointerup",func:e=>{if(!ve)return;if(ve=!1,ye&&E.classList.remove("popupable-thumbnails-dragging"),E.hasPointerCapture(e.pointerId)&&E.releasePointerCapture(e.pointerId),ge)return performance.now()-Ce>10&&(Ee=0),void N();const t=document.elementFromPoint(e.clientX,e.clientY)?.closest?.(".popupable-thumbnail");t&&(v.currentIndex=Number(t.dataset.thumbnailIndex),T())}},{target:E,event:"pointercancel",func:e=>{ve&&(ve=!1,ye&&E.classList.remove("popupable-thumbnails-dragging"),E.hasPointerCapture(e.pointerId)&&E.releasePointerCapture(e.pointerId),A())}},{target:E,event:"wheel",func:e=>{e.stopPropagation(),e.preventDefault();const t=E.scrollWidth-E.clientWidth;if(t<=0)return;const n=Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.deltaY,o=E.scrollLeft<=.1,a=E.scrollLeft>=t-.1;if(o&&n<0||a&&n>0)return;o&&n>0&&Ee<0&&(Ee=0),a&&n<0&&Ee>0&&(Ee=0);Ee=(Ee||0)+.015*n,Ie||N()},args:{passive:!1}})}he&&(e.listeners.push({target:ce,event:"pointerenter",func:()=>{me=!0,X()}},{target:ue,event:"pointerenter",func:()=>{me=!0,X()}},{target:ce,event:"pointerleave",func:()=>{me=!1,e.scheduleNavHide()}},{target:ue,event:"pointerleave",func:()=>{me=!1,e.scheduleNavHide()}}),e.listeners.push({target:g,event:"pointermove",func:t=>{if("zoomed"!==e.state)return null==be||null==fe?(be=t.clientX,void(fe=t.clientY)):void(Math.abs(t.clientX-be)<a&&Math.abs(t.clientY-fe)<a||(be=t.clientX,fe=t.clientY,X()))},args:{passive:!0}}));for(const Pe of v)Pe.content&&w&&w.append(Pe.content)}else h&&w.append(h);const Y={counter:!!C,content:!!w,thumbnails:!!E},R=f.order.top.filter(e=>Y[e]),B=f.order.bottom.filter(e=>Y[e]);function H(e,t){e&&("counter"===t&&C?(S[e===L?"counterTop":"counterBottom"]=!0,e.append(C)):"content"===t&&w?(S[e===L?"contentTop":"contentBottom"]=!0,e.append(w)):"thumbnails"===t&&E&&(S[e===L?"thumbnailsTop":"thumbnailsBottom"]=!0,e.append(E)))}L=document.createElement("div"),L.className="popupable-header",x=document.createElement("div"),x.className="popupable-footer";for(const Me of R)H(L,Me);for(const ze of B)H(x,ze);y.append(L),y.append(x);const D=document.createElement("div");D.className="popupable-button-container popupable-close-container",D.innerHTML='<div class="popupable-button popupable-close"><svg width="24px" height="24px" viewBox="0 -960 960 960" fill="currentColor"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg></div>',D.addEventListener("click",closePopupable),f.zoomable||D.classList.add("popupable-button-inactive"),L.append(D),g.append(b,y),Object.assign(d,f,{popup:g,group:v,contentContainer:w,thumbnailsContainer:E,orderPlacement:S,closeContainer:D,goNext:M,goPrev:z});const F=setTimeout(()=>{u===o&&c.classList.add("popupable-loading")},250);if(await d.ready,clearTimeout(F),c.classList.remove("popupable-loading"),u!==o||e!==d||"close"===d.state)return;m.style.transition="initial",document.body.append(g);const{hideSource:W,crossfade:V,fade:O}=setCloneToOriginalRect(m,c);W&&c.classList.add("popupable-hide"),V&&g.classList.add("popupable-crossfade"),O&&g.classList.add("popupable-fade"),disableScroll();const $=getComputedStyle(g);d.transition.duration=1e3*parseFloat($.transitionDuration)+1e3*parseFloat($.transitionDelay),g._state=d,m.style.transition=null,openPopupable(g._state),v&&T();let U,q=0;v&&g.addEventListener("dragstart",e=>e.preventDefault());const _=new Map;function j(e,t,n,o,i=[]){if("open"!==e.state)return;let s=0;const l=t.cloneContainer.parentElement,p=l.style.transform;if(p){const e=p.match(/translateX\((-?\d+(?:\.\d+)?)px\)/);e&&(s=Number(e[1])||0)}const c=Math.abs(s)>.5;r=!1,c?(t.cloneContainer.style.translate="0 0",t.cloneContainer.style.transition="translate var(--popupable-switch-duration), transform 0s",l.style.transition=null,l.style.transform=null,t.cloneContainer.style.translate=`${s}px 0`):(l.style.transition=null,l.style.transform=null),e.state="zoomed",g.classList.add("popupable-locked");let u,d,b=o;const f=new Map;let m,h,v,w,L,x,C,E,I,P,M=!1;const z=t.cloneContainer.getBoundingClientRect(),k=n?.clientX??z.left+z.width/2,T=n?.clientY??z.top+z.height/2;u=(k-z.left)*(1-b),d=(T-z.top)*(1-b);const S=()=>t.cloneContainer.style.transform=`translate(${u}px, ${d}px) scale(${b})`;function X(e,n,o){const a=b;var i;if(i=e,b=Math.min(6,Math.max(.5,i)),b===a)return!1;const r=t.cloneContainer.getBoundingClientRect(),s=b/a,l=n-r.left,p=o-r.top;return u+=l*(1-s),d+=p*(1-s),!0}function A(){if(1===f.size){const e=f.values().next().value;return m=e.id,h=e.x,v=e.y,w=null,L=null,void(x=null)}if(f.size>=2){m=null;const[e,t]=[...f.values()];return w=(e.x+t.x)/2,L=(e.y+t.y)/2,void(x=Math.hypot(t.x-e.x,t.y-e.y))}m=null,h=null,v=null,w=null,L=null,x=null}if(t.cloneContainer.classList.add("popupable-zoomed"),S(),i.length){c||(t.cloneContainer.style.transition="none"),P=!0;for(const e of i)f.set(e.id,{id:e.id,x:e.x,y:e.y}),g.setPointerCapture(e.id);A()}e.unzoom=()=>{e.state="open",g.classList.remove("popupable-locked");for(const e of f.keys())g.hasPointerCapture(e)&&g.releasePointerCapture(e);f.clear(),t.cloneContainer.classList.remove("popupable-zoomed"),t.cloneContainer.style.transition=null,t.cloneContainer.style.transform=null,t.cloneContainer.style.translate=null;for(const t of e.zoomListeners)t.target.removeEventListener(t.event,t.func)},e.zoomListeners=[{target:g,event:"pointerdown",func:e=>{0===e.button&&(t.cloneContainer.style.transition="none",g.setPointerCapture(e.pointerId),f.set(e.pointerId,{id:e.pointerId,x:e.clientX,y:e.clientY}),1===f.size?(C=e.target,E=e.clientX,I=e.clientY,P=!1):P=!0,A(),e.preventDefault())}},{target:g,event:"pointermove",func:e=>{const t=f.get(e.pointerId);if(t){if(t.x=e.clientX,t.y=e.clientY,!P&&(Math.abs(e.clientX-E)>a||Math.abs(e.clientY-I)>a)&&(P=!0),1===f.size&&m===e.pointerId){const t=e.clientX-h,n=e.clientY-v;if(!t&&!n)return;return u+=t,d+=n,h=e.clientX,v=e.clientY,void S()}if(f.size>=2){const[e,t]=[...f.values()],n=(e.x+t.x)/2,o=(e.y+t.y)/2,a=Math.hypot(t.x-e.x,t.y-e.y);if(!x)return w=n,L=o,void(x=a);u+=n-w,d+=o-L,X(b*(a/x),n,o),M=!0,w=n,L=o,x=a,S()}}}},{target:g,event:"pointerup",func:n=>{if(f.has(n.pointerId)){if(f.delete(n.pointerId),g.hasPointerCapture(n.pointerId)&&g.releasePointerCapture(n.pointerId),M&&b<=1.01&&f.size<2)return e.skipOpenTouchPointerUps=f.size,void e.unzoom();if(!f.size&&!P&&Math.abs(n.clientX-E)<a&&Math.abs(n.clientY-I)<a){if(C?.closest?.(".popupable-clone-container")===t.cloneContainer||(C===g||C===y))return void e.unzoom()}A()}}},{target:g,event:"pointercancel",func:e=>{f.has(e.pointerId)&&(f.delete(e.pointerId),g.hasPointerCapture(e.pointerId)&&g.releasePointerCapture(e.pointerId),A())}},{target:g,event:"wheel",func:e=>{t.cloneContainer.style.transition="none",X(b*Math.exp(.002*-e.deltaY),e.clientX,e.clientY)&&S()},args:{passive:!0}}];for(const t of e.zoomListeners)t.target.addEventListener(t.event,t.func,t.args)}e.listeners.push({target:g,event:"pointerdown",func:e=>{if("open"!==g._state.state||"touch"!==e.pointerType)return;const t=g._state,n=t.group?t.group[t.group.currentIndex]:t;e.target.closest(".popupable-clone-container")===n.cloneContainer&&(_.set(e.pointerId,{id:e.pointerId,x:e.clientX,y:e.clientY}),_.size>=2&&(j(t,n,e,1,[..._.values()].slice(0,2)),_.clear(),e.preventDefault()))}},{target:g,event:"pointermove",func:e=>{const t=_.get(e.pointerId);t&&(t.x=e.clientX,t.y=e.clientY)}},{target:g,event:"pointerup",func:e=>{_.delete(e.pointerId)}},{target:g,event:"pointercancel",func:e=>{_.delete(e.pointerId)}}),g.addEventListener("pointerup",t=>{if("zoomed"===g._state.state)return;if("touch"===t.pointerType&&(g._state.skipOpenTouchPointerUps||0)>0)return void g._state.skipOpenTouchPointerUps--;const o=performance.now(),a=null!=t.target.closest(".popupable-next-container, .popupable-prev-container");if(U&&o-q<250)return void(q=o);if(a?(U=!0,q=o):(U=!1,q=o),0!==t.button||!((t.target.classList.contains("popupable-clone")||t.target.classList.contains("popupable-clone-layer"))&&n.classList.contains("popupable-clone-container")||t.target==n&&(t.target.closest(".popupable-clone-container")||t.target.classList.contains("popupable-viewport")||t.target.classList.contains("popupable-container"))||t.target.classList.contains("popupable-container")&&n===e.original.parentElement))return;const i=g._state,r=i.group?i.group[i.group.currentIndex]:i;i.blocked&&(i.blocked=!1),"open"!==i.state?(t.stopPropagation(),e!==i&&(closePopupable(),e=i),openPopupable(e)):requestAnimationFrame(()=>{i.blocked?i.blocked=!1:r.zoomable&&(t.target.classList.contains("popupable-clone")||t.target.classList.contains("popupable-clone-layer"))?j(i,r,t,2):closePopupable()})})}),document.addEventListener("keydown",t=>{if("Escape"===t.key||"Backspace"===t.key||" "===t.key||"Delete"===t.key){if("zoomed"===e.state)return void e.unzoom();closePopupable()}}),window.addEventListener("resize",updateExpandedSize),visualViewport&&visualViewport.addEventListener("resize",updateExpandedSize)}
|