popupable 1.2.0 → 1.4.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 +52 -7
- package/dist/popupable.min.css +2 -2
- package/dist/popupable.min.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,13 +13,14 @@ Just add `data-popupable` to any image!
|
|
|
13
13
|
|
|
14
14
|
* No dependencies
|
|
15
15
|
* Animates open from the element's original position
|
|
16
|
+
* Multiple built-in animation styles, with support for custom ones
|
|
16
17
|
* Works with mouse, touch, and keyboard
|
|
17
18
|
* Gallery groups with swipe, scroll, keyboard, and button navigation
|
|
18
19
|
* Thumbnail strip and image counter
|
|
19
20
|
* Pinch-to-zoom on touch, with optional click/tap-to-zoom support
|
|
20
|
-
* Load a hi-res image on open
|
|
21
21
|
* Checkerboard background for transparent images
|
|
22
22
|
* Customizable via CSS variables
|
|
23
|
+
* Works in Vue, React, Svelte, and more
|
|
23
24
|
|
|
24
25
|
## Quick Start
|
|
25
26
|
|
|
@@ -58,10 +59,11 @@ Close by clicking again, or pressing Escape, Backspace, or Delete.
|
|
|
58
59
|
| `data-popupable-maintain-aspect` | Uses the element's rendered aspect ratio instead of the image's natural dimensions. |
|
|
59
60
|
| `data-popupable-no-upscale` | Prevents the popup from scaling the image beyond its native resolution. |
|
|
60
61
|
| `data-popupable-zoomable` | Enables click/tap-to-zoom and scroll wheel zoom. |
|
|
62
|
+
| `data-popupable-anim="name"` | Sets the open/close animation style. |
|
|
61
63
|
| `data-popupable-group="name"` | Groups images into a navigable gallery. |
|
|
62
64
|
| `data-popupable-counter` | Shows a "1 / N" counter when in a group. Read from the clicked image. |
|
|
63
65
|
| `data-popupable-thumbnails` | Shows a thumbnail strip when in a group. Read from the clicked image. |
|
|
64
|
-
| `data-popupable-order="..."` | Controls the order of UI elements.
|
|
66
|
+
| `data-popupable-order="..."` | Controls the order of UI elements. |
|
|
65
67
|
|
|
66
68
|
## Advanced Usage
|
|
67
69
|
|
|
@@ -105,7 +107,7 @@ All images support pinch-to-zoom. Add `data-popupable-zoomable` to also enable t
|
|
|
105
107
|
<img src="map.jpg" data-popupable data-popupable-zoomable>
|
|
106
108
|
```
|
|
107
109
|
|
|
108
|
-
When zoomed in, pan by dragging and zoom in/out with the scroll wheel. Click the image or background, or pinch back to scale 1, to unzoom.
|
|
110
|
+
When zoomed in, pan by dragging and zoom in/out with the scroll wheel. Click the image or background, or pinch back to scale 1, to unzoom. A close button also appears in the corner when `data-popupable-zoomable` is set.
|
|
109
111
|
|
|
110
112
|
### Groups / Galleries
|
|
111
113
|
|
|
@@ -117,7 +119,7 @@ Group multiple images together with `data-popupable-group`. Users can navigate w
|
|
|
117
119
|
<img src="photo3.jpg" data-popupable data-popupable-group="holiday">
|
|
118
120
|
```
|
|
119
121
|
|
|
120
|
-
###Counter and thumbnails
|
|
122
|
+
### Counter and thumbnails
|
|
121
123
|
|
|
122
124
|
Add `data-popupable-counter` and/or `data-popupable-thumbnails` to individual group members. The attributes are read from whichever image is clicked to open the gallery, so add them to every image that should show these elements:
|
|
123
125
|
|
|
@@ -127,7 +129,7 @@ Add `data-popupable-counter` and/or `data-popupable-thumbnails` to individual gr
|
|
|
127
129
|
<img src="photo3.jpg" data-popupable data-popupable-group="holiday" data-popupable-counter data-popupable-thumbnails>
|
|
128
130
|
```
|
|
129
131
|
|
|
130
|
-
###Custom UI order
|
|
132
|
+
### Custom UI order
|
|
131
133
|
|
|
132
134
|
Control the order of UI elements around the image with `data-popupable-order`. The `image` token marks where the image sits; everything before it goes in the header, everything after goes in the footer.
|
|
133
135
|
|
|
@@ -138,7 +140,7 @@ Control the order of UI elements around the image with `data-popupable-order`. T
|
|
|
138
140
|
|
|
139
141
|
Default order: `counter,image,content,thumbnails`
|
|
140
142
|
|
|
141
|
-
###Keyboard navigation
|
|
143
|
+
### Keyboard navigation
|
|
142
144
|
|
|
143
145
|
| Keys | Action |
|
|
144
146
|
|---|---|
|
|
@@ -164,6 +166,47 @@ Set the value of `data-popupable` to give the popup a CSS `id`, useful for per-p
|
|
|
164
166
|
#theme-blue { --popupable-background: #00003acc; }
|
|
165
167
|
```
|
|
166
168
|
|
|
169
|
+
### Animation styles
|
|
170
|
+
|
|
171
|
+
Use `data-popupable-anim` to choose an open/close animation style. The default is `expand`.
|
|
172
|
+
|
|
173
|
+
| Value | Description |
|
|
174
|
+
|---|---|
|
|
175
|
+
| `expand` | Expands from the image's original position (default) |
|
|
176
|
+
| `pop` | Scales up from a slightly smaller version at the final position |
|
|
177
|
+
| `line` | Expands vertically from a thin horizontal line at the center, like a CRT TV powering on |
|
|
178
|
+
| `float` | Fades in while rising upward into position |
|
|
179
|
+
|
|
180
|
+
```html
|
|
181
|
+
<img src="photo.jpg" data-popupable data-popupable-anim="line">
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The popup container receives a `popupable-anim-{name}` class (e.g. `popupable-anim-float`), which can be used to apply custom CSS for that animation style.
|
|
185
|
+
|
|
186
|
+
#### Custom animation styles
|
|
187
|
+
|
|
188
|
+
Register your own animation style by adding a function to `window.popupableAnimTypes`. The function receives the original element and the final expanded rect `{ top, left, width, height }`, and returns an object describing the starting rect for the open animation (which is also the ending rect for close).
|
|
189
|
+
|
|
190
|
+
| Return property | Type | Description |
|
|
191
|
+
|---|---|---|
|
|
192
|
+
| `top` | number | Starting top position in pixels |
|
|
193
|
+
| `left` | number | Starting left position in pixels |
|
|
194
|
+
| `width` | number | Starting width in pixels |
|
|
195
|
+
| `height` | number | Starting height in pixels |
|
|
196
|
+
| `fade` | boolean | Fades opacity in/out alongside the geometry |
|
|
197
|
+
| `crossfade` | boolean | Crossfades between the thumbnail and alternate source image as it opens |
|
|
198
|
+
| `hideSource` | boolean | Hides the original element while the popup is open |
|
|
199
|
+
|
|
200
|
+
```js
|
|
201
|
+
window.popupableAnimTypes.myAnim = (original, rect) => ({
|
|
202
|
+
top: rect.top + rect.height / 2,
|
|
203
|
+
left: rect.left,
|
|
204
|
+
width: rect.width,
|
|
205
|
+
height: 0,
|
|
206
|
+
fade: true
|
|
207
|
+
})
|
|
208
|
+
```
|
|
209
|
+
|
|
167
210
|
## Customization
|
|
168
211
|
|
|
169
212
|
Popups can be styled using CSS variables:
|
|
@@ -182,7 +225,9 @@ Popups can be styled using CSS variables:
|
|
|
182
225
|
|
|
183
226
|
/* Animation */
|
|
184
227
|
--popupable-open-duration: .25s; /* Open/close transition duration */
|
|
228
|
+
--popupable-open-easing: ease; /* Open/close transition easing */
|
|
185
229
|
--popupable-switch-duration: .25s; /* Gallery navigation transition duration */
|
|
230
|
+
--popupable-switch-easing: ease; /* Gallery navigation transition easing */
|
|
186
231
|
}
|
|
187
232
|
```
|
|
188
233
|
|
|
@@ -199,4 +244,4 @@ This gives a seamless visual transition with no layout shifts.
|
|
|
199
244
|
|
|
200
245
|
## License
|
|
201
246
|
|
|
202
|
-
MIT © [Ewan Howell](https://
|
|
247
|
+
MIT © [Ewan Howell](https://ewanhowell.com/)
|
package/dist/popupable.min.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* popupable
|
|
3
|
-
* Version : 1.
|
|
3
|
+
* Version : 1.4.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-switch-duration{syntax:"<time>";inherits:true;initial-value:.25s}[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),backdrop-filter var(--popupable-open-duration);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 *{-webkit-tap-highlight-color:transparent}.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-container *{box-sizing:border-box}.popupable-container.popupable-open,.popupable-container.popupable-open>*{pointer-events:initial}.popupable-clones{transition:transform var(--popupable-switch-duration)}.popupable-clone-container{position:fixed;transition:all var(--popupable-open-duration);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);image-rendering:pixelated}.popupable-container.popupable-active .popupable-clone-container{border-radius:0!important}.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),translate var(--popupable-switch-duration)}.popupable-clone,.popupable-clone-layer{width:100%;height:100%;position:absolute;inset:0;transition:opacity var(--popupable-open-duration)}.popupable-clone-layer{opacity:0;object-fit:cover}.popupable-
|
|
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 *{-webkit-tap-highlight-color:transparent}.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-container *{box-sizing:border-box}.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-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);color:#fff;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;color:#fff;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.4.0
|
|
4
4
|
* License : MIT
|
|
5
5
|
* Copyright: 2026 Ewan Howell
|
|
6
6
|
*/
|
|
7
|
-
{let e,t,n,o=0;const a=3;let r,i,l,s;function triggerHaptic(){if("function"!=typeof navigator.vibrate){if(!r){r=document.createElement("label"),r.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;pointer-events:none";const e=document.createElement("input");e.type="checkbox",e.setAttribute("switch",""),r.append(e),document.body.append(r)}r.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 setCloneToOriginalRect(e,t){const n=t.getBoundingClientRect();e.style.top=visualViewport.offsetTop+n.top+"px",e.style.left=visualViewport.offsetLeft+n.left+"px",e.style.width=n.width+"px",e.style.height=n.height+"px"}function openPopupable(e){if("open"===e.state)return;e.state="open",triggerHaptic();const{cloneContainer:t,popup:n,transition:o,group:a,listeners:r}=e;n.classList.add("popupable-active"),updateExpandedSize(),t.removeEventListener("transitionend",o.listener),o.listener=e=>{if(!e||e.target===e.currentTarget){if(t.removeEventListener("transitionend",o.listener),n.classList.add("popupable-open"),a)for(const e of a)e.cloneContainer.style.display=null;for(const e of r)e.target.addEventListener(e.event,e.func,e.args)}},o.duration?t.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,clone:a,original:r,popup:i,transition:l,group:s,listeners:p}=e;if(r.classList.remove("popupable-loading"),i.classList.remove("popupable-active"),i.classList.remove("popupable-open"),setCloneToOriginalRect(n,r),s)for(const[e,t]of s.entries())t.clone!==a&&e!==s.currentIndex&&(t.cloneContainer.style.display="none");for(const e of p)e.target.removeEventListener(e.event,e.func);n.removeEventListener("transitionend",l.listener);const c=e;l.listener=o=>{o&&o.target!==o.currentTarget||(n.removeEventListener("transitionend",l.listener),r.classList.remove("popupable-hide"),i.remove(),c===e&&(enableScroll(),t=e,e=null))},l.duration?n.addEventListener("transitionend",l.listener):l.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,r=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",r),e.popup.style.setProperty("--popupable-vv-ui-scale",1/r);const i=parseFloat(getComputedStyle(e.popup).getPropertyValue("--popupable-vv-ui-scale"))||1,l=(parseFloat(getComputedStyle(e.popup).getPropertyValue("--popupable-screen-padding"))||0)/r,s=Math.max(0,t-2*l),p=n-2*l,c=e.popup.querySelector(".popupable-counter"),u=c?c.getBoundingClientRect().height/i:0;let d;d=e.group?e.group:[e];for(const t of d){let c;if(t.maintainAspect){const e=t.original.getBoundingClientRect();c=e.width/e.height}else c=t.cloneLayer?t.cloneLayer.naturalWidth/t.cloneLayer.naturalHeight:t.original.naturalWidth/t.original.naturalHeight;const d=Math.max(0,p),f=t.content?t.content.getBoundingClientRect().height/i:0,m=e.thumbnailsContainer?e.thumbnailsContainer.getBoundingClientRect().height/i:0,b=(e.orderPlacement.counterTop?u:0)+(e.orderPlacement.contentTop?f:0)+(e.orderPlacement.thumbnailsTop?m:0),v=(e.orderPlacement.counterBottom?u:0)+(e.orderPlacement.contentBottom?f:0)+(e.orderPlacement.thumbnailsBottom?m:0),g=Math.max(0,n-b-v-2*l);let h=s,y=h/c;if(y>d&&(y=d,h=y*c),y>g&&(y=g,h=y*c),t.noUpscale){const e=t.cloneLayer||t.original,n=e.naturalWidth,o=e.naturalHeight;if(n&&o){const e=n/r,t=o/r,a=Math.min(1,e/h,t/y);a<1&&(h*=a,y*=a)}}let L=o+l+(d-y)/2;const x=o+n-v-l-y;L=Math.min(L,x),L=Math.max(L,o+b+l),t.cloneContainer.style.top=L+"px",t.cloneContainer.style.left=a+l+(s-h)/2+"px",t.cloneContainer.style.width=h+"px",t.cloneContainer.style.height=y+"px"}if(e.contentContainer){let t;t=e.group?e.group[e.group.currentIndex]:e;const n=t.content.getBoundingClientRect();e.contentContainer.style.height=n.height/i+"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){const t=document.createElement("div");t.className="popupable-clone-container",e.hasAttribute("data-popupable-transparent")&&t.classList.add("popupable-transparent");const n=new Image;n.className="popupable-clone",n.src=e.currentSrc??e.src;const o=getComputedStyle(e);let a,r,i;if(t.style.borderRadius=o.borderRadius,n.style.objectFit=o.objectFit,n.style.objectPosition=o.objectPosition,n.style.imageRendering=o.imageRendering,n.style.background=o.background,t.append(n),e.dataset.popupableSrc&&(a=new Image,a.className="popupable-clone-layer",a.src=e.dataset.popupableSrc,a.style.imageRendering=o.imageRendering,t.append(a),"fill"===n.style.objectFit)){const t=e.getBoundingClientRect();e.naturalWidth&&e.naturalHeight&&Math.abs(t.width/t.height-e.naturalWidth/e.naturalHeight)<.01&&(n.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")&&(i=!0,t.classList.add("popupable-zoomable")),{id:e.dataset.popupable,original:e,cloneContainer:t,clone:n,cloneLayer:a,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),ready:Promise.all([n,a].filter(Boolean).map(e=>e.decode().catch(()=>{}))),content:r,zoomable:i}}function handleMove(t){if("open"!==e?.state||!e.group||!i)return;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)-l}px)`}document.addEventListener("pointerdown",t=>{0===t.button&&(i||(n=t.target,l=t.clientX,s=t.clientY),i||"open"!==e?.state||t.target.closest(".popupable-header, .popupable-footer")||(i=!0))}),document.addEventListener("mousemove",handleMove),document.addEventListener("touchmove",handleMove,{passive:!0}),document.addEventListener("pointerup",async r=>{if(0!==r.button)return;if(i){i=!1;const _=e.group?e.group[e.group.currentIndex]:e;_.cloneContainer.parentElement.style.transition=null,_.cloneContainer.parentElement.style.transform=null;const j=r.clientX-l,K=Math.abs(j),G=r.clientY-s,Z=Math.abs(G);if("touch"===r.pointerType&&Z>56&&Z>1.1*K)return void closePopupable();if(e.group&&K>a){const J=Math.max(0,Math.floor((K-window.innerWidth/2)/window.innerWidth));if(j>32)for(let Q=0;Q<=J;Q++)e.goPrev();else if(j<-32)for(let ee=0;ee<=J;ee++)e.goNext();return void(e.blocked=!0)}}const p=r.target.closest(".popupable-viewport")&&!n.closest(".popupable-viewport");if(!p&&r.target!=n&&(!n.classList.contains("popupable-clone-container")||r.target!==t?.original)&&(!n.closest(".popupable-container")||r.target.closest(".popupable-container"))||Math.abs(r.clientX-l)>a||Math.abs(r.clientY-s)>a)return;const c=(p?n.closest("[data-popupable]"):null)||r.target.closest("[data-popupable]");if(!c){if(p)return void closePopupable();if(r.target.closest(".popupable-container"))return;return void(e&&("zoomed"===e.state?e.unzoom():closePopupable()))}if(r.preventDefault(),e?.original===c&&e.popup&&!e.popup.isConnected&&"close"!==e.state)return;const u=++o;e&&closePopupable(),e={transition:{},listeners:[]};const d=e,f=document.createElement("div");f.className="popupable-clones";const m=cloneElement(c),{cloneContainer:b,clone:v,content:g}=m;let h;if(c.dataset.popupableGroup){const te=document.querySelectorAll(`[data-popupable-group="${c.dataset.popupableGroup}"]`);if(te.length){h=[];for(const[ne,oe]of te.entries())if(oe===c)h.push(m),h.currentIndex=ne,f.append(b);else{const ae=cloneElement(oe);ae.cloneContainer.style.display="none",ae.cloneContainer.classList.add("popupable-clone-extra"),h.push(ae),f.append(ae.cloneContainer)}}}else f.append(b);const y=document.createElement("div");y.className="popupable-container",m.id&&(y.id=m.id);const L=document.createElement("div");let x,w,C,P,E,I,M,k,z,T;L.className="popupable-viewport",g&&(x=document.createElement("div"),x.classList="popupable-content-container");const X={};if(h){m.counter&&(w=document.createElement("div"),w.className="popupable-header",P=document.createElement("div"),P.className="popupable-counter",w.append(P)),m.thumbnails&&(E=document.createElement("div"),E.className="popupable-thumbnails",I=h.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})),L.innerHTML=`\n <div class="popupable-prev-container${h.currentIndex?"":" popupable-disabled"}">\n <div class="popupable-button popupable-nav-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-next-container${h.currentIndex===h.length-1?" popupable-disabled":""}">\n <div class="popupable-button popupable-nav-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 re=L.querySelector(".popupable-next-container"),ie=L.querySelector(".popupable-prev-container");let le,se,pe,ce;const ue=!(navigator.maxTouchPoints>0||window.matchMedia("(hover: none)").matches);function A(){ue&&(clearTimeout(le),ce||(le=setTimeout(()=>{ce||(re.classList.add("popupable-nav-inactive"),ie.classList.add("popupable-nav-inactive"))},1500)))}function S(){re.classList.remove("popupable-nav-inactive"),ie.classList.remove("popupable-nav-inactive"),A()}async function Y(){const e=h[h.currentIndex];await e.ready,h.currentIndex?ie.classList.remove("popupable-disabled"):ie.classList.add("popupable-disabled"),h.currentIndex===h.length-1?re.classList.add("popupable-disabled"):re.classList.remove("popupable-disabled");for(const[e,t]of h.entries()){const n=e-h.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(e.id?y.id=e.id:y.removeAttribute("id"),P&&(P.textContent=`${h.currentIndex+1} / ${h.length}`),I){for(const[e,t]of I.entries())t.classList.toggle("popupable-thumbnail-active",e===h.currentIndex);const e=I[h.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,r=E.scrollLeft+E.clientWidth-o,i=e.offsetLeft,l=i+e.offsetWidth;let s=E.scrollLeft;i<a?s=Math.max(0,i-n):l>r&&(s=l-E.clientWidth+o),s!==E.scrollLeft&&(M?E.scrollTo({left:s,behavior:"smooth"}):E.scrollLeft=s),M=!0})}updateExpandedSize()}if(k=()=>{h.currentIndex>=h.length-1||(h.currentIndex++,Y())},z=()=>{h.currentIndex<=0||(h.currentIndex--,Y())},Y(),ue&&A(),e.listeners.push({target:re,event:"click",func:()=>k()},{target:ie,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":k();break;case"ArrowLeft":case"ArrowUp":case"PageUp":case"a":case"w":z();break;case"Home":h.currentIndex=0,Y();break;case"End":h.currentIndex=h.length-1,Y();break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":h.currentIndex=Math.min(Math.max(Number(t.key),1)-1,h.length-1),Y()}}},{target:document,event:"wheel",func:t=>{if("zoomed"===e.state)return;const n=performance.now();n-(T||0)<80||(t.deltaY>50?(T=n,k()):t.deltaY<-50&&(T=n,z()))},args:{passive:!0}}),E){let de,fe,me,be,ve,ge,he,ye,Le;function R(){Le&&(cancelAnimationFrame(Le),Le=null)}function B(){if(R(),Math.abs(ye)<.01)return;let e=performance.now();Le=requestAnimationFrame(function t(n){if(!E.isConnected)return void R();const o=E.scrollWidth-E.clientWidth;if(o<=0)return void R();const a=Math.min(32,n-e);e=n;let r=E.scrollLeft+ye*a;r<0&&(r=0),r>o&&(r=o),E.scrollLeft=r,E.scrollLeft<=.1&&ye<0||E.scrollLeft>=o-.1&&ye>0?R():(ye*=Math.pow(.8,a/16.67),Math.abs(ye)<=.002?R():Le=requestAnimationFrame(t))})}e.listeners.push({target:E,event:"pointerdown",func:e=>{if(0!==e.button)return;const t=E.scrollWidth-E.clientWidth;me=t>0,R(),de=!0,fe=!1,be=e.clientX,ve=E.scrollLeft,ge=E.scrollLeft,he=performance.now(),ye=0,me&&E.classList.add("popupable-thumbnails-dragging"),E.setPointerCapture(e.pointerId)}},{target:E,event:"pointermove",func:e=>{if(!de)return;const t=e.clientX-be;Math.abs(t)>a&&(fe=!0);const n=performance.now(),o=n-he,r=ve-t;if(E.scrollLeft=r,o>0){const e=(E.scrollLeft-ge)/o;ye=.65*ye+.35*e,ge=E.scrollLeft,he=n}}},{target:E,event:"pointerup",func:e=>{if(!de)return;if(de=!1,me&&E.classList.remove("popupable-thumbnails-dragging"),E.hasPointerCapture(e.pointerId)&&E.releasePointerCapture(e.pointerId),fe)return performance.now()-he>10&&(ye=0),void B();const t=document.elementFromPoint(e.clientX,e.clientY)?.closest?.(".popupable-thumbnail");t&&(h.currentIndex=Number(t.dataset.thumbnailIndex),Y())}},{target:E,event:"pointercancel",func:e=>{de&&(de=!1,me&&E.classList.remove("popupable-thumbnails-dragging"),E.hasPointerCapture(e.pointerId)&&E.releasePointerCapture(e.pointerId),R())}},{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&&ye<0&&(ye=0),a&&n<0&&ye>0&&(ye=0);ye=(ye||0)+.015*n,Le||B()},args:{passive:!1}})}ue&&(e.listeners.push({target:re,event:"pointerenter",func:()=>{ce=!0,S()}},{target:ie,event:"pointerenter",func:()=>{ce=!0,S()}},{target:re,event:"pointerleave",func:()=>{ce=!1,A()}},{target:ie,event:"pointerleave",func:()=>{ce=!1,A()}}),e.listeners.push({target:y,event:"pointermove",func:t=>{if("zoomed"!==e.state)return null==se||null==pe?(se=t.clientX,void(pe=t.clientY)):void(Math.abs(t.clientX-se)<a&&Math.abs(t.clientY-pe)<a||(se=t.clientX,pe=t.clientY,S()))},args:{passive:!0}}));for(const xe of h)xe.content&&x&&x.append(xe.content)}else g&&x.append(g);const N={counter:!!P,content:!!x,thumbnails:!!E},F=m.order.top.filter(e=>N[e]),D=m.order.bottom.filter(e=>N[e]);function W(e,t){e&&("counter"===t&&P?(X[e===w?"counterTop":"counterBottom"]=!0,e.append(P)):"content"===t&&x?(X[e===w?"contentTop":"contentBottom"]=!0,e.append(x)):"thumbnails"===t&&E&&(X[e===w?"thumbnailsTop":"thumbnailsBottom"]=!0,e.append(E)))}F.length&&(w=document.createElement("div"),w.className="popupable-header"),D.length&&(C=document.createElement("div"),C.className="popupable-footer");for(const we of F)W(w,we);for(const Ce of D)W(C,Ce);w&&L.append(w),C&&L.append(C),y.append(f,L),Object.assign(d,m,{popup:y,group:h,contentContainer:x,thumbnailsContainer:E,orderPlacement:X,goNext:k,goPrev:z});const H=setTimeout(()=>{u===o&&c.classList.add("popupable-loading")},250);if(await d.ready,clearTimeout(H),c.classList.remove("popupable-loading"),u!==o||e!==d||"close"===d.state)return;setCloneToOriginalRect(b,c),document.body.append(y),c.classList.add("popupable-hide"),disableScroll();const O=getComputedStyle(y);d.transition.duration=1e3*parseFloat(O.transitionDuration)+1e3*parseFloat(O.transitionDelay),y._state=d,requestAnimationFrame(()=>{requestAnimationFrame(()=>{openPopupable(y._state)})});let V,q=0;h&&y.addEventListener("dragstart",e=>e.preventDefault());const $=new Map;function U(e,t,n,o,r=[]){if("open"!==e.state)return;let l=0;const s=t.cloneContainer.parentElement,p=s.style.transform;if(p){const e=p.match(/translateX\((-?\d+(?:\.\d+)?)px\)/);e&&(l=Number(e[1])||0)}const c=Math.abs(l)>.5;i=!1,c?(t.cloneContainer.style.translate="0 0",t.cloneContainer.style.transition="translate var(--popupable-switch-duration), transform 0s",s.style.transition=null,s.style.transform=null,t.cloneContainer.style.translate=`${l}px 0`):(s.style.transition=null,s.style.transform=null),e.state="zoomed",y.classList.add("popupable-locked");let u,d,f=o;const m=new Map;let b,v,g,h,x,w,C,P,E,I,M=!1;const k=t.cloneContainer.getBoundingClientRect(),z=n?.clientX??k.left+k.width/2,T=n?.clientY??k.top+k.height/2;u=(z-k.left)*(1-f),d=(T-k.top)*(1-f);const X=()=>t.cloneContainer.style.transform=`translate(${u}px, ${d}px) scale(${f})`;function A(e,n,o){const a=f;var r;if(r=e,f=Math.min(6,Math.max(1,r)),f===a)return!1;const i=t.cloneContainer.getBoundingClientRect(),l=f/a,s=n-i.left,p=o-i.top;return u+=s*(1-l),d+=p*(1-l),!0}function S(){if(1===m.size){const e=m.values().next().value;return b=e.id,v=e.x,g=e.y,h=null,x=null,void(w=null)}if(m.size>=2){b=null;const[e,t]=[...m.values()];return h=(e.x+t.x)/2,x=(e.y+t.y)/2,void(w=Math.hypot(t.x-e.x,t.y-e.y))}b=null,v=null,g=null,h=null,x=null,w=null}if(t.cloneContainer.classList.add("popupable-zoomed"),X(),r.length){c||(t.cloneContainer.style.transition="none"),I=!0;for(const e of r)m.set(e.id,{id:e.id,x:e.x,y:e.y}),y.setPointerCapture(e.id);S()}e.unzoom=()=>{e.state="open",y.classList.remove("popupable-locked");for(const e of m.keys())y.hasPointerCapture(e)&&y.releasePointerCapture(e);m.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:y,event:"pointerdown",func:e=>{0===e.button&&(t.cloneContainer.style.transition="none",y.setPointerCapture(e.pointerId),m.set(e.pointerId,{id:e.pointerId,x:e.clientX,y:e.clientY}),1===m.size?(C=e.target,P=e.clientX,E=e.clientY,I=!1):I=!0,S(),e.preventDefault())}},{target:y,event:"pointermove",func:e=>{const t=m.get(e.pointerId);if(t){if(t.x=e.clientX,t.y=e.clientY,!I&&(Math.abs(e.clientX-P)>a||Math.abs(e.clientY-E)>a)&&(I=!0),1===m.size&&b===e.pointerId){const t=e.clientX-v,n=e.clientY-g;if(!t&&!n)return;return u+=t,d+=n,v=e.clientX,g=e.clientY,void X()}if(m.size>=2){const[e,t]=[...m.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(!w)return h=n,x=o,void(w=a);u+=n-h,d+=o-x,A(f*(a/w),n,o),M=!0,h=n,x=o,w=a,X()}}}},{target:y,event:"pointerup",func:n=>{if(m.has(n.pointerId)){if(m.delete(n.pointerId),y.hasPointerCapture(n.pointerId)&&y.releasePointerCapture(n.pointerId),M&&f<=1.01&&m.size<2)return e.skipOpenTouchPointerUps=m.size,void e.unzoom();if(!m.size&&!I&&Math.abs(n.clientX-P)<a&&Math.abs(n.clientY-E)<a){if(C?.closest?.(".popupable-clone-container")===t.cloneContainer||(C===y||C===L))return void e.unzoom()}S()}}},{target:y,event:"pointercancel",func:e=>{m.has(e.pointerId)&&(m.delete(e.pointerId),y.hasPointerCapture(e.pointerId)&&y.releasePointerCapture(e.pointerId),S())}},{target:y,event:"wheel",func:e=>{t.cloneContainer.style.transition="none",A(f*Math.exp(.002*-e.deltaY),e.clientX,e.clientY)&&X()},args:{passive:!0}}];for(const t of e.zoomListeners)t.target.addEventListener(t.event,t.func,t.args)}e.listeners.push({target:y,event:"pointerdown",func:e=>{if("open"!==y._state.state||"touch"!==e.pointerType)return;const t=y._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&&(U(t,n,e,1,[...$.values()].slice(0,2)),$.clear(),e.preventDefault()))}},{target:y,event:"pointermove",func:e=>{const t=$.get(e.pointerId);t&&(t.x=e.clientX,t.y=e.clientY)}},{target:y,event:"pointerup",func:e=>{$.delete(e.pointerId)}},{target:y,event:"pointercancel",func:e=>{$.delete(e.pointerId)}}),y.addEventListener("pointerup",t=>{if("zoomed"===y._state.state)return;if("touch"===t.pointerType&&(y._state.skipOpenTouchPointerUps||0)>0)return void y._state.skipOpenTouchPointerUps--;const o=performance.now(),a=null!=t.target.closest(".popupable-next-container, .popupable-prev-container");if(V&&o-q<250)return void(q=o);if(a?(V=!0,q=o):(V=!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 r=y._state,i=r.group?r.group[r.group.currentIndex]:r;r.blocked&&(r.blocked=!1),"open"!==r.state?(t.stopPropagation(),e!==r&&(closePopupable(),e=r),openPopupable(e)):requestAnimationFrame(()=>{r.blocked?r.blocked=!1:i.zoomable&&(t.target.classList.contains("popupable-clone")||t.target.classList.contains("popupable-clone-layer"))?U(r,i,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,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)}
|