popupable 1.6.3 → 1.7.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/LICENSE.txt +21 -0
- package/README.md +61 -0
- package/dist/popupable.min.css +2 -2
- package/dist/popupable.min.js +2 -2
- package/package.json +1 -1
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ewan Howell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ Just add `data-popupable` to any image!
|
|
|
16
16
|
* Multiple built-in animation styles, with support for custom ones
|
|
17
17
|
* Works with mouse, touch, and keyboard
|
|
18
18
|
* Gallery groups with swipe, scroll, keyboard, and button navigation
|
|
19
|
+
* Supports both images and videos
|
|
19
20
|
* Thumbnail strip and image counter
|
|
20
21
|
* Pinch-to-zoom on touch, with optional click/tap-to-zoom support
|
|
21
22
|
* Checkerboard background for transparent images
|
|
@@ -65,6 +66,9 @@ Close by clicking again, or pressing Escape, Backspace, or Delete.
|
|
|
65
66
|
| `data-popupable-counter` | Shows a "1 / N" counter when in a group. |
|
|
66
67
|
| `data-popupable-thumbnails` | Shows a thumbnail strip when in a group. |
|
|
67
68
|
| `data-popupable-order="..."` | Controls the order of UI elements. |
|
|
69
|
+
| `data-popupable-type="image\|video"` | Forces popupable to treat the source as an image or video regardless of its tag name or file extension. |
|
|
70
|
+
| `data-popupable-poster="url"` | Poster image to show before a video has loaded. Also used as the placeholder for video thumbnails. |
|
|
71
|
+
| `data-popupable-attr="..."` | Comma-separated list of properties to set on the `<video>` element. See [Videos](#videos). |
|
|
68
72
|
|
|
69
73
|
### Inheritance
|
|
70
74
|
|
|
@@ -122,6 +126,59 @@ Add `data-popupable-no-upscale` to prevent the popup from scaling the image beyo
|
|
|
122
126
|
<img src="pixel-art.png" data-popupable data-popupable-no-upscale>
|
|
123
127
|
```
|
|
124
128
|
|
|
129
|
+
### Videos
|
|
130
|
+
|
|
131
|
+
popupable supports videos in the same gallery flow as images. A source is treated as a video if any of these are true:
|
|
132
|
+
|
|
133
|
+
* The element is a `<video>` tag.
|
|
134
|
+
* The URL ends in one of: `.mp4`, `.m4v`, `.webm`, `.ogv`, `.mov`, `.3gp`, `.m3u8`, `.flv`.
|
|
135
|
+
* `data-popupable-type="video"` is set on the element (or inherited from a parent).
|
|
136
|
+
|
|
137
|
+
Use `data-popupable-type` explicitly when the tag/extension doesn't match what you actually want — for example, when the URL doesn't reveal the underlying format (a proxied URL, a query-string-only URL), or when you want to force a `<video>` element or a `.mp4`-extensioned URL to be rendered as an image:
|
|
138
|
+
|
|
139
|
+
```html
|
|
140
|
+
<!-- Force video on a URL that doesn't end with a video extension -->
|
|
141
|
+
<div data-popupable data-popupable-type="video" src="/video/clip"></div>
|
|
142
|
+
|
|
143
|
+
<!-- Force image on a URL or tag that would otherwise be detected as video -->
|
|
144
|
+
<div data-popupable data-popupable-type="image" src="/render/clip.mp4"></div>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
#### Poster images
|
|
148
|
+
|
|
149
|
+
Add `data-popupable-poster` to provide a still image to show before the video has loaded:
|
|
150
|
+
|
|
151
|
+
```html
|
|
152
|
+
<video src="clip.mp4" poster="clip.jpg" data-popupable></video>
|
|
153
|
+
<div data-popupable data-popupable-type="video" src="/video/clip" data-popupable-poster="/preview/clip.jpg"></div>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
If the source is a `<video>` element, its `poster` attribute is also used automatically.
|
|
157
|
+
|
|
158
|
+
> **Recommended for large galleries.** When a video has a poster, popupable uses an `<img>` for its thumbnail strip entry instead of a `<video>`. Posters load much faster than a video's metadata range request, especially across many thumbnails at once, so the strip fills in quickly even with hundreds of items.
|
|
159
|
+
|
|
160
|
+
#### Passing attributes to the `<video>` element
|
|
161
|
+
|
|
162
|
+
Use `data-popupable-attr` to set properties on the underlying `<video>` element. The value is a comma-separated list of `name` or `name=value` pairs. Values are parsed as `true`/`false`, numbers, or strings.
|
|
163
|
+
|
|
164
|
+
```html
|
|
165
|
+
<!-- Hide the controls bar -->
|
|
166
|
+
<div data-popupable data-popupable-type="video" data-popupable-attr="controls=false" src="/video/clip"></div>
|
|
167
|
+
|
|
168
|
+
<!-- Autoplay muted, looping, at 1.5x speed -->
|
|
169
|
+
<div data-popupable data-popupable-type="video" data-popupable-attr="muted,loop,autoplay,playbackRate=1.5" src="/video/clip"></div>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`data-popupable-attr` is inherited, so you can set defaults on a group container.
|
|
173
|
+
|
|
174
|
+
Notes on `controls`:
|
|
175
|
+
|
|
176
|
+
* By default, videos get `controls=true` when opened.
|
|
177
|
+
* If `controls` is mentioned in `data-popupable-attr` (e.g. `controls`, `controls=true`, `controls=false`), that explicit value is respected.
|
|
178
|
+
* `data-popupable-zoomable` always forces `controls=false`, regardless of `data-popupable-attr`, because zoomable mode uses click and scroll for zoom/pan.
|
|
179
|
+
|
|
180
|
+
Videos are always rendered with `playsInline`.
|
|
181
|
+
|
|
125
182
|
### Zoom
|
|
126
183
|
|
|
127
184
|
All images support pinch-to-zoom. Add `data-popupable-zoomable` to also enable tap/click-to-zoom and scroll wheel zoom:
|
|
@@ -185,6 +242,10 @@ Default order: `counter,image,content,thumbnails`
|
|
|
185
242
|
| `End` | Last image |
|
|
186
243
|
| `1`–`9` | Jump to image by number |
|
|
187
244
|
|
|
245
|
+
### Large galleries
|
|
246
|
+
|
|
247
|
+
popupable is designed to handle galleries with many items. Only the slides near the active one are kept loaded; the rest are unloaded automatically and shown as a blurred-gradient placeholder until you scroll back to them. Prefetching adjusts as you drag, so slides you scroll onto are loaded by the time they reach view.
|
|
248
|
+
|
|
188
249
|
### Custom IDs
|
|
189
250
|
|
|
190
251
|
Set the value of `data-popupable` to give the popup a CSS `id`, useful for per-popup styling. In a gallery, the `id` updates as you navigate, so each image can have its own style:
|
package/dist/popupable.min.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* popupable
|
|
3
|
-
* Version : 1.
|
|
3
|
+
* Version : 1.7.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}@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;border-width:0!important;outline-width:0!important;box-shadow:none!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}.popupable-block-transitions,.popupable-block-transitions *{transition:initial!important}@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}}
|
|
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-clone-loading>.popupable-clone,.popupable-clone-container.popupable-clone-loading>.popupable-clone-layer{visibility:hidden}.popupable-clone-container.popupable-clone-loading::after{content:"";position:absolute;inset:-16px;background:radial-gradient(circle at var(--popupable-loading-x1,30%) var(--popupable-loading-y1,20%),var(--popupable-loading-c1,rgba(255,255,255,.07)),transparent 55%),radial-gradient(circle at var(--popupable-loading-x2,70%) var(--popupable-loading-y2,80%),var(--popupable-loading-c2,rgba(255,255,255,.05)),transparent 60%),linear-gradient(var(--popupable-loading-angle,135deg),var(--popupable-loading-a,#1a1a1a) 0,var(--popupable-loading-b,#242424) 50%,var(--popupable-loading-a,#1a1a1a) 100%);filter:blur(8px) saturate(.6);pointer-events:none;z-index: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;border-width:0!important;outline-width:0!important;box-shadow:none!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}video.popupable-clone:fullscreen{object-fit:contain!important}.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}.popupable-block-transitions,.popupable-block-transitions *{transition:initial!important}@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.7.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;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 f=t.source.naturalWidth/t.source.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),{top:a,left:i,width:r,height:s}=e.animation.position(n,o);t.style.top=a+"px",t.style.left=i+"px",t.style.width=r+"px",t.style.height=s+"px"}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"}}}window.popupableAnimTypes={expand:{styles:!0,hideSource:!0,crossfade:!0,position(e){const t=e.getBoundingClientRect();return{top:visualViewport.offsetTop+t.top,left:visualViewport.offsetLeft+t.left,width:t.width,height:t.height}}},pop:{fade:!0,position:(e,{top:t,left:n,width:o,height:a})=>({top:t+.05*a,left:n+.05*o,width:.9*o,height:.9*a})},line:{fade:!0,position:(e,{top:t,left:n,width:o,height:a})=>({top:t+a/2,left:n+.05*o,width:.9*o,height:0})},float:{fade:!0,position:(e,{top:t,left:n,width:o,height:a})=>({top:t+40,left:n,width:o,height:a})}};const r=e=>e.getAttribute("currentSrc")||e.getAttribute("src")||e.getAttribute("data-popupable-src");function inheritAttr(e,t){const n=e.closest(`[${t}]`);if(!n)return;const o=n.getAttribute(t);return"false"!==o?o||!0:void 0}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=e){const n=inheritAttr(e,"data-popupable-anim"),o=popupableAnimTypes[n]?n:"expand",a=popupableAnimTypes[o],i=inheritAttr(e,"data-popupable-src"),s=r(e),l=inheritAttr(e,"data-popupable-title"),p=inheritAttr(e,"data-popupable-description"),c=inheritAttr(e,"data-popupable-zoomable"),u=getComputedStyle(e),d=t===e?u:getComputedStyle(t),b=t!==e?r(t):null,f=document.createElement("div");f.className="popupable-clone-container",inheritAttr(e,"data-popupable-transparent")&&f.classList.add("popupable-transparent"),c&&f.classList.add("popupable-zoomable"),f.style.borderRadius=u.borderRadius,a.styles&&(f.style.border=u.border,f.style.outline=u.outline,f.style.boxShadow=u.boxShadow);const m=new Image;let h,v,g;if(m.className="popupable-clone",m.src=b||s||i,m.style.objectFit=d.objectFit,m.style.objectPosition=d.objectPosition,m.style.imageRendering=d.imageRendering,m.style.background=d.background,f.append(m),i&&s||b){if(h=new Image,h.className="popupable-clone-layer",h.src=i||s,h.style.imageRendering=u.imageRendering,f.append(h),"fill"===m.style.objectFit){const t=e.getBoundingClientRect();e.naturalWidth&&e.naturalHeight&&Math.abs(t.width/t.height-e.naturalWidth/e.naturalHeight)<.01&&(m.style.objectFit="cover")}v=h}else v=m;if(l||p){if(g=document.createElement("div"),g.classList="popupable-content",l){const e=document.createElement("div");e.className="popupable-title",e.textContent=l,g.append(e)}if(p){const e=document.createElement("div");e.className="popupable-description",e.textContent=p,g.append(e)}}return{id:e.dataset.popupable,original:e,cloneContainer:f,clone:m,cloneLayer:h,maintainAspect:inheritAttr(e,"data-popupable-maintain-aspect"),noUpscale:inheritAttr(e,"data-popupable-no-upscale"),counter:inheritAttr(e,"data-popupable-counter"),thumbnails:inheritAttr(e,"data-popupable-thumbnails"),order:parsePopupableOrder(inheritAttr(e,"data-popupable-order")),animationName:o,animation:a,ready:Promise.all([m,h].filter(Boolean).map(e=>e.decode().catch(()=>{}))),content:g,zoomable:c,source:v}}let s,l,p;function handleMove(t){if("open"!==e?.state||!e.group||!s)return;if(!e.popup?.classList.contains("popupable-open"))return l=t.touches?.[0].clientX??t.clientX,void(p=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)-l}px)`}document.addEventListener("pointerdown",t=>{0===t.button&&(s||(n=t.target,l=t.clientX,p=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 Z=e.group?e.group[e.group.currentIndex]:e;Z.cloneContainer.parentElement.style.transition=null,Z.cloneContainer.parentElement.style.transform=null;const G=i.clientX-l,J=Math.abs(G),Q=i.clientY-p,ee=Math.abs(Q);if("touch"===i.pointerType&&ee>56&&ee>1.1*J)return void closePopupable();if(e.group&&J>a){const te=Math.max(0,Math.floor((J-window.innerWidth/2)/window.innerWidth));if(G>32)for(let ne=0;ne<=te;ne++)e.goPrev();else if(G<-32)for(let oe=0;oe<=te;oe++)e.goNext();return void(e.blocked=!0)}}const c=i.target.closest(".popupable-viewport")&&!n.closest(".popupable-viewport");if(!c&&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-l)>a||Math.abs(i.clientY-p)>a)return;const u=(c?n.closest("[data-popupable]"):null)||i.target.closest("[data-popupable]");if(!u){if(c)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===u)return;e&&closePopupable();const d=++o;e={transition:{},listeners:[]};const b=e,f=document.createElement("div");f.className="popupable-clones";const m=cloneElement(u),{cloneContainer:h,content:v}=m;let g;const y=u.closest("[data-popupable-group]"),w=y?.getAttribute("data-popupable-group"),L=w&&"false"!==w?w:null;if(L){const ae=[],ie=new Set;for(const re of document.querySelectorAll(`[data-popupable-group="${L}"]`)){re.hasAttribute("data-popupable")&&!ie.has(re)&&(ie.add(re),ae.push(re));for(const se of re.querySelectorAll("[data-popupable]")){if(ie.has(se))continue;const le=se.getAttribute("data-popupable-group");null!==le&&le!==L||se.closest("[data-popupable-group]")!==re||(ie.add(se),ae.push(se))}}if(ae.length){g=[];for(const[pe,ce]of ae.entries())if(ce===u)g.push(m),g.currentIndex=pe,f.append(h);else{const ue=cloneElement(ce,u);ue.cloneContainer.style.display="none",g.push(ue),f.append(ue.cloneContainer)}for(const[de,be]of g.entries()){if(!be.content)continue;const fe=de-g.currentIndex;fe>0?be.content.classList.add("popupable-content-after"):fe<0&&be.content.classList.add("popupable-content-before")}}}else f.append(h);const x=document.createElement("div");x.className=`popupable-container popupable-anim-${m.animationName}`,m.id&&(x.id=m.id);const C=document.createElement("div");let E,I,P,M,k,A,z,T,S,N,X;C.className="popupable-viewport",(v||g&&g.some(e=>e.content))&&(E=document.createElement("div"),E.classList="popupable-content-container");const Y={};if(g){m.counter&&(M=document.createElement("div"),M.className="popupable-counter"),m.thumbnails&&(k=document.createElement("div"),k.className="popupable-thumbnails",A=g.map((e,t)=>{const n=new Image;return n.className="popupable-thumbnail",n.src=inheritAttr(e.original,"data-popupable-src")||r(e.original),n.dataset.thumbnailIndex=t,k.append(n),n})),C.innerHTML=`\n <div class="popupable-button-container popupable-prev-container${g.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${g.currentIndex===g.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 me=C.querySelector(".popupable-next-container"),he=C.querySelector(".popupable-prev-container");let ve,ge,ye,we;const Le=!(navigator.maxTouchPoints>0||window.matchMedia("(hover: none)").matches);function R(){me.classList.remove("popupable-button-inactive"),he.classList.remove("popupable-button-inactive"),e.scheduleNavHide()}if(e.scheduleNavHide=()=>{Le&&(clearTimeout(ve),we||(ve=setTimeout(()=>{we||(me.classList.add("popupable-button-inactive"),he.classList.add("popupable-button-inactive"))},1500)))},e.clearNavInactive=()=>{me.classList.remove("popupable-button-inactive"),he.classList.remove("popupable-button-inactive")},X=async()=>{const t=g[g.currentIndex];await t.ready,g.currentIndex?he.classList.remove("popupable-button-disabled"):he.classList.add("popupable-button-disabled"),g.currentIndex===g.length-1?me.classList.add("popupable-button-disabled"):me.classList.remove("popupable-button-disabled");for(const[e,t]of g.entries()){const n=e-g.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?x.id=t.id:x.removeAttribute("id"),M&&(M.textContent=`${g.currentIndex+1} / ${g.length}`),A){for(const[e,t]of A.entries())t.classList.toggle("popupable-thumbnail-active",e===g.currentIndex);const e=A[g.currentIndex];requestAnimationFrame(()=>{if(!e||!k?.isConnected)return;const t=getComputedStyle(k),n=parseFloat(t.paddingLeft)||0,o=parseFloat(t.paddingRight)||0,a=k.scrollLeft+n,i=k.scrollLeft+k.clientWidth-o,r=e.offsetLeft,s=r+e.offsetWidth;let l=k.scrollLeft;r<a?l=Math.max(0,r-n):s>i&&(l=s-k.clientWidth+o),l!==k.scrollLeft&&(z?k.scrollTo({left:l,behavior:"smooth"}):k.scrollLeft=l),z=!0})}e.closeContainer.classList.toggle("popupable-button-inactive",!t.zoomable),updateExpandedSize()},T=()=>{g.currentIndex>=g.length-1||(g.currentIndex++,X())},S=()=>{g.currentIndex<=0||(g.currentIndex--,X())},e.listeners.push({target:me,event:"click",func:()=>T()},{target:he,event:"click",func:()=>S()},{target:document,event:"keydown",func:t=>{if("zoomed"!==e.state)switch(t.key){case"ArrowRight":case"ArrowDown":case"PageDown":case"d":case"s":T();break;case"ArrowLeft":case"ArrowUp":case"PageUp":case"a":case"w":S();break;case"Home":g.currentIndex=0,X();break;case"End":g.currentIndex=g.length-1,X();break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":g.currentIndex=Math.min(Math.max(Number(t.key),1)-1,g.length-1),X()}}},{target:document,event:"wheel",func:t=>{if("zoomed"===e.state)return;const n=performance.now();n-(N||0)<80||(t.deltaY>50?(N=n,T()):t.deltaY<-50&&(N=n,S()))},args:{passive:!0}}),k){let xe,Ce,Ee,Ie,Pe,Me,ke,Ae,ze;function B(){ze&&(cancelAnimationFrame(ze),ze=null)}function H(){if(B(),Math.abs(Ae)<.01)return;let e=performance.now();ze=requestAnimationFrame(function t(n){if(!k.isConnected)return void B();const o=k.scrollWidth-k.clientWidth;if(o<=0)return void B();const a=Math.min(32,n-e);e=n;let i=k.scrollLeft+Ae*a;i<0&&(i=0),i>o&&(i=o),k.scrollLeft=i,k.scrollLeft<=.1&&Ae<0||k.scrollLeft>=o-.1&&Ae>0?B():(Ae*=Math.pow(.8,a/16.67),Math.abs(Ae)<=.002?B():ze=requestAnimationFrame(t))})}e.listeners.push({target:k,event:"pointerdown",func:e=>{if(0!==e.button)return;const t=k.scrollWidth-k.clientWidth;Ee=t>0,B(),xe=!0,Ce=!1,Ie=e.clientX,Pe=k.scrollLeft,Me=k.scrollLeft,ke=performance.now(),Ae=0,Ee&&k.classList.add("popupable-thumbnails-dragging"),k.setPointerCapture(e.pointerId)}},{target:k,event:"pointermove",func:e=>{if(!xe)return;const t=e.clientX-Ie;Math.abs(t)>a&&(Ce=!0);const n=performance.now(),o=n-ke,i=Pe-t;if(k.scrollLeft=i,o>0){const e=(k.scrollLeft-Me)/o;Ae=.65*Ae+.35*e,Me=k.scrollLeft,ke=n}}},{target:k,event:"pointerup",func:e=>{if(!xe)return;if(xe=!1,Ee&&k.classList.remove("popupable-thumbnails-dragging"),k.hasPointerCapture(e.pointerId)&&k.releasePointerCapture(e.pointerId),Ce)return performance.now()-ke>10&&(Ae=0),void H();const t=document.elementFromPoint(e.clientX,e.clientY)?.closest?.(".popupable-thumbnail");t&&(g.currentIndex=Number(t.dataset.thumbnailIndex),X())}},{target:k,event:"pointercancel",func:e=>{xe&&(xe=!1,Ee&&k.classList.remove("popupable-thumbnails-dragging"),k.hasPointerCapture(e.pointerId)&&k.releasePointerCapture(e.pointerId),B())}},{target:k,event:"wheel",func:e=>{e.stopPropagation(),e.preventDefault();const t=k.scrollWidth-k.clientWidth;if(t<=0)return;const n=Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.deltaY,o=k.scrollLeft<=.1,a=k.scrollLeft>=t-.1;if(o&&n<0||a&&n>0)return;o&&n>0&&Ae<0&&(Ae=0),a&&n<0&&Ae>0&&(Ae=0);Ae=(Ae||0)+.015*n,ze||H()},args:{passive:!1}})}Le&&(e.listeners.push({target:me,event:"pointerenter",func:()=>{we=!0,R()}},{target:he,event:"pointerenter",func:()=>{we=!0,R()}},{target:me,event:"pointerleave",func:()=>{we=!1,e.scheduleNavHide()}},{target:he,event:"pointerleave",func:()=>{we=!1,e.scheduleNavHide()}}),e.listeners.push({target:x,event:"pointermove",func:t=>{if("zoomed"!==e.state)return null==ge||null==ye?(ge=t.clientX,void(ye=t.clientY)):void(Math.abs(t.clientX-ge)<a&&Math.abs(t.clientY-ye)<a||(ge=t.clientX,ye=t.clientY,R()))},args:{passive:!0}}));for(const Te of g)Te.content&&E&&E.append(Te.content)}else v&&E.append(v);const F={counter:!!M,content:!!E,thumbnails:!!k},W=m.order.top.filter(e=>F[e]),V=m.order.bottom.filter(e=>F[e]);function D(e,t){e&&("counter"===t&&M?(Y[e===I?"counterTop":"counterBottom"]=!0,e.append(M)):"content"===t&&E?(Y[e===I?"contentTop":"contentBottom"]=!0,e.append(E)):"thumbnails"===t&&k&&(Y[e===I?"thumbnailsTop":"thumbnailsBottom"]=!0,e.append(k)))}I=document.createElement("div"),I.className="popupable-header",P=document.createElement("div"),P.className="popupable-footer";for(const Se of W)D(I,Se);for(const Ne of V)D(P,Ne);C.append(I),C.append(P);const $=document.createElement("div");$.className="popupable-button-container popupable-close-container",$.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>',$.addEventListener("click",closePopupable),m.zoomable||$.classList.add("popupable-button-inactive"),I.append($),x.append(f,C),Object.assign(b,m,{popup:x,group:g,contentContainer:E,thumbnailsContainer:k,orderPlacement:Y,closeContainer:$,goNext:T,goPrev:S});const q=setTimeout(()=>{d===o&&u.classList.add("popupable-loading")},250);if(await b.ready,clearTimeout(q),u.classList.remove("popupable-loading"),d!==o||e!==b||"close"===b.state)return;h.classList.add("popupable-block-transitions"),m.animation.hideSource&&u.classList.add("popupable-hide"),m.animation.crossfade&&x.classList.add("popupable-crossfade"),m.animation.fade&&x.classList.add("popupable-fade"),document.body.append(x),setCloneToOriginalRect(h,u),disableScroll();const O=getComputedStyle(x);b.transition.duration=1e3*parseFloat(O.transitionDuration)+1e3*parseFloat(O.transitionDelay),x._state=b,requestAnimationFrame(()=>{h.classList.remove("popupable-block-transitions"),openPopupable(x._state),g&&X()});let U,_=0;g&&x.addEventListener("dragstart",e=>e.preventDefault());const j=new Map;function K(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",x.classList.add("popupable-locked");let u,d,b=o;const f=new Map;let m,h,v,g,y,w,L,E,I,P,M=!1;const k=t.cloneContainer.getBoundingClientRect(),A=n?.clientX??k.left+k.width/2,z=n?.clientY??k.top+k.height/2;u=(A-k.left)*(1-b),d=(z-k.top)*(1-b);const T=()=>t.cloneContainer.style.transform=`translate(${u}px, ${d}px) scale(${b})`;function S(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 N(){if(1===f.size){const e=f.values().next().value;return m=e.id,h=e.x,v=e.y,g=null,y=null,void(w=null)}if(f.size>=2){m=null;const[e,t]=[...f.values()];return g=(e.x+t.x)/2,y=(e.y+t.y)/2,void(w=Math.hypot(t.x-e.x,t.y-e.y))}m=null,h=null,v=null,g=null,y=null,w=null}if(t.cloneContainer.classList.add("popupable-zoomed"),T(),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}),x.setPointerCapture(e.id);N()}e.unzoom=()=>{e.state="open",x.classList.remove("popupable-locked");for(const e of f.keys())x.hasPointerCapture(e)&&x.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:x,event:"pointerdown",func:e=>{0===e.button&&(t.cloneContainer.style.transition="none",x.setPointerCapture(e.pointerId),f.set(e.pointerId,{id:e.pointerId,x:e.clientX,y:e.clientY}),1===f.size?(L=e.target,E=e.clientX,I=e.clientY,P=!1):P=!0,N(),e.preventDefault())}},{target:x,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 T()}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(!w)return g=n,y=o,void(w=a);u+=n-g,d+=o-y,S(b*(a/w),n,o),M=!0,g=n,y=o,w=a,T()}}}},{target:x,event:"pointerup",func:n=>{if(f.has(n.pointerId)){if(f.delete(n.pointerId),x.hasPointerCapture(n.pointerId)&&x.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(L?.closest?.(".popupable-clone-container")===t.cloneContainer||(L===x||L===C))return void e.unzoom()}N()}}},{target:x,event:"pointercancel",func:e=>{f.has(e.pointerId)&&(f.delete(e.pointerId),x.hasPointerCapture(e.pointerId)&&x.releasePointerCapture(e.pointerId),N())}},{target:x,event:"wheel",func:e=>{t.cloneContainer.style.transition="none",S(b*Math.exp(.002*-e.deltaY),e.clientX,e.clientY)&&T()},args:{passive:!0}}];for(const t of e.zoomListeners)t.target.addEventListener(t.event,t.func,t.args)}e.listeners.push({target:x,event:"pointerdown",func:e=>{if("open"!==x._state.state||"touch"!==e.pointerType)return;const t=x._state,n=t.group?t.group[t.group.currentIndex]:t;e.target.closest(".popupable-clone-container")===n.cloneContainer&&(j.set(e.pointerId,{id:e.pointerId,x:e.clientX,y:e.clientY}),j.size>=2&&(K(t,n,e,1,[...j.values()].slice(0,2)),j.clear(),e.preventDefault()))}},{target:x,event:"pointermove",func:e=>{const t=j.get(e.pointerId);t&&(t.x=e.clientX,t.y=e.clientY)}},{target:x,event:"pointerup",func:e=>{j.delete(e.pointerId)}},{target:x,event:"pointercancel",func:e=>{j.delete(e.pointerId)}}),x.addEventListener("pointerup",t=>{if("zoomed"===x._state.state)return;if("touch"===t.pointerType&&(x._state.skipOpenTouchPointerUps||0)>0)return void x._state.skipOpenTouchPointerUps--;const o=performance.now(),a=null!=t.target.closest(".popupable-next-container, .popupable-prev-container");if(U&&o-_<250)return void(_=o);if(a?(U=!0,_=o):(U=!1,_=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=x._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"))?K(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)}
|
|
7
|
+
{let e,t,n,o=0;const a=3;let r;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 calcExpandedRect(t){const n=t.original,o=visualViewport?.width||window.innerWidth,a=visualViewport?.height||window.innerHeight,r=visualViewport?.offsetTop||0,i=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,m=Math.max(0,d);let b;if(t.maintainAspect){const e=n.getBoundingClientRect();b=e.width/e.height}else{b=(t.source.naturalWidth||t.source.videoWidth)/(t.source.naturalHeight||t.source.videoHeight)||1}let f=0,g=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,r=e.contentContainer,i=t.content?t.content.getBoundingClientRect().height/l:r?.previousElementSibling&&r?.nextElementSibling&&parseFloat(getComputedStyle(r,"::after").height)||0,{counterTop:s,contentTop:p,thumbnailsTop:c,counterBottom:u,contentBottom:d,thumbnailsBottom:m}=e.orderPlacement;f=(s?o:0)+(p?i:0)+(c?a:0),g=(u?o:0)+(d?i:0)+(m?a:0)}const h=Math.max(0,a-f-g-2*c);let v=u,y=v/b;if(y>m&&(y=m,v=y*b),y>h&&(y=h,v=y*b),t.noUpscale){const e=t.cloneLayer||n,o=e.naturalWidth||e.videoWidth,a=e.naturalHeight||e.videoHeight;if(o&&a){const e=o/s,t=a/s,n=Math.min(1,e/v,t/y);n<1&&(v*=n,y*=n)}}let x=r+c+(m-y)/2;const w=r+a-g-c-y;return x=Math.min(x,w),x=Math.max(x,r+f+c),{top:x,left:i+c+(u-v)/2,width:v,height:y}}function setCloneToOriginalRect(t,n){const o=calcExpandedRect(e),{top:a,left:r,width:i,height:s}=e.animation.position(n,o);t.style.top=a+"px",t.style.left=r+"px",t.style.width=i+"px",t.style.height=s+"px"}window.popupableAnimTypes={expand:{styles:!0,hideSource:!0,crossfade:!0,position(e){const t=e.getBoundingClientRect();return{top:visualViewport.offsetTop+t.top,left:visualViewport.offsetLeft+t.left,width:t.width,height:t.height}}},pop:{fade:!0,position:(e,{top:t,left:n,width:o,height:a})=>({top:t+.05*a,left:n+.05*o,width:.9*o,height:.9*a})},line:{fade:!0,position:(e,{top:t,left:n,width:o,height:a})=>({top:t+a/2,left:n+.05*o,width:.9*o,height:0})},float:{fade:!0,position:(e,{top:t,left:n,width:o,height:a})=>({top:t+40,left:n,width:o,height:a})}};const i=3;function parseCssTime(e){if(!e)return 0;const t=parseFloat(e);return Number.isNaN(t)?0:/ms\s*$/i.test(e)?t:1e3*t}function getReleaseDelay(e){const t=e?.popup||document.documentElement;return parseCssTime(getComputedStyle(t).getPropertyValue("--popupable-switch-duration"))}function buildDecodeQueue(e,t=e.group?.currentIndex,{delayRelease:n=!0}={}){if(!e.group)return;const o=e.group.length,a=n?getReleaseDelay(e):0;for(let n=0;n<o;n++){const o=e.group[n];Math.abs(n-t)>i?o.releaseDecode&&!o._releaseTimer&&(a<=0?o.releaseDecode():o._releaseTimer=setTimeout(()=>{o._releaseTimer=null,o.releaseDecode()},a)):o._releaseTimer&&(clearTimeout(o._releaseTimer),o._releaseTimer=null)}const r=[];t!==e.group.currentIndex&&t>=0&&t<o&&r.push(e.group[t]);for(let n=1;n<=i;n++)t+n<o&&r.push(e.group[t+n]),t-n>=0&&r.push(e.group[t-n]);e.decodeQueue=r,runDecodeQueue(e)}function projectSnapIndex(e,t){const n=window.innerWidth,o=Math.abs(t);if(o<=Math.max(.1*n,64))return e.currentIndex;const a=Math.max(0,Math.floor((o-n/2)/n))+1,r=t>0?-1:1;return Math.max(0,Math.min(e.length-1,e.currentIndex+r*a))}const s=100;let l=0,p=null,c=-1;function scheduleDragDecodeQueue(t){if(c=t,p)return;const n=Math.max(0,s-(performance.now()-l));p=setTimeout(()=>{p=null,l=performance.now();const t=c;c=-1,t>=0&&e?.group&&t!==e.group.currentIndex&&buildDecodeQueue(e,t,{delayRelease:!1})},n)}function cancelDragDecodeQueue(){p&&(clearTimeout(p),p=null),c=-1}async function runDecodeQueue(e){if(!e.decodeQueueRunning){for(e.decodeQueueRunning=!0;e.decodeQueue&&e.decodeQueue.length&&!e.decodeAborted;){const t=e.decodeQueue.shift();try{await t.triggerDecode()}catch{}}e.decodeQueueRunning=!1}}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"),e.clearNavInactive?.(),updateExpandedSize(),e.closingContainer?.removeEventListener("transitionend",o.listener);const i=e.closingContainer??t;o.listener=t=>{if(t&&t.target!==t.currentTarget)return;i.removeEventListener("transitionend",o.listener),n.classList.add("popupable-open");const s=a?a[a.currentIndex]:e;if(s.video&&(s.zoomable?s.source.controls=!1:s.explicitControls||(s.source.controls=!0)),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);e.scheduleNavHide?.()},o.duration?i.addEventListener("transitionend",o.listener):o.listener()}function closePopupable(){if(!e||"close"===e.state)return;if(o++,e.state="close",e.decodeAborted=!0,e.decodeQueue=null,e.group)for(const t of e.group)t._releaseTimer&&(clearTimeout(t._releaseTimer),t._releaseTimer=null);document.body.classList.add("popupable-block-touch"),setTimeout(()=>document.body.classList.remove("popupable-block-touch"),300);const{cloneContainer:n,original:a,popup:r,transition:i,group:s,listeners:l}=e;a.classList.remove("popupable-loading"),r.classList.remove("popupable-active"),r.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",i.listener);const c=s?s[s.currentIndex]:e;c.video&&c.source&&(c.source.controls=!1);const u=c.original===a,d=e;i.listener=n=>{n&&n.target!==n.currentTarget||(p.removeEventListener("transitionend",i.listener),a.classList.remove("popupable-hide"),u&&c.video&&"VIDEO"===a.tagName&&!c.cloneLayer&&(a.currentTime=c.source.currentTime),u&&c.wasPlaying&&"VIDEO"===a.tagName&&a.play(),r.remove(),d===e&&(enableScroll(),t=e,e=null))},i.duration?p.addEventListener("transitionend",i.listener):i.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=1/r;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/i+"px"}else{const t=e.contentContainer,n=t.previousElementSibling&&t.nextElementSibling&&parseFloat(getComputedStyle(t,"::after").height)||0;t.style.height=n+"px"}}}const u=/\.(mp4|m4v|webm|ogv|mov|3gp|m3u8|flv)(\?|#|$)/i;function isVideo(e){const t=inheritAttr(e,"data-popupable-type");if(t)return"video"===t;if("VIDEO"===e.tagName)return!0;if("IMG"===e.tagName)return!1;const n=e.getAttribute("data-popupable-src")||e.getAttribute("src")||"";return u.test(n)}const d=e=>e.getAttribute("currentSrc")||e.getAttribute("src")||e.getAttribute("data-popupable-src");function inheritAttr(e,t){const n=e.closest(`[${t}]`);if(!n)return;const o=n.getAttribute(t);return"false"!==o?o||!0:void 0}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=e){const n=inheritAttr(e,"data-popupable-anim"),o=popupableAnimTypes[n]?n:"expand",a=popupableAnimTypes[o],r=inheritAttr(e,"data-popupable-src"),i=d(e),s=inheritAttr(e,"data-popupable-title"),l=inheritAttr(e,"data-popupable-description"),p=inheritAttr(e,"data-popupable-zoomable"),c=getComputedStyle(e),m=t===e?c:getComputedStyle(t),b=t!==e?d(t):null,f=t===e,g=document.createElement("div");g.className="popupable-clone-container",inheritAttr(e,"data-popupable-transparent")&&g.classList.add("popupable-transparent"),p&&g.classList.add("popupable-zoomable"),g.style.borderRadius=c.borderRadius,a.styles&&(g.style.border=c.border,g.style.outline=c.outline,g.style.boxShadow=c.boxShadow);const h=isVideo(e);let v=!1;const y=inheritAttr(e,"data-popupable-poster"),x=("string"==typeof y?y:null)||("VIDEO"===e.tagName?e.getAttribute("poster"):null),w=b||i||r,L=u.test(w)||h&&w===i,E=r&&i||b;let I,C,P;if(L?(I=document.createElement("video"),I.className="popupable-clone",f&&(I.src=w),I.playsInline=!0,I.controls=!1,h&&!E||(I.muted=!0,I.loop=!0,I.autoplay=!0),f&&x&&w===i&&(I.poster=x)):(I=new Image,I.className="popupable-clone",f&&(I.src=w),I.style.imageRendering=m.imageRendering),I.style.objectFit=m.objectFit,I.style.objectPosition=m.objectPosition,I.style.background=m.background,g.append(I),"VIDEO"===I.tagName?I.addEventListener("loadedmetadata",()=>updateExpandedSize()):I.addEventListener("load",()=>updateExpandedSize()),E){const t=r||i;if(u.test(t)||h&&t===i?(C=document.createElement("video"),C.className="popupable-clone-layer",f&&(C.src=t),C.playsInline=!0,C.controls=!1,h||(C.muted=!0,C.loop=!0,C.autoplay=!0),f&&x&&t===i&&(C.poster=x)):(C=new Image,C.className="popupable-clone-layer",f&&(C.src=t),C.style.imageRendering=c.imageRendering),g.append(C),"VIDEO"===C.tagName?C.addEventListener("loadedmetadata",()=>updateExpandedSize()):C.addEventListener("load",()=>updateExpandedSize()),"fill"===I.style.objectFit&&"IMG"===I.tagName){const t=e.getBoundingClientRect();e.naturalWidth&&e.naturalHeight&&Math.abs(t.width/t.height-e.naturalWidth/e.naturalHeight)<.01&&(I.style.objectFit="cover")}P=C}else P=I;h&&"VIDEO"===e.tagName&&t===e&&(L&&(I.currentTime=e.currentTime),v=!e.paused,e.pause());const A=inheritAttr(e,"data-popupable-attr");let M,N=!1;if("string"==typeof A)for(const e of A.split(",")){const t=e.trim();if(!t)continue;const n=t.indexOf("=");if(-1===n)P[t]=!0,"controls"===t&&(N=!0);else{const e=t.slice(0,n).trim(),o=t.slice(n+1).trim(),a=Number(o);"true"===o?P[e]=!0:"false"===o?P[e]=!1:""===o||Number.isNaN(a)?P[e]=o:P[e]=a,"controls"===e&&(N=!0)}}if(s||l){if(M=document.createElement("div"),M.classList="popupable-content",s){const e=document.createElement("div");e.className="popupable-title",e.textContent=s,M.append(e)}if(l){const e=document.createElement("div");e.className="popupable-description",e.textContent=l,M.append(e)}}const D=[I,C].filter(Boolean),T=Promise.all(D.filter(e=>"VIDEO"===e.tagName).map(e=>{const t=new Promise(t=>{if(e.readyState>=1)return t();e.addEventListener("loadedmetadata",t,{once:!0}),e.addEventListener("error",t,{once:!0})});if(e.poster){const n=new Promise(t=>{const n=new Image;n.addEventListener("load",t,{once:!0}),n.addEventListener("error",t,{once:!0}),n.src=e.poster});return Promise.all([n,t])}return t})),z=w,k=C?r||i:null;let S=f||!C;const F="VIDEO"===I.tagName&&x&&w===i?x:null,V=C&&"VIDEO"===C.tagName&&x&&(r||i)===i?x:null;let R=!f,O=null;const X=(e,t)=>e+Math.random()*(t-e),Y=(e,t,n)=>`hsl(${e.toFixed(0)} ${t.toFixed(0)}% ${n.toFixed(0)}%)`,$=Math.random();let W,H,B;$<.2?(W=X(6,14),H=X(22,38),B=X(20,45)):$<.55?(W=X(14,26),H=X(38,58),B=X(25,55)):$<.85?(W=X(22,38),H=X(58,75),B=X(35,65)):(W=X(32,50),H=X(72,90),B=X(40,75));const Q=X(0,360),_=(Q+X(20,140))%360,j=(Q+X(-40,220)+360)%360;function q(){R&&(R=!1,g.classList.remove("popupable-clone-loading"),S&&z&&!I.getAttribute("src")&&(I.src=z,"VIDEO"===I.tagName&&F&&(I.poster=F)),C&&k&&!C.getAttribute("src")&&(C.src=k,"VIDEO"===C.tagName&&V&&(C.poster=V)))}function U(){if(q(),O)return O;const e=D.filter(e=>"VIDEO"!==e.tagName);return e.length?(O=Promise.all(e.map(e=>e.decode?e.decode().catch(()=>{}):new Promise(t=>{if(e.complete)return t();e.addEventListener("load",t,{once:!0}),e.addEventListener("error",t,{once:!0})}))).then(()=>T),O):(O=T,O)}return g.style.setProperty("--popupable-loading-x1",X(0,100).toFixed(0)+"%"),g.style.setProperty("--popupable-loading-y1",X(0,100).toFixed(0)+"%"),g.style.setProperty("--popupable-loading-x2",X(0,100).toFixed(0)+"%"),g.style.setProperty("--popupable-loading-y2",X(0,100).toFixed(0)+"%"),g.style.setProperty("--popupable-loading-c1",`hsla(${j.toFixed(0)} ${Math.min(95,B+X(10,25)).toFixed(0)}% ${H.toFixed(0)}% / ${X(.55,.9).toFixed(2)})`),g.style.setProperty("--popupable-loading-c2",`hsla(${_.toFixed(0)} ${B.toFixed(0)}% ${(.8*H).toFixed(0)}% / ${X(.4,.75).toFixed(2)})`),g.style.setProperty("--popupable-loading-angle",X(0,360).toFixed(0)+"deg"),g.style.setProperty("--popupable-loading-a",Y(Q,.6*B,W)),g.style.setProperty("--popupable-loading-b",Y(_,.8*B,(W+H)/2)),R&&g.classList.add("popupable-clone-loading"),{id:e.dataset.popupable,original:e,cloneContainer:g,clone:I,cloneLayer:C,maintainAspect:inheritAttr(e,"data-popupable-maintain-aspect"),noUpscale:inheritAttr(e,"data-popupable-no-upscale"),counter:inheritAttr(e,"data-popupable-counter"),thumbnails:inheritAttr(e,"data-popupable-thumbnails"),order:parsePopupableOrder(inheritAttr(e,"data-popupable-order")),animationName:o,animation:a,get ready(){return U()},triggerDecode:U,ensureLoaded:q,markAsActiveInGroup:function(){S=!0,R||!z||I.getAttribute("src")||(I.src=z,"VIDEO"===I.tagName&&F&&(I.poster=F))},releaseDecode:function(){R||(R=!0,O=null,g.classList.add("popupable-clone-loading"),"VIDEO"===I.tagName?(I.paused||I.pause(),I.removeAttribute("src"),I.removeAttribute("poster"),I.load()):I.removeAttribute("src"),C&&("VIDEO"===C.tagName?(C.paused||C.pause(),C.removeAttribute("src"),C.removeAttribute("poster"),C.load()):C.removeAttribute("src")))},content:M,zoomable:p,source:P,video:h,explicitControls:N,wasPlaying:v}}let m,b,f;document.addEventListener("pointerdown",t=>{0===t.button&&(m||(n=t.target,b=t.clientX,f=t.clientY),m||"open"!==e?.state||t.target.closest(".popupable-header, .popupable-footer")||(m=!0))});let g=!1;function handleMove(t){if("open"!==e?.state||!e.group||!m)return;if(!e.popup?.classList.contains("popupable-open"))return b=t.touches?.[0].clientX??t.clientX,void(f=t.touches?.[0].clientY??t.clientY);const n=e.group[e.group.currentIndex],o=t.touches?.[0].clientX??t.clientX;!g&&Math.abs(o-b)>a&&n.video&&(g=!0,n.source.style.pointerEvents="none"),n.cloneContainer.parentElement.style.transition="initial",n.cloneContainer.parentElement.style.transform=`translateX(${o-b}px)`;const r=projectSnapIndex(e.group,o-b);r!==e.lastProjectedIndex&&(e.lastProjectedIndex=r,scheduleDragDecodeQueue(r))}document.addEventListener("mousemove",handleMove),document.addEventListener("touchmove",handleMove,{passive:!0}),document.addEventListener("pointerup",async r=>{if(0!==r.button)return;if(m){m=!1,cancelDragDecodeQueue();const Z=e.group?e.group[e.group.currentIndex]:e;g&&(g=!1,Z.source.style.pointerEvents=null),Z.cloneContainer.parentElement.style.transition=null,Z.cloneContainer.parentElement.style.transform=null;const J=r.clientX-b,ee=Math.abs(J),te=r.clientY-f,ne=Math.abs(te);if("touch"===r.pointerType&&ne>56&&ne>1.1*ee)return void closePopupable();if(e.group&&ee>a){const oe=Math.max(0,Math.floor((ee-window.innerWidth/2)/window.innerWidth));if(J>Math.max(.1*window.innerWidth,64))for(let ae=0;ae<=oe;ae++)e.goPrev();else if(J<-Math.max(.1*window.innerWidth,64))for(let re=0;re<=oe;re++)e.goNext();return void(e.blocked=!0)}}const i=r.target.closest(".popupable-viewport")&&!n.closest(".popupable-viewport");if(!i&&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-b)>a||Math.abs(r.clientY-f)>a)return;const s=(i?n.closest("[data-popupable]"):null)||r.target.closest("[data-popupable]");if(!s){if(i)return void closePopupable();if(r.target.closest(".popupable-container"))return;return void(e&&("zoomed"===e.state?e.unzoom():closePopupable()))}if(r.preventDefault(),e&&"close"!==e.state&&e.original===s)return;e&&closePopupable();const l=++o;e={transition:{},listeners:[]};const p=e,c=document.createElement("div");c.className="popupable-clones";const u=cloneElement(s),{cloneContainer:h,content:v}=u;let y;const x=s.closest("[data-popupable-group]"),w=x?.getAttribute("data-popupable-group"),L=w&&"false"!==w?w:null;if(L){const ie=[],se=new Set;for(const le of document.querySelectorAll(`[data-popupable-group="${L}"]`)){le.hasAttribute("data-popupable")&&!se.has(le)&&(se.add(le),ie.push(le));for(const pe of le.querySelectorAll("[data-popupable]")){if(se.has(pe))continue;const ce=pe.getAttribute("data-popupable-group");null!==ce&&ce!==L||pe.closest("[data-popupable-group]")!==le||(se.add(pe),ie.push(pe))}}if(ie.length){y=[];for(const[ue,de]of ie.entries())if(de===s)y.push(u),y.currentIndex=ue,c.append(h);else{const me=cloneElement(de,s);me.cloneContainer.style.display="none",y.push(me),c.append(me.cloneContainer)}for(const[be,fe]of y.entries()){if(!fe.content)continue;const ge=be-y.currentIndex;ge>0?fe.content.classList.add("popupable-content-after"):ge<0&&fe.content.classList.add("popupable-content-before")}}}else c.append(h);const E=document.createElement("div");E.className=`popupable-container popupable-anim-${u.animationName}`,u.id&&(E.id=u.id);const I=document.createElement("div");let C,P,A,M,N,D,T,z,k,S,F;I.className="popupable-viewport",(v||y&&y.some(e=>e.content))&&(C=document.createElement("div"),C.classList="popupable-content-container");const V={};if(y){u.counter&&(M=document.createElement("div"),M.className="popupable-counter"),u.thumbnails&&(N=document.createElement("div"),N.className="popupable-thumbnails",D=y.map((e,t)=>{let n;if(e.video){const t=inheritAttr(e.original,"data-popupable-poster"),o=("string"==typeof t?t:null)||("VIDEO"===e.original.tagName?e.original.getAttribute("poster"):null);o?(n=new Image,n.src=o):(n=document.createElement("video"),n.src=inheritAttr(e.original,"data-popupable-src")||d(e.original),n.muted=!0,n.playsInline=!0,n.preload="metadata",n.disablePictureInPicture=!0,n.disableRemotePlayback=!0)}else n=new Image,n.src=inheritAttr(e.original,"data-popupable-src")||d(e.original);return n.className="popupable-thumbnail",n.dataset.thumbnailIndex=t,N.append(n),n})),I.innerHTML=`\n <div class="popupable-button-container popupable-prev-container${y.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${y.currentIndex===y.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 he=I.querySelector(".popupable-next-container"),ve=I.querySelector(".popupable-prev-container");let ye,xe,we,Le;const Ee=!(navigator.maxTouchPoints>0||window.matchMedia("(hover: none)").matches);function R(){he.classList.remove("popupable-button-inactive"),ve.classList.remove("popupable-button-inactive"),e.scheduleNavHide()}function O(e){const t=y[y.currentIndex];t.video&&t.source&&(t.source.paused||(t.swipePaused=!0,t.source.pause()),t.source.controls=!1),y.currentIndex=e;const n=y[y.currentIndex];n.video&&n.source&&(n.zoomable||(n.source.controls=!0),n.source.play().catch(()=>{}),n.swipePaused=!1),F()}if(e.scheduleNavHide=()=>{Ee&&(clearTimeout(ye),Le||(ye=setTimeout(()=>{Le||(he.classList.add("popupable-button-inactive"),ve.classList.add("popupable-button-inactive"))},1500)))},e.clearNavInactive=()=>{he.classList.remove("popupable-button-inactive"),ve.classList.remove("popupable-button-inactive")},F=async()=>{const t=y[y.currentIndex];t.markAsActiveInGroup(),await t.ready,y.currentIndex?ve.classList.remove("popupable-button-disabled"):ve.classList.add("popupable-button-disabled"),y.currentIndex===y.length-1?he.classList.add("popupable-button-disabled"):he.classList.remove("popupable-button-disabled");for(const[e,t]of y.entries()){const n=e-y.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?E.id=t.id:E.removeAttribute("id"),M&&(M.textContent=`${y.currentIndex+1} / ${y.length}`),D){for(const[e,t]of D.entries())t.classList.toggle("popupable-thumbnail-active",e===y.currentIndex);const e=D[y.currentIndex];requestAnimationFrame(()=>{if(!e||!N?.isConnected)return;const t=getComputedStyle(N),n=parseFloat(t.paddingLeft)||0,o=parseFloat(t.paddingRight)||0,a=N.scrollLeft+n,r=N.scrollLeft+N.clientWidth-o,i=e.offsetLeft,s=i+e.offsetWidth;let l=N.scrollLeft;i<a?l=Math.max(0,i-n):s>r&&(l=s-N.clientWidth+o),l!==N.scrollLeft&&(T?N.scrollTo({left:l,behavior:"smooth"}):N.scrollLeft=l),T=!0})}e.closeContainer.classList.toggle("popupable-button-inactive",!t.zoomable&&!t.video),updateExpandedSize(),e.lastProjectedIndex=e.group.currentIndex,buildDecodeQueue(e)},z=()=>{y.currentIndex>=y.length-1||O(y.currentIndex+1)},k=()=>{y.currentIndex<=0||O(y.currentIndex-1)},e.listeners.push({target:he,event:"click",func:()=>z()},{target:ve,event:"click",func:()=>k()},{target:document,event:"keydown",func:t=>{if("zoomed"!==e.state)switch(t.key){case"ArrowRight":case"ArrowDown":case"PageDown":case"d":case"s":z();break;case"ArrowLeft":case"ArrowUp":case"PageUp":case"a":case"w":k();break;case"Home":y.currentIndex=0,F();break;case"End":y.currentIndex=y.length-1,F();break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":y.currentIndex=Math.min(Math.max(Number(t.key),1)-1,y.length-1),F()}}},{target:document,event:"wheel",func:t=>{if("zoomed"===e.state)return;const n=performance.now();n-(S||0)<80||(t.deltaY>50?(S=n,z()):t.deltaY<-50&&(S=n,k()))},args:{passive:!0}}),N){let Ie,Ce,Pe,Ae,Me,Ne,De,Te,ze;function X(){ze&&(cancelAnimationFrame(ze),ze=null)}function Y(){if(X(),Math.abs(Te)<.01)return;let e=performance.now();ze=requestAnimationFrame(function t(n){if(!N.isConnected)return void X();const o=N.scrollWidth-N.clientWidth;if(o<=0)return void X();const a=Math.min(32,n-e);e=n;let r=N.scrollLeft+Te*a;r<0&&(r=0),r>o&&(r=o),N.scrollLeft=r,N.scrollLeft<=.1&&Te<0||N.scrollLeft>=o-.1&&Te>0?X():(Te*=Math.pow(.8,a/16.67),Math.abs(Te)<=.002?X():ze=requestAnimationFrame(t))})}e.listeners.push({target:N,event:"pointerdown",func:e=>{if(0!==e.button)return;const t=N.scrollWidth-N.clientWidth;Pe=t>0,X(),Ie=!0,Ce=!1,Ae=e.clientX,Me=N.scrollLeft,Ne=N.scrollLeft,De=performance.now(),Te=0,Pe&&N.classList.add("popupable-thumbnails-dragging"),N.setPointerCapture(e.pointerId)}},{target:N,event:"pointermove",func:e=>{if(!Ie)return;const t=e.clientX-Ae;Math.abs(t)>a&&(Ce=!0);const n=performance.now(),o=n-De,r=Me-t;if(N.scrollLeft=r,o>0){const e=(N.scrollLeft-Ne)/o;Te=.65*Te+.35*e,Ne=N.scrollLeft,De=n}}},{target:N,event:"pointerup",func:e=>{if(!Ie)return;if(Ie=!1,Pe&&N.classList.remove("popupable-thumbnails-dragging"),N.hasPointerCapture(e.pointerId)&&N.releasePointerCapture(e.pointerId),Ce)return performance.now()-De>10&&(Te=0),void Y();const t=document.elementFromPoint(e.clientX,e.clientY)?.closest?.(".popupable-thumbnail");t&&(y.currentIndex=Number(t.dataset.thumbnailIndex),F())}},{target:N,event:"pointercancel",func:e=>{Ie&&(Ie=!1,Pe&&N.classList.remove("popupable-thumbnails-dragging"),N.hasPointerCapture(e.pointerId)&&N.releasePointerCapture(e.pointerId),X())}},{target:N,event:"wheel",func:e=>{e.stopPropagation(),e.preventDefault();const t=N.scrollWidth-N.clientWidth;if(t<=0)return;const n=Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.deltaY,o=N.scrollLeft<=.1,a=N.scrollLeft>=t-.1;if(o&&n<0||a&&n>0)return;o&&n>0&&Te<0&&(Te=0),a&&n<0&&Te>0&&(Te=0);Te=(Te||0)+.015*n,ze||Y()},args:{passive:!1}})}Ee&&(e.listeners.push({target:he,event:"pointerenter",func:()=>{Le=!0,R()}},{target:ve,event:"pointerenter",func:()=>{Le=!0,R()}},{target:he,event:"pointerleave",func:()=>{Le=!1,e.scheduleNavHide()}},{target:ve,event:"pointerleave",func:()=>{Le=!1,e.scheduleNavHide()}}),e.listeners.push({target:E,event:"pointermove",func:t=>{if("zoomed"!==e.state)return null==xe||null==we?(xe=t.clientX,void(we=t.clientY)):void(Math.abs(t.clientX-xe)<a&&Math.abs(t.clientY-we)<a||(xe=t.clientX,we=t.clientY,R()))},args:{passive:!0}}));for(const ke of y)ke.content&&C&&C.append(ke.content)}else v&&C.append(v);const $={counter:!!M,content:!!C,thumbnails:!!N},W=u.order.top.filter(e=>$[e]),H=u.order.bottom.filter(e=>$[e]);function B(e,t){e&&("counter"===t&&M?(V[e===P?"counterTop":"counterBottom"]=!0,e.append(M)):"content"===t&&C?(V[e===P?"contentTop":"contentBottom"]=!0,e.append(C)):"thumbnails"===t&&N&&(V[e===P?"thumbnailsTop":"thumbnailsBottom"]=!0,e.append(N)))}P=document.createElement("div"),P.className="popupable-header",A=document.createElement("div"),A.className="popupable-footer";for(const Se of W)B(P,Se);for(const Fe of H)B(A,Fe);I.append(P),I.append(A);const Q=document.createElement("div");Q.className="popupable-button-container popupable-close-container",Q.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>',Q.addEventListener("click",closePopupable),u.zoomable||u.video||Q.classList.add("popupable-button-inactive"),P.append(Q),E.append(c,I),Object.assign(p,u,{popup:E,group:y,contentContainer:C,thumbnailsContainer:N,orderPlacement:V,closeContainer:Q,goNext:z,goPrev:k});const _=setTimeout(()=>{l===o&&s.classList.add("popupable-loading")},250);if(await p.ready,clearTimeout(_),s.classList.remove("popupable-loading"),l!==o||e!==p||"close"===p.state)return;h.classList.add("popupable-block-transitions"),u.animation.hideSource&&s.classList.add("popupable-hide"),u.animation.crossfade&&E.classList.add("popupable-crossfade"),u.animation.fade&&E.classList.add("popupable-fade"),document.body.append(E),setCloneToOriginalRect(h,s),u.video&&u.source.play().catch(()=>{}),disableScroll();const j=getComputedStyle(E);p.transition.duration=1e3*parseFloat(j.transitionDuration)+1e3*parseFloat(j.transitionDelay),E._state=p,requestAnimationFrame(()=>{requestAnimationFrame(()=>{h.classList.remove("popupable-block-transitions"),openPopupable(E._state),y&&(F(),buildDecodeQueue(E._state))})});let q,U=0;y&&E.addEventListener("dragstart",e=>e.preventDefault());const G=new Map;function K(e,t,n,o,r=[]){if("open"!==e.state)return;let i=0;const s=t.cloneContainer.parentElement,l=s.style.transform;if(l){const e=l.match(/translateX\((-?\d+(?:\.\d+)?)px\)/);e&&(i=Number(e[1])||0)}const p=Math.abs(i)>.5;m=!1,p?(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=`${i}px 0`):(s.style.transition=null,s.style.transform=null),e.state="zoomed",E.classList.add("popupable-locked");let c,u,d=o;const b=new Map;let f,g,h,v,y,x,w,L,C,P,A=!1;const M=t.cloneContainer.getBoundingClientRect(),N=n?.clientX??M.left+M.width/2,D=n?.clientY??M.top+M.height/2;c=(N-M.left)*(1-d),u=(D-M.top)*(1-d);const T=()=>t.cloneContainer.style.transform=`translate(${c}px, ${u}px) scale(${d})`;function z(e,n,o){const a=d;var r;if(r=e,d=Math.min(6,Math.max(.5,r)),d===a)return!1;const i=t.cloneContainer.getBoundingClientRect(),s=d/a,l=n-i.left,p=o-i.top;return c+=l*(1-s),u+=p*(1-s),!0}function k(){if(1===b.size){const e=b.values().next().value;return f=e.id,g=e.x,h=e.y,v=null,y=null,void(x=null)}if(b.size>=2){f=null;const[e,t]=[...b.values()];return v=(e.x+t.x)/2,y=(e.y+t.y)/2,void(x=Math.hypot(t.x-e.x,t.y-e.y))}f=null,g=null,h=null,v=null,y=null,x=null}if(t.cloneContainer.classList.add("popupable-zoomed"),T(),r.length){p||(t.cloneContainer.style.transition="none"),P=!0;for(const e of r)b.set(e.id,{id:e.id,x:e.x,y:e.y}),E.setPointerCapture(e.id);k()}e.unzoom=()=>{e.state="open",E.classList.remove("popupable-locked");for(const e of b.keys())E.hasPointerCapture(e)&&E.releasePointerCapture(e);b.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:E,event:"pointerdown",func:e=>{0===e.button&&(t.cloneContainer.style.transition="none",E.setPointerCapture(e.pointerId),b.set(e.pointerId,{id:e.pointerId,x:e.clientX,y:e.clientY}),1===b.size?(w=e.target,L=e.clientX,C=e.clientY,P=!1):P=!0,k(),e.preventDefault())}},{target:E,event:"pointermove",func:e=>{const t=b.get(e.pointerId);if(t){if(t.x=e.clientX,t.y=e.clientY,!P&&(Math.abs(e.clientX-L)>a||Math.abs(e.clientY-C)>a)&&(P=!0),1===b.size&&f===e.pointerId){const t=e.clientX-g,n=e.clientY-h;if(!t&&!n)return;return c+=t,u+=n,g=e.clientX,h=e.clientY,void T()}if(b.size>=2){const[e,t]=[...b.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 v=n,y=o,void(x=a);c+=n-v,u+=o-y,z(d*(a/x),n,o),A=!0,v=n,y=o,x=a,T()}}}},{target:E,event:"pointerup",func:n=>{if(b.has(n.pointerId)){if(b.delete(n.pointerId),E.hasPointerCapture(n.pointerId)&&E.releasePointerCapture(n.pointerId),A&&d<=1.01&&b.size<2)return e.skipOpenTouchPointerUps=b.size,void e.unzoom();if(!b.size&&!P&&Math.abs(n.clientX-L)<a&&Math.abs(n.clientY-C)<a){if(w?.closest?.(".popupable-clone-container")===t.cloneContainer||(w===E||w===I))return void e.unzoom()}k()}}},{target:E,event:"pointercancel",func:e=>{b.has(e.pointerId)&&(b.delete(e.pointerId),E.hasPointerCapture(e.pointerId)&&E.releasePointerCapture(e.pointerId),k())}},{target:E,event:"wheel",func:e=>{t.cloneContainer.style.transition="none",z(d*Math.exp(.002*-e.deltaY),e.clientX,e.clientY)&&T()},args:{passive:!0}}];for(const t of e.zoomListeners)t.target.addEventListener(t.event,t.func,t.args)}e.listeners.push({target:E,event:"pointerdown",func:e=>{if("open"!==E._state.state||"touch"!==e.pointerType)return;const t=E._state,n=t.group?t.group[t.group.currentIndex]:t;e.target.closest(".popupable-clone-container")===n.cloneContainer&&(G.set(e.pointerId,{id:e.pointerId,x:e.clientX,y:e.clientY}),G.size>=2&&(K(t,n,e,1,[...G.values()].slice(0,2)),G.clear(),e.preventDefault()))}},{target:E,event:"pointermove",func:e=>{const t=G.get(e.pointerId);t&&(t.x=e.clientX,t.y=e.clientY)}},{target:E,event:"pointerup",func:e=>{G.delete(e.pointerId)}},{target:E,event:"pointercancel",func:e=>{G.delete(e.pointerId)}}),E.addEventListener("pointerup",t=>{if("zoomed"===E._state.state)return;if("touch"===t.pointerType&&(E._state.skipOpenTouchPointerUps||0)>0)return void E._state.skipOpenTouchPointerUps--;const o=performance.now(),a=null!=t.target.closest(".popupable-next-container, .popupable-prev-container");if(q&&o-U<250)return void(U=o);if(a?(q=!0,U=o):(q=!1,U=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=E._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"))?K(r,i,t,2):i.video&&(t.target.classList.contains("popupable-clone")||t.target.closest(".popupable-clone-container")===i.cloneContainer)||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)}
|