smartphoto 2.1.4 → 2.1.6
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 +13 -5
- package/css/smartphoto.css +18 -18
- package/css/smartphoto.min.css +1 -1
- package/js/jquery-smartphoto.js +126 -20
- package/js/jquery-smartphoto.min.js +2 -2
- package/js/smartphoto.js +126 -20
- package/js/smartphoto.min.js +2 -2
- package/lib/smartphoto.js +124 -19
- package/lib/smartphoto.mjs +124 -19
- package/lib/types/core/index.d.ts +9 -5
- package/lib/types/core/state.d.ts +6 -6
- package/lib/types/core/types.d.ts +13 -11
- package/lib/types/core/view.d.ts +2 -2
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,6 +70,14 @@ document.addEventListener('DOMContentLoaded',function(){
|
|
|
70
70
|
</script>
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
When SmartPhoto is constructed with a CSS selector string (as above), clicks are handled via a single delegated listener, so elements added to the page **after** construction (e.g. by Ajax/infinite scroll) are picked up automatically just by clicking them — no need to call `addItem()`/`addNewItem()` manually. Right before a photo is opened, SmartPhoto also reconciles that photo's group against the current DOM: newly appended matching elements are added, and elements that have since been removed from the DOM are dropped from the group (remaining indices are recalculated). This auto-detection only applies to the selector-string form; when a `NodeList`/`Element[]` is passed (or in data source mode below), add/remove items explicitly via `addItem()`/`addNewItem()`.
|
|
74
|
+
|
|
75
|
+
A few things to keep in mind:
|
|
76
|
+
- Reconciliation only happens **right before a photo is opened** (via a click, `show()`, or hash restoration) — not continuously. If an element disappears from the DOM while the viewer is already open and you `next()`/`prev()` through the same session, that removal isn't reflected until the viewer is opened again.
|
|
77
|
+
- It does not support replacing an entire container's `innerHTML` (which recreates existing elements too, as brand-new DOM nodes) — that produces duplicate items, since the old and new elements aren't recognized as the same one. Only *appending*/*removing* individual elements is supported; if you regenerate the whole container, call `destroy()` and construct a new instance instead.
|
|
78
|
+
- Changing `data-group` on an element that has already been opened/registered has no effect (the group is fixed at first registration). Changing it before the element is first interacted with is picked up correctly.
|
|
79
|
+
- If multiple instances are built with overlapping selectors, avoid relying on distinguishing exactly which instance handles a click for elements that could match either.
|
|
80
|
+
|
|
73
81
|
### Programmatic usage (data source mode)
|
|
74
82
|
|
|
75
83
|
Instead of scanning `<a>` elements in the page, you can pass an array of slide objects directly (inspired by [yet-another-react-lightbox](https://yet-another-react-lightbox.com/)). This is useful when your images come from an API or a JS-rendered list.
|
|
@@ -211,7 +219,7 @@ Slide fields:
|
|
|
211
219
|
<tr>
|
|
212
220
|
<td>animationSpeed</td>
|
|
213
221
|
<td>animation speed (ms) when switching/opening/closing images</td>
|
|
214
|
-
<td>
|
|
222
|
+
<td>450</td>
|
|
215
223
|
</tr>
|
|
216
224
|
<tr>
|
|
217
225
|
<td>forceInterval</td>
|
|
@@ -337,7 +345,7 @@ photo.on('zoomout',function(){
|
|
|
337
345
|
</tr>
|
|
338
346
|
<tr>
|
|
339
347
|
<td><code>addNewItem(element)</code></td>
|
|
340
|
-
<td>register a new <code><a></code> thumbnail element (HTML mode)</td>
|
|
348
|
+
<td>register a new <code><a></code> thumbnail element (HTML mode). Only needed when constructed with a <code>NodeList</code>/<code>Element[]</code> or otherwise not using a selector string — with a selector string, elements added later are auto-detected on click (see above)</td>
|
|
341
349
|
</tr>
|
|
342
350
|
<tr>
|
|
343
351
|
<td><code>show(indexOrId?, options?)</code></td>
|
|
@@ -353,7 +361,7 @@ photo.on('zoomout',function(){
|
|
|
353
361
|
</tr>
|
|
354
362
|
<tr>
|
|
355
363
|
<td><code>addItem(slideOrElement)</code></td>
|
|
356
|
-
<td>add a new item. Accepts a slide object (data source mode) or an <code>Element</code> (HTML mode, same as <code>addNewItem</code>)</td>
|
|
364
|
+
<td>add a new item. Accepts a slide object (data source mode, where explicit registration is always required) or an <code>Element</code> (HTML mode, same caveat as <code>addNewItem</code>)</td>
|
|
357
365
|
</tr>
|
|
358
366
|
<tr>
|
|
359
367
|
<td><code>currentIndex</code></td>
|
|
@@ -372,7 +380,7 @@ photo.on('zoomout',function(){
|
|
|
372
380
|
<tr>
|
|
373
381
|
<td>--smartphoto-animation-speed</td>
|
|
374
382
|
<td>animation speed when switching/opening/closing images. Overridden per-instance by the <code>animationSpeed</code> JS option</td>
|
|
375
|
-
<td>
|
|
383
|
+
<td>450ms</td>
|
|
376
384
|
</tr>
|
|
377
385
|
<tr>
|
|
378
386
|
<td>--smartphoto-animation-function</td>
|
|
@@ -395,7 +403,7 @@ Set these on `.smartphoto` (or `:root`) to override the defaults, no rebuild req
|
|
|
395
403
|
|
|
396
404
|
```css
|
|
397
405
|
.smartphoto {
|
|
398
|
-
--smartphoto-animation-speed:
|
|
406
|
+
--smartphoto-animation-speed: 450ms;
|
|
399
407
|
--smartphoto-animation-function: ease-in-out;
|
|
400
408
|
--smartphoto-backdrop-color: rgba(0, 0, 0, 0.9);
|
|
401
409
|
--smartphoto-header-color: rgba(0, 0, 0, 0.4);
|
package/css/smartphoto.css
CHANGED
|
@@ -110,9 +110,9 @@
|
|
|
110
110
|
* 対象に加えることで、opacity のフェードが完了するまでその適用を1フレーム分
|
|
111
111
|
* 遅らせ、閉じる瞬間に「ぱっと」消えず滑らかにフェードアウトするようにする */
|
|
112
112
|
transition:
|
|
113
|
-
opacity var(--smartphoto-animation-speed, 0.
|
|
114
|
-
display var(--smartphoto-animation-speed, 0.
|
|
115
|
-
overlay var(--smartphoto-animation-speed, 0.
|
|
113
|
+
opacity var(--smartphoto-animation-speed, 0.45s) var(--smartphoto-animation-function, ease-out),
|
|
114
|
+
display var(--smartphoto-animation-speed, 0.45s) var(--smartphoto-animation-function, ease-out) allow-discrete,
|
|
115
|
+
overlay var(--smartphoto-animation-speed, 0.45s) var(--smartphoto-animation-function, ease-out) allow-discrete;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
.smartphoto:not([open]) {
|
|
@@ -127,11 +127,11 @@
|
|
|
127
127
|
* ルート要素(html)の子として扱われ、dialog に設定した --smartphoto-animation-speed を
|
|
128
128
|
* 継承しない。そのため JS 側では document.documentElement にも同じ変数を設定しており、
|
|
129
129
|
* ここではその値を参照する。指定がなければブラウザ既定(実装依存, 概ね0.25s前後で
|
|
130
|
-
* 速すぎるとの声があった)の代わりに 0.
|
|
130
|
+
* 速すぎるとの声があった)の代わりに 0.45s を使う */
|
|
131
131
|
::view-transition-group(smartphoto-hero),
|
|
132
132
|
::view-transition-old(smartphoto-hero),
|
|
133
133
|
::view-transition-new(smartphoto-hero) {
|
|
134
|
-
animation-duration: var(--smartphoto-animation-speed, 0.
|
|
134
|
+
animation-duration: var(--smartphoto-animation-speed, 0.45s);
|
|
135
135
|
animation-timing-function: var(--smartphoto-animation-function, ease-out);
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -213,7 +213,7 @@
|
|
|
213
213
|
-moz-user-select: none;
|
|
214
214
|
-ms-user-select: none;
|
|
215
215
|
user-select: none;
|
|
216
|
-
transition: transform var(--smartphoto-animation-speed, 0.
|
|
216
|
+
transition: transform var(--smartphoto-animation-speed, 0.45s) var(--smartphoto-animation-function, ease-out);
|
|
217
217
|
|
|
218
218
|
-webkit-user-drag: none;
|
|
219
219
|
}
|
|
@@ -229,7 +229,7 @@
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
.smartphoto-img-elasticmove {
|
|
232
|
-
transition: transform var(--smartphoto-animation-speed, 0.
|
|
232
|
+
transition: transform var(--smartphoto-animation-speed, 0.45s) var(--smartphoto-animation-function, ease-out);
|
|
233
233
|
}
|
|
234
234
|
|
|
235
235
|
.smartphoto-img-wrap {
|
|
@@ -237,13 +237,13 @@
|
|
|
237
237
|
opacity: 1;
|
|
238
238
|
/* Pointer Events(ピンチ/ドラッグ)がブラウザ既定のスクロール・ズームと衝突しないようにする */
|
|
239
239
|
touch-action: none;
|
|
240
|
-
-webkit-transition: opacity var(--smartphoto-animation-speed, 0.
|
|
241
|
-
-moz-transition: opacity var(--smartphoto-animation-speed, 0.
|
|
242
|
-
-ms-transition: opacity var(--smartphoto-animation-speed, 0.
|
|
243
|
-
-o-transition: opacity var(--smartphoto-animation-speed, 0.
|
|
244
|
-
transition: opacity var(--smartphoto-animation-speed, 0.
|
|
240
|
+
-webkit-transition: opacity var(--smartphoto-animation-speed, 0.45s) var(--smartphoto-animation-function, ease-out);
|
|
241
|
+
-moz-transition: opacity var(--smartphoto-animation-speed, 0.45s) var(--smartphoto-animation-function, ease-out);
|
|
242
|
+
-ms-transition: opacity var(--smartphoto-animation-speed, 0.45s) var(--smartphoto-animation-function, ease-out);
|
|
243
|
+
-o-transition: opacity var(--smartphoto-animation-speed, 0.45s) var(--smartphoto-animation-function, ease-out);
|
|
244
|
+
transition: opacity var(--smartphoto-animation-speed, 0.45s) var(--smartphoto-animation-function, ease-out);
|
|
245
245
|
animation-name: smartphoto-img-wrap;
|
|
246
|
-
animation-duration: var(--smartphoto-animation-speed, 0.
|
|
246
|
+
animation-duration: var(--smartphoto-animation-speed, 0.45s);
|
|
247
247
|
animation-timing-function: var(--smartphoto-animation-function, ease-out);
|
|
248
248
|
}
|
|
249
249
|
|
|
@@ -265,7 +265,7 @@
|
|
|
265
265
|
left: 0;
|
|
266
266
|
opacity: 1;
|
|
267
267
|
animation-name: smartphoto-appear;
|
|
268
|
-
animation-duration: var(--smartphoto-animation-speed, 0.
|
|
268
|
+
animation-duration: var(--smartphoto-animation-speed, 0.45s);
|
|
269
269
|
animation-timing-function: var(--smartphoto-animation-function, ease-out);
|
|
270
270
|
}
|
|
271
271
|
|
|
@@ -282,7 +282,7 @@
|
|
|
282
282
|
height: 30px;
|
|
283
283
|
margin-top: -20px;
|
|
284
284
|
box-sizing: content-box;
|
|
285
|
-
animation-duration: var(--smartphoto-animation-speed, 0.
|
|
285
|
+
animation-duration: var(--smartphoto-animation-speed, 0.45s);
|
|
286
286
|
animation-timing-function: var(--smartphoto-animation-function, ease-out);
|
|
287
287
|
animation-name: smartphoto-appear;
|
|
288
288
|
}
|
|
@@ -341,7 +341,7 @@
|
|
|
341
341
|
width: 100%;
|
|
342
342
|
opacity: 1;
|
|
343
343
|
animation-name: smartphoto-appear;
|
|
344
|
-
animation-duration: var(--smartphoto-animation-speed, 0.
|
|
344
|
+
animation-duration: var(--smartphoto-animation-speed, 0.45s);
|
|
345
345
|
animation-timing-function: var(--smartphoto-animation-function, ease-out);
|
|
346
346
|
}
|
|
347
347
|
|
|
@@ -417,7 +417,7 @@
|
|
|
417
417
|
left: 0;
|
|
418
418
|
width: 100%;
|
|
419
419
|
height: 100%;
|
|
420
|
-
transition: all var(--smartphoto-animation-speed, 0.
|
|
420
|
+
transition: all var(--smartphoto-animation-speed, 0.45s) var(--smartphoto-animation-function, ease-out);
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
.smartphoto-list li:focus {
|
|
@@ -485,7 +485,7 @@
|
|
|
485
485
|
z-index: 100;
|
|
486
486
|
top: 0;
|
|
487
487
|
left: 0;
|
|
488
|
-
transition: all var(--smartphoto-animation-speed, 0.
|
|
488
|
+
transition: all var(--smartphoto-animation-speed, 0.45s) var(--smartphoto-animation-function, ease-out);
|
|
489
489
|
}
|
|
490
490
|
|
|
491
491
|
.smartphoto-sr-only {
|
package/css/smartphoto.min.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@keyframes smartphoto{0%{opacity:0}to{opacity:1}}@keyframes smartphoto-img-wrap{0%{opacity:0}to{opacity:1}}@keyframes smartphoto-inner{0%{transform:translateY(100px)}to{transform:translate(0)}}@keyframes smartphoto-loader{0%{opacity:.4;transform:rotate(0deg)}50%{opacity:1;transform:rotate(180deg)}to{opacity:.4;transform:rotate(1turn)}}@keyframes smartphoto-appear{0%{opacity:0}to{opacity:1}}@keyframes smartphoto-hide{0%{opacity:1}to{opacity:0}}:root:has(dialog.smartphoto[open]){overflow:hidden}.smartphoto{border:none;background:transparent;padding:0;margin:0;outline:none;position:fixed;inset:0;width:100%;height:100%;max-width:100%;max-height:100%;overflow:hidden;height:var(--smartphoto-vh,100dvh);max-height:var(--smartphoto-vh,100dvh);background-color:var(--smartphoto-backdrop-color,#000);opacity:1;font-family:sans-serif;cursor:pointer;transition:opacity var(--smartphoto-animation-speed,.
|
|
1
|
+
@keyframes smartphoto{0%{opacity:0}to{opacity:1}}@keyframes smartphoto-img-wrap{0%{opacity:0}to{opacity:1}}@keyframes smartphoto-inner{0%{transform:translateY(100px)}to{transform:translate(0)}}@keyframes smartphoto-loader{0%{opacity:.4;transform:rotate(0deg)}50%{opacity:1;transform:rotate(180deg)}to{opacity:.4;transform:rotate(1turn)}}@keyframes smartphoto-appear{0%{opacity:0}to{opacity:1}}@keyframes smartphoto-hide{0%{opacity:1}to{opacity:0}}:root:has(dialog.smartphoto[open]){overflow:hidden}.smartphoto{border:none;background:transparent;padding:0;margin:0;outline:none;position:fixed;inset:0;width:100%;height:100%;max-width:100%;max-height:100%;overflow:hidden;height:var(--smartphoto-vh,100dvh);max-height:var(--smartphoto-vh,100dvh);background-color:var(--smartphoto-backdrop-color,#000);opacity:1;font-family:sans-serif;cursor:pointer;transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out),display var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out) allow-discrete,overlay var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out) allow-discrete}.smartphoto:not([open]){opacity:0}.smartphoto::backdrop{background-color:var(--smartphoto-backdrop-color,#000)}::view-transition-group(smartphoto-hero),::view-transition-new(smartphoto-hero),::view-transition-old(smartphoto-hero){animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out)}.smartphoto-close{opacity:0}.smartphoto-count{display:inline-block;color:#fff;font-size:16px}.smartphoto-header{display:block;box-sizing:border-box;position:fixed;z-index:102;top:0;left:0;width:100%;height:50px;padding:15px;background-color:var(--smartphoto-header-color,rgba(0,0,0,.2))}.smartphoto-content{display:block;position:absolute;top:0;left:0;width:100%;height:100%;touch-action:none}.smartphoto-dismiss{display:block;position:absolute;top:15px;right:10px;width:20px;height:20px;padding:0;border:none;background-color:transparent;background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNmZmYiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHZpZXdCb3g9IjAgMCAyODM0LjY1IDI4MzQuNjUiPjx0aXRsZT5pY29uPC90aXRsZT48cGF0aCBkPSJNMTU3Ni40MiAxNDA2Ljc2IDI3ODQgMTk5LjE5YTU2Ljg2IDU2Ljg2IDAgMCAwIDAtODAuMThsLTc4LjkyLTc4LjkyYTU2Ljg2IDU2Ljg2IDAgMCAwLTgwLjE4IDBMMTQxNy4zMiAxMjQ3LjY2IDIwOS43NSA0MC4wOWE1Ni44NiA1Ni44NiAwIDAgMC04MC4xOCAwTDUwLjY1IDExOWE1Ni44NiA1Ni44NiAwIDAgMCAwIDgwLjE4bDEyMDcuNTggMTIwNy41OEw1MC42NSAyNjE0LjM0YTU2Ljg2IDU2Ljg2IDAgMCAwIDAgODAuMThsNzguOTIgNzguOTJhNTYuODYgNTYuODYgMCAwIDAgODAuMTggMGwxMjA3LjU3LTEyMDcuNThMMjYyNC45IDI3NzMuNDRhNTYuODYgNTYuODYgMCAwIDAgODAuMTggMGw3OC45Mi03OC45MmE1Ni44NiA1Ni44NiAwIDAgMCAwLTgwLjE4WiIvPjwvc3ZnPg==);text-shadow:0 1px 0 #fff;color:#fff;font-size:30px;text-decoration:none;cursor:pointer;line-height:1}.smartphoto-body{z-index:102;margin:0 auto}.smartphoto-body,.smartphoto-inner{position:relative;width:100%;height:100%}.smartphoto-inner{vertical-align:top}.smartphoto-img{display:none;max-width:none;width:auto;height:auto;cursor:zoom-in;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;transition:transform var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);-webkit-user-drag:none}.smartphoto-img.active{display:block}.smartphoto-img-onmove{cursor:grab;cursor:-webkit-grab;transition:none}.smartphoto-img-elasticmove{transition:transform var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out)}.smartphoto-img-wrap{display:inline-block;opacity:1;touch-action:none;-webkit-transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);-moz-transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);-ms-transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);-o-transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);transition:opacity var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out);animation-name:smartphoto-img-wrap;animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out)}.smartphoto-img-left{transform:translateX(150%)!important}.smartphoto-img-right{transform:translateX(-150%)!important}.smartphoto-arrows{list-style-type:none;margin:0;padding:0;position:relative;z-index:1002;top:50%;left:0;opacity:1;animation-name:smartphoto-appear;animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out)}.smartphoto-arrows[aria-hidden=true]{animation-name:smartphoto-hide;display:none}.smartphoto-arrows li{display:block;position:absolute;top:50%;width:30px;height:30px;margin-top:-20px;box-sizing:content-box;animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out);animation-name:smartphoto-appear}.smartphoto-arrows li:focus{outline:none}.smartphoto-arrows [aria-hidden=true]{animation-name:smartphoto-hide;display:none}.smartphoto-arrows button{appearance:none;display:block;width:100%;height:100%;margin:0;padding:0;border:none;background-color:transparent;cursor:pointer}.smartphoto-arrow-right{right:0;padding:5px 0;background-color:rgba(0,0,0,.5)}.smartphoto-arrow-right button{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNmZmYiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHZpZXdCb3g9IjAgMCAyODM0LjY1IDI4MzQuNjUiPjx0aXRsZT5pY29uPC90aXRsZT48cGF0aCBkPSJNMTgzNy44OCAxNDE3LjMyIDY0My41OSAyMjNhNzIuMjEgNzIuMjEgMCAwIDEgMC0xMDEuODJMNzQzLjgyIDIxYTcyLjIxIDcyLjIxIDAgMCAxIDEwMS44MiAwbDEyNDUuMTkgMTI0NS4xOSAxMDAuMjMgMTAwLjIzYTcyLjIxIDcyLjIxIDAgMCAxIDAgMTAxLjgyTDg0NS42NCAyODEzLjY1YTcyLjIxIDcyLjIxIDAgMCAxLTEwMS44MiAwbC0xMDAuMjMtMTAwLjIzYTcyLjIxIDcyLjIxIDAgMCAxIDAtMTAxLjgyWiIvPjwvc3ZnPg==)}.smartphoto-arrow-left{left:0;padding:5px 0;background-color:rgba(0,0,0,.5)}.smartphoto-arrow-left button{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9IiNmZmYiIGRhdGEtbmFtZT0i44Os44Kk44Ok44O8IDEiIHZpZXdCb3g9IjAgMCAyODM0LjY1IDI4MzQuNjUiPjx0aXRsZT5pY29uPC90aXRsZT48cGF0aCBkPSJNOTk2Ljc3IDE0MTcuMzIgMjE5MS4wNiAyMjNhNzIuMjEgNzIuMjEgMCAwIDAgMC0xMDEuODJMMjA5MC44MyAyMUE3Mi4yMSA3Mi4yMSAwIDAgMCAxOTg5IDIxTDc0My44MiAxMjY2LjE5bC0xMDAuMjMgMTAwLjIzYTcyLjIxIDcyLjIxIDAgMCAwIDAgMTAxLjgyTDE5ODkgMjgxMy42NWE3Mi4yMSA3Mi4yMSAwIDAgMCAxMDEuODIgMGwxMDAuMjMtMTAwLjIzYTcyLjIxIDcyLjIxIDAgMCAwIDAtMTAxLjgyWiIvPjwvc3ZnPg==)}.smartPhotoArrowHideIcon{display:none}.smartphoto-nav{position:absolute;bottom:0;left:0;width:100%;opacity:1;animation-name:smartphoto-appear;animation-duration:var(--smartphoto-animation-speed,.45s);animation-timing-function:var(--smartphoto-animation-function,ease-out)}.smartphoto-nav[aria-hidden=true]{animation-name:smartphoto-hide;display:none}.smartphoto-nav ul{display:block;overflow-x:auto;list-style:none;margin:0;padding:0;text-align:center;white-space:nowrap;-webkit-overflow-scrolling:touch}.smartphoto-nav li{display:inline-block;overflow:hidden;width:50px;height:50px}.smartphoto-nav button{appearance:none;display:block;width:100%;height:100%;margin:0;padding:0;border:none;background-color:#fff;background-position:50%;background-size:cover;opacity:.5;cursor:pointer}.smartphoto-nav button:focus{opacity:.8}.smartphoto-nav button.current{opacity:1}.smartphoto-nav img{width:auto;height:100%}.smartphoto-list{list-style-type:none;position:absolute;z-index:101;top:0;left:0;margin:0;padding:0;white-space:nowrap}.smartphoto-list li{display:block;position:absolute;top:0;left:0;width:100%;height:100%;transition:all var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out)}.smartphoto-list li:focus{outline:none}.smartphoto-list-onmove{transition:all .3s var(--smartphoto-animation-function,ease-out)}.smartphoto-caption{overflow:hidden;box-sizing:border-box;position:absolute;top:0;left:0;width:100%;height:50px;padding:0 50px;color:#fff;font-size:12px;text-align:center;line-height:50px;white-space:nowrap;text-overflow:ellipsis;margin:0;font-weight:400}.smartphoto-caption:focus{outline:none}.smartphoto-loader-wrap{display:block;position:relative;z-index:103;width:0;height:0;transform:translate(50vw,50vh);transform:translate(50vw,50dvh);transform:translate(50vw,calc(var(--smartphoto-vh, 100dvh)/2))}.smartphoto-loader{position:absolute;z-index:101;top:0;left:0;width:30px;height:30px;margin-top:-25px;margin-left:-25px;border:8px solid #17cddd;border-right-color:transparent;border-radius:50%;animation:smartphoto-loader .5s linear infinite}.smartphoto-img-clone{position:fixed;z-index:100;top:0;left:0;transition:all var(--smartphoto-animation-speed,.45s) var(--smartphoto-animation-function,ease-out)}.smartphoto-sr-only{overflow:hidden;position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;clip:rect(0,0,0,0)}
|
package/js/jquery-smartphoto.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SmartPhoto v2.1.
|
|
2
|
+
* SmartPhoto v2.1.6
|
|
3
3
|
* (c) appleple
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
loadOffset: 2,
|
|
115
115
|
resizeStyle: "fit",
|
|
116
116
|
lazyAttribute: "data-src",
|
|
117
|
-
animationSpeed:
|
|
117
|
+
animationSpeed: 450
|
|
118
118
|
};
|
|
119
119
|
function deepFreeze(obj) {
|
|
120
120
|
Object.keys(obj).forEach((key) => {
|
|
@@ -128,7 +128,11 @@
|
|
|
128
128
|
function createState(settings) {
|
|
129
129
|
return {
|
|
130
130
|
options: deepFreeze(
|
|
131
|
-
extend(
|
|
131
|
+
extend(
|
|
132
|
+
{},
|
|
133
|
+
defaults,
|
|
134
|
+
settings
|
|
135
|
+
)
|
|
132
136
|
),
|
|
133
137
|
viewer: {
|
|
134
138
|
isOpen: false,
|
|
@@ -1139,6 +1143,44 @@
|
|
|
1139
1143
|
this.timeouts = [];
|
|
1140
1144
|
this.loadAllFired = /* @__PURE__ */ new Set();
|
|
1141
1145
|
this.syncedGroupId = null;
|
|
1146
|
+
// 文字列セレクタで構築された場合のみ設定される。Ajax等で後から追加された
|
|
1147
|
+
// 要素をクリック時に動的検出するための再スキャン起点(§discoverGroupElements)
|
|
1148
|
+
this.rootSelector = null;
|
|
1149
|
+
// クリックされた要素(またはその祖先)から登録済み Item を逆引きするための
|
|
1150
|
+
// キャッシュ。documentへのイベントデリゲーションで祖先チェーンを辿る際に使う
|
|
1151
|
+
this.itemsByElement = /* @__PURE__ */ new Map();
|
|
1152
|
+
// サムネイルクリックはこの1本の document デリゲーションリスナーだけで処理する
|
|
1153
|
+
// (個別バインドは廃止)。同じクリックイベントを複数の SmartPhoto インスタンスが
|
|
1154
|
+
// 二重処理しないよう、処理済みマーカーをイベント自体に立てて後続インスタンスに
|
|
1155
|
+
// 早期returnさせる(セレクタが重複するインスタンスが同時に存在するケース)
|
|
1156
|
+
this.handleDocumentClick = (e) => {
|
|
1157
|
+
if (!(e.target instanceof Element)) {
|
|
1158
|
+
return;
|
|
1159
|
+
}
|
|
1160
|
+
const marker = e;
|
|
1161
|
+
if (marker.__smartphotoClaimed) {
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
let matched = this.findRegisteredAncestor(e.target);
|
|
1165
|
+
if (!matched && this.rootSelector) {
|
|
1166
|
+
matched = e.target.closest(this.rootSelector);
|
|
1167
|
+
}
|
|
1168
|
+
if (!matched) {
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
e.preventDefault();
|
|
1172
|
+
marker.__smartphotoClaimed = true;
|
|
1173
|
+
if (!this.itemsByElement.has(matched) && this.rootSelector) {
|
|
1174
|
+
const groupId = groupIdFromElement(matched);
|
|
1175
|
+
if (this.resyncGroupFromDom(groupId)) {
|
|
1176
|
+
this.syncCurrentGroupView();
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
const item = this.itemsByElement.get(matched);
|
|
1180
|
+
if (item) {
|
|
1181
|
+
this.openPhoto(item, matched);
|
|
1182
|
+
}
|
|
1183
|
+
};
|
|
1142
1184
|
// ---- 内部: window イベント ----
|
|
1143
1185
|
this.updateViewportHeight = () => {
|
|
1144
1186
|
this.view.refs.dialog.style.setProperty(
|
|
@@ -1150,6 +1192,7 @@
|
|
|
1150
1192
|
if (!currentItems(this.state)) {
|
|
1151
1193
|
return;
|
|
1152
1194
|
}
|
|
1195
|
+
this.updateViewportHeight();
|
|
1153
1196
|
this.resetTranslateCurrent();
|
|
1154
1197
|
this.setPosByCurrentIndex();
|
|
1155
1198
|
this.setSizeByScreen();
|
|
@@ -1172,6 +1215,7 @@
|
|
|
1172
1215
|
if (!currentItems(this.state)) {
|
|
1173
1216
|
return;
|
|
1174
1217
|
}
|
|
1218
|
+
this.updateViewportHeight();
|
|
1175
1219
|
this.resetTranslateCurrent();
|
|
1176
1220
|
this.setPosByCurrentIndex();
|
|
1177
1221
|
this.setHashByCurrentIndex();
|
|
@@ -1182,6 +1226,7 @@
|
|
|
1182
1226
|
const poll = (time) => {
|
|
1183
1227
|
this.scheduleTimeout(() => {
|
|
1184
1228
|
if (prevWidth !== getWindowWidth()) {
|
|
1229
|
+
this.updateViewportHeight();
|
|
1185
1230
|
this.resetTranslateCurrent();
|
|
1186
1231
|
this.setPosByCurrentIndex();
|
|
1187
1232
|
this.setHashByCurrentIndex();
|
|
@@ -1194,6 +1239,7 @@
|
|
|
1194
1239
|
};
|
|
1195
1240
|
poll(0);
|
|
1196
1241
|
};
|
|
1242
|
+
this.rootSelector = typeof source === "string" ? source : null;
|
|
1197
1243
|
this.state = createState(settings != null ? settings : {});
|
|
1198
1244
|
this.view = createView(
|
|
1199
1245
|
{ id: this.id, options: this.state.options },
|
|
@@ -1215,15 +1261,14 @@
|
|
|
1215
1261
|
},
|
|
1216
1262
|
{ signal: this.abortController.signal }
|
|
1217
1263
|
);
|
|
1264
|
+
document.addEventListener("click", this.handleDocumentClick, {
|
|
1265
|
+
signal: this.abortController.signal
|
|
1266
|
+
});
|
|
1218
1267
|
this.ingestSource(source);
|
|
1219
1268
|
this.syncCurrentGroupView();
|
|
1220
1269
|
const restored = this.restoreFromHash();
|
|
1221
1270
|
if (restored) {
|
|
1222
|
-
|
|
1223
|
-
triggerEvent(restored.element, "click");
|
|
1224
|
-
} else {
|
|
1225
|
-
this.openPhoto(restored, null);
|
|
1226
|
-
}
|
|
1271
|
+
this.openPhoto(restored, restored.element);
|
|
1227
1272
|
}
|
|
1228
1273
|
this.updateViewportHeight();
|
|
1229
1274
|
if (window.visualViewport) {
|
|
@@ -1268,6 +1313,7 @@
|
|
|
1268
1313
|
clearTimeout(id);
|
|
1269
1314
|
});
|
|
1270
1315
|
this.timeouts = [];
|
|
1316
|
+
this.itemsByElement.clear();
|
|
1271
1317
|
this.gestures.detach();
|
|
1272
1318
|
this.view.destroy();
|
|
1273
1319
|
}
|
|
@@ -1382,7 +1428,7 @@
|
|
|
1382
1428
|
this.gotoSlide(this.state.viewer.prev);
|
|
1383
1429
|
}
|
|
1384
1430
|
addItem(slideOrElement) {
|
|
1385
|
-
const item = slideOrElement instanceof
|
|
1431
|
+
const item = slideOrElement instanceof HTMLElement ? this.addElementItem(slideOrElement) : this.addSlideItem(slideOrElement);
|
|
1386
1432
|
this.syncCurrentGroupView();
|
|
1387
1433
|
return item;
|
|
1388
1434
|
}
|
|
@@ -1414,7 +1460,7 @@
|
|
|
1414
1460
|
);
|
|
1415
1461
|
addItemToGroup(this.state, item);
|
|
1416
1462
|
this.loadAllFired.delete(groupId);
|
|
1417
|
-
this.
|
|
1463
|
+
this.itemsByElement.set(element, item);
|
|
1418
1464
|
return item;
|
|
1419
1465
|
}
|
|
1420
1466
|
addSlideItem(slide) {
|
|
@@ -1426,15 +1472,73 @@
|
|
|
1426
1472
|
this.loadAllFired.delete(groupId);
|
|
1427
1473
|
return item;
|
|
1428
1474
|
}
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1475
|
+
// クリックされた要素(またはその祖先。<a><img></a> の img がクリックされる
|
|
1476
|
+
// ケースを含む)から、登録済み Item を持つ要素まで祖先チェーンを遡って探す
|
|
1477
|
+
findRegisteredAncestor(target) {
|
|
1478
|
+
let node = target;
|
|
1479
|
+
while (node) {
|
|
1480
|
+
if (this.itemsByElement.has(node)) {
|
|
1481
|
+
return node;
|
|
1482
|
+
}
|
|
1483
|
+
node = node.parentElement;
|
|
1484
|
+
}
|
|
1485
|
+
return null;
|
|
1486
|
+
}
|
|
1487
|
+
// rootSelector(文字列セレクタで構築した場合のみ設定される)を再スキャンし、
|
|
1488
|
+
// 指定グループを現在のDOM状態に合わせて丸ごと再構築する(追加・削除・並び順の
|
|
1489
|
+
// 変化を一度に反映)。既知要素は既存の Item オブジェクトをそのまま再利用する
|
|
1490
|
+
// ため loaded/width/height は保持され、DOM から消えた要素だけ itemsByElement
|
|
1491
|
+
// からも除去する。index/translateX は resetTranslate() で再計算する。
|
|
1492
|
+
// 呼び出し元(openPhoto)がこの結果を使い、変化があった場合のみ view を
|
|
1493
|
+
// 再同期する(§ダイアログを開く瞬間に整合を取る。開いている間の next()/prev()
|
|
1494
|
+
// では呼ばれないため、この間の追加/削除は次に開き直すまで反映されない)
|
|
1495
|
+
resyncGroupFromDom(groupId) {
|
|
1496
|
+
var _a;
|
|
1497
|
+
if (!this.rootSelector) {
|
|
1498
|
+
return false;
|
|
1499
|
+
}
|
|
1500
|
+
const domElements = Array.from(
|
|
1501
|
+
document.querySelectorAll(this.rootSelector)
|
|
1502
|
+
).filter((el) => groupIdFromElement(el) === groupId);
|
|
1503
|
+
const domElementSet = new Set(domElements);
|
|
1504
|
+
const previous = (_a = this.state.groups.get(groupId)) != null ? _a : [];
|
|
1505
|
+
const previousByElement = /* @__PURE__ */ new Map();
|
|
1506
|
+
previous.forEach((it) => {
|
|
1507
|
+
if (it.element) {
|
|
1508
|
+
previousByElement.set(it.element, it);
|
|
1509
|
+
}
|
|
1510
|
+
});
|
|
1511
|
+
let changed = domElements.length !== previous.length;
|
|
1512
|
+
const rebuilt = domElements.map((el, index) => {
|
|
1513
|
+
const existing = previousByElement.get(el);
|
|
1514
|
+
if (existing) {
|
|
1515
|
+
if (existing.index !== index) {
|
|
1516
|
+
changed = true;
|
|
1517
|
+
existing.index = index;
|
|
1518
|
+
}
|
|
1519
|
+
return existing;
|
|
1520
|
+
}
|
|
1521
|
+
changed = true;
|
|
1522
|
+
const item = itemFromElement(
|
|
1523
|
+
el,
|
|
1524
|
+
this.state.options,
|
|
1525
|
+
index,
|
|
1526
|
+
getWindowWidth()
|
|
1527
|
+
);
|
|
1528
|
+
this.itemsByElement.set(el, item);
|
|
1529
|
+
return item;
|
|
1530
|
+
});
|
|
1531
|
+
previous.forEach((it) => {
|
|
1532
|
+
if (it.element && !domElementSet.has(it.element)) {
|
|
1533
|
+
this.itemsByElement.delete(it.element);
|
|
1534
|
+
}
|
|
1535
|
+
});
|
|
1536
|
+
resetTranslate(rebuilt, getWindowWidth());
|
|
1537
|
+
this.state.groups.set(groupId, rebuilt);
|
|
1538
|
+
if (changed) {
|
|
1539
|
+
this.loadAllFired.delete(groupId);
|
|
1540
|
+
}
|
|
1541
|
+
return changed;
|
|
1438
1542
|
}
|
|
1439
1543
|
syncCurrentGroupView() {
|
|
1440
1544
|
const items = currentItems(this.state);
|
|
@@ -1692,10 +1796,11 @@
|
|
|
1692
1796
|
});
|
|
1693
1797
|
}
|
|
1694
1798
|
openPhoto(item, trigger) {
|
|
1799
|
+
const groupChanged = this.rootSelector ? this.resyncGroupFromDom(item.groupId) : false;
|
|
1695
1800
|
this.lastTriggerElement = trigger;
|
|
1696
1801
|
this.state.viewer.currentGroup = item.groupId;
|
|
1697
1802
|
this.state.viewer.currentIndex = item.index;
|
|
1698
|
-
if (this.syncedGroupId !== item.groupId) {
|
|
1803
|
+
if (this.syncedGroupId !== item.groupId || groupChanged) {
|
|
1699
1804
|
this.syncCurrentGroupView();
|
|
1700
1805
|
}
|
|
1701
1806
|
this.setHashByCurrentIndex();
|
|
@@ -1787,6 +1892,7 @@
|
|
|
1787
1892
|
this.state.viewer.photoPosX = 0;
|
|
1788
1893
|
this.state.viewer.photoPosY = 0;
|
|
1789
1894
|
this.state.viewer.onMove = true;
|
|
1895
|
+
this.updateViewportHeight();
|
|
1790
1896
|
this.setPosByCurrentIndex();
|
|
1791
1897
|
this.setHashByCurrentIndex();
|
|
1792
1898
|
this.setSizeByScreen();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* SmartPhoto v2.1.
|
|
2
|
+
* SmartPhoto v2.1.6
|
|
3
3
|
* (c) appleple
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
"use strict";(()=>{var K=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function Pe(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let r=e[o];if(r){for(let s in r)if(Object.hasOwn(r,s)){let n=r[s];n&&typeof n=="object"?t[s]=Pe((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var be=Pe,he=(t,e,i)=>{let o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,i)),t.dispatchEvent(o)},ye=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},Se=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Ge={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:300};function xe(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&xe(i)}),Object.freeze(t)}function Ie(t){return{options:xe(be({},Ge,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function de(t){return t.getAttribute("data-group")||"nogroup"}function ce(t){return t.group||"nogroup"}function Le(t,e,i,o){let r=de(t),s=t.getAttribute("href"),n=t.querySelector("img"),c=s;n&&(n.getAttribute(e.lazyAttribute)?c=n.getAttribute(e.lazyAttribute):n.currentSrc?c=n.currentSrc:c=n.src);let m="";n!=null&&n.getAttribute("alt")?m=n.getAttribute("alt"):t.getAttribute("data-caption")?m=t.getAttribute("data-caption"):m=s!=null?s:"";let v=t.getAttribute("data-id");return{src:s,thumb:c,caption:t.getAttribute("data-caption"),alt:m,groupId:r,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:v||i,loaded:!1,processed:!1,element:t}}function Ce(t,e,i){var v,g,b,C,y;let o=ce(t),r=t.src,s=(v=t.thumb)!=null?v:r,n=(g=t.caption)!=null?g:null,c=(C=(b=t.alt)!=null?b:n)!=null?C:r,m=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:c,groupId:o,translateX:i*e,translateY:0,index:e,width:m?t.width:50,height:m?t.height:50,scale:1,x:0,y:0,id:(y=t.id)!=null?y:e,loaded:m,processed:!1,element:null}}function me(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function M(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function H(t){var i;let e=M(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function pe(t){let e=M(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,r=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),r!==-1&&(t.viewer.prev=r,t.viewer.showPrevArrow=!0)}function Te(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function _(t,e){let i=10**e;return Math.round(t*i)/i}function Q(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Ae(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,c,m,v;return i>r?(m=(i-r)/2,n=-1*m):(m=(r-i)/2,n=-1*m),o>s?(v=(o-s)/2,c=-1*v):(v=(s-o)/2,c=-1*v),{minX:_(n,6)*e.scaleSize,minY:_(c,6)*e.scaleSize,maxX:_(m,6)*e.scaleSize,maxY:_(v,6)*e.scaleSize}}function Me(t,e,i,o,r){let s=i-(o+r);t.forEach(n=>{n.loaded&&(n.processed=!0,n.scale=s/n.height,n.height<s&&(n.scale=1),n.x=(n.scale-1)/2*n.width+(e-n.width*n.scale)/2,n.y=(n.scale-1)/2*n.height+(i-n.height*n.scale)/2,n.width*n.scale>e&&(n.scale=e/n.width,n.x=(n.scale-1)/2*n.width))})}function He(t){let e=H(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function ze(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function fe(t,e){let i=10**e;return Math.round(t*i)/i}function W(t){return{x:t.pageX,y:t.pageY}}function Oe(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var ke=10;function $e(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function Xe(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function Ne({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,c=null,m=null,v=null,g=0,b=!1,C=null,y=null,z=0,O=0,A=!1,V=0,S=null,L=0,X=0;function u(){return K()}function R(a){let{width:h,height:E}=Xe();return Ae(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=Xe();return Q(a,h,E,u())}function ee(a,h){let E=H(t),w=R(E);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=w.minX:a===-1&&(t.viewer.photoPosX=w.maxX),h===1?t.viewer.photoPosY=w.minY:h===-1&&(t.viewer.photoPosY=w.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let te=setInterval(()=>{if(A||s||b||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=L,t.viewer.photoPosY+=X;let a=H(t);if(!a)return;let h=R(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,L*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,L*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,X*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,X*=-.2);let E=$e(L,X),w=E.force-t.options.registance;Math.abs(w)<.5||(L=Math.cos(E.theta)*w,X=Math.sin(E.theta)*w,e.onPhotoDragMove())},t.options.forceInterval);function N(a,h){(a>5||a<-5)&&(L+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(X+=h*.05)}function J(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||A||s||b||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?N(a.gamma,a.beta):h===90?N(a.beta,a.gamma):h===-90?N(-a.beta,-a.gamma):h===180&&N(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",J,{signal:i});function ie(){A=!0,s=!1,b=!1;let a=Array.from(o.values());V=Oe(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function oe(a){let h=W(a);s=!0,n=!0,c=h,m=h,g=Date.now()}function re(a){b=!0;let h=W(a);y=h,C=h}function ne(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(w){}if(o.set(a.pointerId,W(a)),o.size>1){ie();return}if(t.viewer.scale){re(a);return}oe(a)}function se(){S===null&&(S=requestAnimationFrame(()=>{S=null,e.onGestureMove()}))}function ae(){S!==null&&(cancelAnimationFrame(S),S=null,e.onGestureMove())}function d(){let a=Array.from(o.values()),h=Oe(a[0],a[1]),E=(h-V)/100,w=t.viewer.scaleSize,I=t.viewer.photoPosX,T=t.viewer.photoPosY;t.viewer.scaleSize+=fe(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<w&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-w)*I,t.viewer.photoPosY=(1+t.viewer.scaleSize-w)*T);let B=H(t);if(B){let le=U(B);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>le}V=h,se()}function l(a){let h=W(a),E=h.x-m.x,w=h.y-c.y;n&&(e.onSwipeStart(),n=!1,v=Math.abs(E)>Math.abs(w)?"horizontal":"vertical"),v==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=w,m=h,e.onSwipeMove()}function P(a){let h=W(a),E=h.x-y.x,w=h.y-y.y,I=fe(t.viewer.scaleSize*E,6),T=fe(t.viewer.scaleSize*w,6);t.viewer.photoPosX+=I,z=I,t.viewer.photoPosY+=T,O=T,y=h,e.onPhotoDragMove()}function f(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,W(a)),A){d();return}if(b){P(a);return}l(a)}}function p(){A=!1,ae();let a=H(t);if(!a)return;let h=U(a);t.viewer.scaleSize>h||(t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scale=!1,t.viewer.scaleSize=1,t.viewer.hideUi=!1,e.onGestureEnd())}function x(){var ge;s=!1;let a=c,h=m,E=Date.now(),w=r-E,I=h.x-a.x,T=h.y-a.y,B=I===0&&T===0;if(!u()&&B){e.onTap();return}if(Math.abs(w)<=500&&B){e.onTap();return}r=E;let le=(ge=M(t))!=null?ge:[];if(v==="horizontal"){let F="stay",Ve=Math.max(E-g,1),Ee=Math.abs(I)>=ke&&Math.abs(I)/Ve>=t.options.swipeVelocity;(I>=t.options.swipeOffset||Ee&&I>0)&&t.viewer.currentIndex!==0?F="prev":(I<=-t.options.swipeOffset||Ee&&I<0)&&t.viewer.currentIndex!==le.length-1&&(F="next"),e.onSwipeEnd(F)}else{let F="stay";t.options.swipeBottomToClose&&T>=t.options.swipeOffset?F="close-bottom":t.options.swipeTopToClose&&T<=-t.options.swipeOffset&&(F="close-top"),e.onSwipeEnd(F)}}function $(){b=!1;let a=y,h=C;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=H(t);if(!E){e.onPhotoDragEnd(null);return}let w=R(E),I=t.options.swipeOffset*t.viewer.scaleSize,T=0,B=0;if(t.viewer.photoPosX>w.maxX?T=-1:t.viewer.photoPosX<w.minX&&(T=1),t.viewer.photoPosY>w.maxY?B=-1:t.viewer.photoPosY<w.minY&&(B=1),t.viewer.photoPosX-w.maxX>I&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(w.minX-t.viewer.photoPosX>I&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}T===0&&B===0?(L=z/5,X=O/5):ee(T,B),e.onPhotoDragEnd(null)}function j(a){if(o.delete(a.pointerId),A){o.size<2&&p();return}if(b){$();return}s&&x()}function D(...a){for(let h of a)h.addEventListener("pointerdown",ne,{signal:i}),h.addEventListener("pointermove",f,{signal:i}),h.addEventListener("pointerup",j,{signal:i}),h.addEventListener("pointercancel",j,{signal:i})}function G(){clearInterval(te),S!==null&&(cancelAnimationFrame(S),S=null)}return{attach:D,detach:G}}function Z(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function ve(){let t=document.createElement("button");return t.type="button",t}function Fe(t){return t.replace(/"/g,'\\"')}function Ye({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let c=document.createElement("dialog");c.className=r.smartPhoto,c.setAttribute("aria-labelledby",`smartphoto-${t}-title`),c.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let m=document.createElement("div");m.className=r.smartPhotoBody;let v=document.createElement("div");v.className=r.smartPhotoInner;let g=document.createElement("div");g.className=r.smartPhotoHeader;let b=document.createElement("span");b.className=r.smartPhotoCount;let C=document.createElement("h1");C.id=`smartphoto-${t}-title`,C.className=r.smartPhotoCaption,C.setAttribute("tabindex","-1");let y=document.createElement("button");y.className=r.smartPhotoDismiss,y.appendChild(Z(s.closeDialog)),y.addEventListener("click",()=>i.onDismiss(),{signal:o}),g.append(b,C,y);let z=document.createElement("div");z.className=r.smartPhotoContent,z.addEventListener("click",d=>{d.target===z&&i.onBackdropClick()},{signal:o});let O=document.createElement("ul");O.className=r.smartPhotoList,O.setAttribute("role","region"),O.setAttribute("aria-roledescription","carousel"),O.setAttribute("aria-label",s.carouselLabel),O.setAttribute("aria-live","polite"),O.setAttribute("aria-atomic","false"),v.append(g,z,O);let A=null,V=null,S=null;if(e.arrows){A=document.createElement("ul"),A.className=r.smartPhotoArrows,V=document.createElement("li"),V.className=r.smartPhotoArrowLeft;let d=ve();d.appendChild(Z(s.gotoPrevImage)),d.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(d),S=document.createElement("li"),S.className=r.smartPhotoArrowRight;let l=ve();l.appendChild(Z(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),S.appendChild(l),A.append(V,S),v.appendChild(A)}let L=null,X=null;e.nav&&(L=document.createElement("nav"),L.className=r.smartPhotoNav,L.setAttribute("aria-label","Choose slide to display"),X=document.createElement("ul"),L.appendChild(X),v.appendChild(L)),m.appendChild(v),c.appendChild(m),n.appendChild(c);let u={dialog:c,count:b,caption:C,dismiss:y,content:z,list:O,arrows:A,arrowLeft:V,arrowRight:S,nav:L,navList:X,slides:new Map,imgClone:null};function R(){let d=document.createElement("div");d.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,d.appendChild(l),d}function U(d){var f,p;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let P=document.createElement("img");return P.className=r.smartPhotoImg,P.src=(f=d.src)!=null?f:"",P.alt=(p=d.alt)!=null?p:"",P.addEventListener("dragstart",x=>x.preventDefault(),{signal:o}),l.appendChild(P),{imgWrap:l,img:P}}function ee(d,l){var P;u.list.replaceChildren(),(P=u.navList)==null||P.replaceChildren(),u.slides=new Map,d.forEach(f=>{var $,j;let p=document.createElement("li");p.setAttribute("role","group"),p.setAttribute("aria-roledescription","slide"),p.setAttribute("aria-label",`${f.index+1} of ${d.length}`);let x={li:p,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(f.processed){let{imgWrap:D,img:G}=U(f);p.appendChild(D),x.imgWrap=D,x.img=G}else{let D=R();p.appendChild(D),x.loaderWrap=D}if(u.list.appendChild(p),u.slides.set(f,x),u.navList){let D=document.createElement("li"),G=ve();G.style.backgroundImage=`url("${Fe(($=f.thumb)!=null?$:"")}")`;let a=f.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(Z(`go to ${(j=f.caption)!=null?j:""}`)),D.appendChild(G),u.navList.appendChild(D),x.navLink=G}}),J(l)}function te(d,l){var p;if(l.imgWrap||!d.processed)return l;let{imgWrap:P,img:f}=U(d);return(p=l.loaderWrap)==null||p.replaceWith(P),l.loaderWrap=null,l.imgWrap=P,l.img=f,l}function N(d){d&&document.activeElement&&d.contains(document.activeElement)&&u.caption.focus()}function J(d){let{viewer:l}=d;u.count.textContent=`${l.currentIndex+1}/${l.total}`,u.slides.forEach((P,f)=>{var $;let p=te(f,P),x=f.index===l.currentIndex;p.li.style.transform=`translate(${f.translateX}px,${f.translateY}px)`,p.li.classList.toggle("current",x),x?p.li.removeAttribute("aria-hidden"):p.li.setAttribute("aria-hidden","true"),x&&(u.caption.textContent=($=f.caption)!=null?$:""),p.imgWrap&&p.img&&(p.imgWrap.style.transform=`translate(${f.x}px,${f.y}px) scale(${f.scale})`,p.img.style.width=`${f.width}px`,p.img.classList.toggle("active",l.appear),p.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),p.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),p.navLink&&(p.navLink.classList.toggle("current",x),x?p.navLink.setAttribute("aria-current","true"):p.navLink.removeAttribute("aria-current"))}),u.arrowLeft&&(l.showPrevArrow?u.arrowLeft.removeAttribute("aria-hidden"):(N(u.arrowLeft),u.arrowLeft.setAttribute("aria-hidden","true"))),u.arrowRight&&(l.showNextArrow?u.arrowRight.removeAttribute("aria-hidden"):(N(u.arrowRight),u.arrowRight.setAttribute("aria-hidden","true"))),u.arrows&&(l.hideUi&&N(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.nav&&(l.hideUi&&N(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ie(d){for(let[l,P]of u.slides)if(l.index===d.viewer.currentIndex)return P;return null}function oe(d){let{viewer:l}=d,P=ie(d),f=P==null?void 0:P.img;f&&(f.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,f.classList.toggle(r.smartPhotoImgOnMove,l.scale),f.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),u.nav&&(l.hideUi&&N(u.nav),u.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),u.arrows&&(l.hideUi&&N(u.arrows),u.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function re(d){let{viewer:l}=d;u.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,u.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function ne(d){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=d.img,l.style.width=`${d.width}px`,l.style.height=`${d.height}px`,l.style.transform=`translate(${d.left}px,${d.top}px) scale(1)`,m.appendChild(l),u.imgClone=l}function se(){var d;(d=u.imgClone)==null||d.remove(),u.imgClone=null}function ae(){n.remove()}return{root:n,refs:u,render:J,syncSlides:ee,updatePhotoTransform:oe,updateListTransform:re,showAppearEffect:ne,removeAppearEffect:se,destroy:ae}}function Y(){return document.documentElement.clientWidth}function k(){let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight}function We(t){return t.length>0&&t[0]instanceof Element}function Re(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function De(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var q=class{constructor(e,i){this.id=Re();this.abortController=new AbortController;this.isSmartPhoneFlag=K();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${k()}px`)};this.handleResize=()=>{M(this.state)&&(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit())};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!M(this.state))return;this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=Y(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==Y()?(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.state=Ie(i!=null?i:{}),this.view=Ye({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Ne({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&(o.element?he(o.element,"click"):this.openPhoto(o,null)),this.updateViewportHeight(),window.visualViewport?window.visualViewport.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,r=s=>i.call(o,s);o.addEventListener(e,r,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){this.state.viewer.currentIndex=Number.parseInt(String(e),10),this.state.viewer.currentIndex||(this.state.viewer.currentIndex=0),this.slideList()}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=De();location.hash&&this.setHash(""),window.scroll(i.x,i.y),this.syncDialog(),(o=this.lastTriggerElement)!=null&&o.isConnected&&this.lastTriggerElement.focus(),this.lastTriggerElement=null,this.doHideEffect(e).then(()=>{this.view.render(this.state),this.isFiringPublicCloseEvent=!0,this.fireEvent("close"),this.isFiringPublicCloseEvent=!1})}zoomPhoto(){let e=H(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(e,Y(),k(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin")},300)))}zoomOutPhoto(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var m,v,g;let o=(m=i.group)!=null?m:this.state.viewer.currentGroup;if(o===null)return;let r=this.state.groups.get(o);if(!(r!=null&&r.length))return;let s=typeof e=="number"?r[e]:r.find(b=>b.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,c=(g=(v=i.trigger)!=null?v:s.element)!=null?g:n;this.openPhoto(s,c)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof Element?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!We(e)){e.forEach(o=>{this.addSlideItem(o)});return}Array.from(typeof e=="string"?document.querySelectorAll(e):e).forEach(o=>{this.addElementItem(o)})}addElementItem(e){var s,n;let i=de(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Le(e,this.state.options,o,Y());return me(this.state,r),this.loadAllFired.delete(i),this.bindThumbnailClick(e,r),r}addSlideItem(e){var s,n;let i=ce(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Ce(e,o,Y());return me(this.state,r),this.loadAllFired.delete(i),r}bindThumbnailClick(e,i){e.addEventListener("click",o=>{o.preventDefault(),this.openPhoto(i,e)},{signal:this.abortController.signal})}syncCurrentGroupView(){let e=M(this.state);e&&(this.view.syncSlides(e,this.state),this.syncedGroupId=this.state.viewer.currentGroup)}setHash(e){var o;if(!((o=window.history)!=null&&o.pushState)||!this.state.options.useHistoryApi)return;let i=`${location.pathname}${location.search}`;window.history.replaceState(null,"",e?`${i}#${e}`:i)}setHashByCurrentIndex(){let e=De();this.setHash(He(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?ze(this.state,ye(e)):null}setPosByCurrentIndex(){let e=H(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=M(this.state);e&&Me(e,Y(),k(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){Te(M(this.state),Y())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;this.state.viewer.isOpen&&!e.open?(e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&e.close()}commit(){this.view.render(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.view.refs.dialog.style.opacity="";let e=M(this.state);if(this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),pe(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=H(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(o,Y(),k(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,c;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{o&&(o.style.viewTransitionName="");let m=this.currentImgElement();m&&(m.style.viewTransitionName="")},s=(c=document.startViewTransition)==null?void 0:c.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i});s==null||s.ready.catch(()=>{r()}),s==null||s.finished.then(r,r)}addAppearEffect(e,i){var z;let o=(z=e==null?void 0:e.querySelector("img"))!=null?z:null;if(!o){this.state.viewer.appear=!0;return}let r=Se(o),s=o.offsetWidth,n=o.offsetHeight,c=Y(),m=k(),v=m-this.state.options.headerHeight-this.state.options.footerHeight,g=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?g=m/n:g=c/s:(s>=n?i.height<v?g=i.width/s:g=v/n:i.height<v?g=i.height/n:g=v/n,s*g>c&&(g=c/s));let b=(g-1)/2*s+(c-s*g)/2,C=(g-1)/2*n+(m-n*g)/2,y=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:y||i.src||"",afterX:b,afterY:C,scale:g}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let r=()=>{i.removeEventListener("transitionend",r,!0),o()};i.addEventListener("transitionend",r,!0),this.scheduleTimeout(()=>{i.style.transform=`translate(${e.afterX}px, ${e.afterY}px) scale(${e.scale})`},10)})}doOpen(e,i){if(this.state.options.showAnimation!==!1&&this.supportsViewTransition())this.openPhotoWithViewTransition(e);else if(this.state.options.showAnimation===!1)this.initPhoto(),this.state.viewer.appear=!0,this.commit();else{this.initPhoto(),this.addAppearEffect(e,i),this.commit();let o=this.state.viewer.appearEffect;o&&this.runAppearEffect(o).then(()=>{this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.appear=!0,this.commit()})}this.fireEvent("open"),this.resyncSizeAfterOpen()}resyncSizeAfterOpen(){let e=Y(),i=k();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(Y()===e&&k()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,this.syncedGroupId!==e.groupId&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{let o=this.view.refs.dialog,r=this.currentImgElement(),s=k(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,c=()=>{this.finishHideEffect===c&&(this.finishHideEffect=null,o.removeEventListener("transitionend",c,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=c,r&&(r.style.transform=n),o.addEventListener("transitionend",c,!0),this.scheduleTimeout(c,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=M(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{this.initPhoto(),this.commit()})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=H(this.state);this.state.viewer.onMove=!1,pe(this.state),this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.initPhoto(),this.commit()})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}fireEvent(e){he(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:()=>this.zoomPhoto(),onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},onPhotoDragMove:()=>this.view.updatePhotoTransform(this.state),onPhotoDragEnd:e=>{if(e==="zoom-out"){this.zoomOutPhoto();return}if(e==="prev"){this.gotoSlide(this.state.viewer.prev);return}if(e==="next"){this.gotoSlide(this.state.viewer.next);return}this.view.updatePhotoTransform(this.state)}}}};var Be=q;var we=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new Be(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],we);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&we(e)}var ot=we;})();
|
|
6
|
+
"use strict";(()=>{var K=()=>{let t=navigator.userAgent;return t.indexOf("iPhone")>0||t.indexOf("iPad")>0||t.indexOf("ipod")>0||t.indexOf("Android")>0};function ye(t,...e){var i;t=t||{};for(let o=0;o<e.length;o++){let r=e[o];if(r){for(let s in r)if(Object.hasOwn(r,s)){let n=r[s];n&&typeof n=="object"?t[s]=ye((i=t[s])!=null?i:{},n):t[s]=n}}}return t}var be=ye,Se=(t,e,i)=>{let o;window.CustomEvent?o=new CustomEvent(e,{cancelable:!0}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!1,!1,i)),t.dispatchEvent(o)},xe=t=>{let e={};for(let i of t.split("&")){let o=i.split("="),r=o[0],s=o.length>1?o.slice(1).join("="):r;e[r]=decodeURIComponent(s)}return e},Ie=t=>({left:t.getBoundingClientRect().left,top:t.getBoundingClientRect().top});var Ge={classNames:{smartPhoto:"smartphoto",smartPhotoClose:"smartphoto-close",smartPhotoBody:"smartphoto-body",smartPhotoInner:"smartphoto-inner",smartPhotoContent:"smartphoto-content",smartPhotoImg:"smartphoto-img",smartPhotoImgOnMove:"smartphoto-img-onmove",smartPhotoImgElasticMove:"smartphoto-img-elasticmove",smartPhotoImgWrap:"smartphoto-img-wrap",smartPhotoArrows:"smartphoto-arrows",smartPhotoNav:"smartphoto-nav",smartPhotoArrowRight:"smartphoto-arrow-right",smartPhotoArrowLeft:"smartphoto-arrow-left",smartPhotoArrowHideIcon:"smartphoto-arrow-hide",smartPhotoImgLeft:"smartphoto-img-left",smartPhotoImgRight:"smartphoto-img-right",smartPhotoList:"smartphoto-list",smartPhotoListOnMove:"smartphoto-list-onmove",smartPhotoHeader:"smartphoto-header",smartPhotoCount:"smartphoto-count",smartPhotoCaption:"smartphoto-caption",smartPhotoDismiss:"smartphoto-dismiss",smartPhotoLoader:"smartphoto-loader",smartPhotoLoaderWrap:"smartphoto-loader-wrap",smartPhotoImgClone:"smartphoto-img-clone"},message:{gotoNextImage:"go to the next image",gotoPrevImage:"go to the previous image",closeDialog:"close the image dialog",carouselLabel:"Images"},arrows:!0,nav:!0,showAnimation:!0,verticalGravity:!1,useOrientationApi:!1,useHistoryApi:!0,swipeTopToClose:!1,swipeBottomToClose:!0,swipeOffset:100,swipeVelocity:.5,headerHeight:60,footerHeight:60,forceInterval:10,registance:.5,loadOffset:2,resizeStyle:"fit",lazyAttribute:"data-src",animationSpeed:450};function Le(t){return Object.keys(t).forEach(e=>{let i=t[e];i&&typeof i=="object"&&!Object.isFrozen(i)&&Le(i)}),Object.freeze(t)}function Ce(t){return{options:Le(be({},Ge,t)),viewer:{isOpen:!1,currentGroup:null,currentIndex:0,oldIndex:0,total:0,translateX:0,translateY:0,photoPosX:0,photoPosY:0,scaleSize:1,scale:!1,elastic:!1,hideUi:!1,onMove:!1,appear:!1,appearEffect:null,prev:-1,next:-1,showPrevArrow:!1,showNextArrow:!1},groups:new Map}}function q(t){return t.getAttribute("data-group")||"nogroup"}function de(t){return t.group||"nogroup"}function ce(t,e,i,o){let r=q(t),s=t.getAttribute("href"),n=t.querySelector("img"),m=s;n&&(n.getAttribute(e.lazyAttribute)?m=n.getAttribute(e.lazyAttribute):n.currentSrc?m=n.currentSrc:m=n.src);let p="";n!=null&&n.getAttribute("alt")?p=n.getAttribute("alt"):t.getAttribute("data-caption")?p=t.getAttribute("data-caption"):p=s!=null?s:"";let u=t.getAttribute("data-id");return{src:s,thumb:m,caption:t.getAttribute("data-caption"),alt:p,groupId:r,translateX:o*i,translateY:0,index:i,width:50,height:50,scale:1,x:0,y:0,id:u||i,loaded:!1,processed:!1,element:t}}function Te(t,e,i){var u,v,P,b,S;let o=de(t),r=t.src,s=(u=t.thumb)!=null?u:r,n=(v=t.caption)!=null?v:null,m=(b=(P=t.alt)!=null?P:n)!=null?b:r,p=typeof t.width=="number"&&typeof t.height=="number";return{src:r,thumb:s,caption:n,alt:m,groupId:o,translateX:i*e,translateY:0,index:e,width:p?t.width:50,height:p?t.height:50,scale:1,x:0,y:0,id:(S=t.id)!=null?S:e,loaded:p,processed:!1,element:null}}function me(t,e){t.groups.has(e.groupId)||t.groups.set(e.groupId,[]),t.groups.get(e.groupId).push(e),t.viewer.currentGroup=e.groupId}function H(t){var e;return t.viewer.currentGroup===null?null:(e=t.groups.get(t.viewer.currentGroup))!=null?e:null}function z(t){var i;let e=H(t);return e&&(i=e[t.viewer.currentIndex])!=null?i:null}function pe(t){let e=H(t);if(!e)return;let i=e.length,o=t.viewer.currentIndex+1,r=t.viewer.currentIndex-1;t.viewer.showNextArrow=!1,t.viewer.showPrevArrow=!1,o!==i&&(t.viewer.next=o,t.viewer.showNextArrow=!0),r!==-1&&(t.viewer.prev=r,t.viewer.showPrevArrow=!0)}function fe(t,e){t.forEach((i,o)=>{i.translateX=e*o})}function Z(t,e){let i=10**e;return Math.round(t*i)/i}function Q(t,e,i,o){return o?t.width>t.height?i/(t.height*t.scale):e/(t.width*t.scale):1/t.scale}function Ae(t,e,i,o){let r=t.width*t.scale*e.scaleSize,s=t.height*t.scale*e.scaleSize,n,m,p,u;return i>r?(p=(i-r)/2,n=-1*p):(p=(r-i)/2,n=-1*p),o>s?(u=(o-s)/2,m=-1*u):(u=(s-o)/2,m=-1*u),{minX:Z(n,6)*e.scaleSize,minY:Z(m,6)*e.scaleSize,maxX:Z(p,6)*e.scaleSize,maxY:Z(u,6)*e.scaleSize}}function Me(t,e,i,o,r){let s=i-(o+r);t.forEach(n=>{n.loaded&&(n.processed=!0,n.scale=s/n.height,n.height<s&&(n.scale=1),n.x=(n.scale-1)/2*n.width+(e-n.width*n.scale)/2,n.y=(n.scale-1)/2*n.height+(i-n.height*n.scale)/2,n.width*n.scale>e&&(n.scale=e/n.width,n.x=(n.scale-1)/2*n.width))})}function He(t){let e=z(t);return e?`group=${t.viewer.currentGroup}&photo=${e.id}`:""}function ze(t,e){let i=null;return t.groups.forEach(o=>{o.forEach(r=>{e.group===r.groupId&&e.photo===r.id&&(i=r)})}),i}function ve(t,e){let i=10**e;return Math.round(t*i)/i}function R(t){return{x:t.pageX,y:t.pageY}}function Oe(t,e){let i=t.x-e.x,o=t.y-e.y;return Math.sqrt(i*i+o*o)}var ke=10;function Fe(t,e){return{force:Math.sqrt(t*t+e*e),theta:Math.atan2(e,t)}}function De(){return{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight}}function Be({state:t,callbacks:e},{signal:i}){let o=new Map,r=Date.now(),s=!1,n=!1,m=null,p=null,u=null,v=0,P=!1,b=null,S=null,O=0,D=0,M=!1,V=0,x=null,C=0,B=0;function d(){return K()}function W(a){let{width:h,height:E}=De();return Ae(a,t.viewer,h,E)}function U(a){let{width:h,height:E}=De();return Q(a,h,E,d())}function te(a,h){let E=z(t),g=W(E);t.viewer.elastic=!0,a===1?t.viewer.photoPosX=g.minX:a===-1&&(t.viewer.photoPosX=g.maxX),h===1?t.viewer.photoPosY=g.minY:h===-1&&(t.viewer.photoPosY=g.maxY),e.onPhotoDragMove(),setTimeout(()=>{t.viewer.elastic=!1,e.onPhotoDragMove()},300)}let ie=setInterval(()=>{if(M||s||P||t.viewer.elastic||!t.viewer.scale)return;t.viewer.photoPosX+=C,t.viewer.photoPosY+=B;let a=z(t);if(!a)return;let h=W(a);t.viewer.photoPosX<h.minX?(t.viewer.photoPosX=h.minX,C*=-.2):t.viewer.photoPosX>h.maxX&&(t.viewer.photoPosX=h.maxX,C*=-.2),t.viewer.photoPosY<h.minY?(t.viewer.photoPosY=h.minY,B*=-.2):t.viewer.photoPosY>h.maxY&&(t.viewer.photoPosY=h.maxY,B*=-.2);let E=Fe(C,B),g=E.force-t.options.registance;Math.abs(g)<.5||(C=Math.cos(E.theta)*g,B=Math.sin(E.theta)*g,e.onPhotoDragMove())},t.options.forceInterval);function X(a,h){(a>5||a<-5)&&(C+=a*.05),t.options.verticalGravity&&(h>5||h<-5)&&(B+=h*.05)}function J(a){if(!(a!=null&&a.gamma)||t.viewer.appearEffect||M||s||P||t.viewer.elastic||!t.viewer.scale)return;let{orientation:h}=window;h===0?X(a.gamma,a.beta):h===90?X(a.beta,a.gamma):h===-90?X(-a.beta,-a.gamma):h===180&&X(-a.gamma,-a.beta)}t.options.useOrientationApi&&window.addEventListener("deviceorientation",J,{signal:i});function oe(){M=!0,s=!1,P=!1;let a=Array.from(o.values());V=Oe(a[0],a[1]),t.viewer.scale=!0,e.onGestureStart()}function re(a){let h=R(a);s=!0,n=!0,m=h,p=h,v=Date.now()}function ne(a){P=!0;let h=R(a);S=h,b=h}function se(a){var h,E;try{(E=(h=a.currentTarget).setPointerCapture)==null||E.call(h,a.pointerId)}catch(g){}if(o.set(a.pointerId,R(a)),o.size>1){oe();return}if(t.viewer.scale){ne(a);return}re(a)}function ae(){x===null&&(x=requestAnimationFrame(()=>{x=null,e.onGestureMove()}))}function le(){x!==null&&(cancelAnimationFrame(x),x=null,e.onGestureMove())}function c(){let a=Array.from(o.values()),h=Oe(a[0],a[1]),E=(h-V)/100,g=t.viewer.scaleSize,L=t.viewer.photoPosX,T=t.viewer.photoPosY;t.viewer.scaleSize+=ve(E,6),t.viewer.scaleSize<.2&&(t.viewer.scaleSize=.2),t.viewer.scaleSize<g&&(t.viewer.photoPosX=(1+t.viewer.scaleSize-g)*L,t.viewer.photoPosY=(1+t.viewer.scaleSize-g)*T);let Y=z(t);if(Y){let he=U(Y);t.viewer.hideUi=t.viewer.scaleSize<1||t.viewer.scaleSize>he}V=h,ae()}function l(a){let h=R(a),E=h.x-p.x,g=h.y-m.y;n&&(e.onSwipeStart(),n=!1,u=Math.abs(E)>Math.abs(g)?"horizontal":"vertical"),u==="horizontal"?t.viewer.translateX+=E:t.viewer.translateY=g,p=h,e.onSwipeMove()}function y(a){let h=R(a),E=h.x-S.x,g=h.y-S.y,L=ve(t.viewer.scaleSize*E,6),T=ve(t.viewer.scaleSize*g,6);t.viewer.photoPosX+=L,O=L,t.viewer.photoPosY+=T,D=T,S=h,e.onPhotoDragMove()}function w(a){if(o.has(a.pointerId)){if(o.set(a.pointerId,R(a)),M){c();return}if(P){y(a);return}l(a)}}function f(){M=!1,le();let a=z(t);if(!a)return;let h=U(a);t.viewer.scaleSize>h||(t.viewer.photoPosX=0,t.viewer.photoPosY=0,t.viewer.scale=!1,t.viewer.scaleSize=1,t.viewer.hideUi=!1,e.onGestureEnd())}function I(){var Ee;s=!1;let a=m,h=p,E=Date.now(),g=r-E,L=h.x-a.x,T=h.y-a.y,Y=L===0&&T===0;if(!d()&&Y){e.onTap();return}if(Math.abs(g)<=500&&Y){e.onTap();return}r=E;let he=(Ee=H(t))!=null?Ee:[];if(u==="horizontal"){let $="stay",Ve=Math.max(E-v,1),Pe=Math.abs(L)>=ke&&Math.abs(L)/Ve>=t.options.swipeVelocity;(L>=t.options.swipeOffset||Pe&&L>0)&&t.viewer.currentIndex!==0?$="prev":(L<=-t.options.swipeOffset||Pe&&L<0)&&t.viewer.currentIndex!==he.length-1&&($="next"),e.onSwipeEnd($)}else{let $="stay";t.options.swipeBottomToClose&&T>=t.options.swipeOffset?$="close-bottom":t.options.swipeTopToClose&&T<=-t.options.swipeOffset&&($="close-top"),e.onSwipeEnd($)}}function F(){P=!1;let a=S,h=b;if(a.x===h.x){e.onPhotoDragEnd("zoom-out");return}let E=z(t);if(!E){e.onPhotoDragEnd(null);return}let g=W(E),L=t.options.swipeOffset*t.viewer.scaleSize,T=0,Y=0;if(t.viewer.photoPosX>g.maxX?T=-1:t.viewer.photoPosX<g.minX&&(T=1),t.viewer.photoPosY>g.maxY?Y=-1:t.viewer.photoPosY<g.minY&&(Y=1),t.viewer.photoPosX-g.maxX>L&&t.viewer.currentIndex!==0){e.onPhotoDragEnd("prev");return}if(g.minX-t.viewer.photoPosX>L&&t.viewer.currentIndex+1!==t.viewer.total){e.onPhotoDragEnd("next");return}T===0&&Y===0?(C=O/5,B=D/5):te(T,Y),e.onPhotoDragEnd(null)}function j(a){if(o.delete(a.pointerId),M){o.size<2&&f();return}if(P){F();return}s&&I()}function N(...a){for(let h of a)h.addEventListener("pointerdown",se,{signal:i}),h.addEventListener("pointermove",w,{signal:i}),h.addEventListener("pointerup",j,{signal:i}),h.addEventListener("pointercancel",j,{signal:i})}function G(){clearInterval(ie),x!==null&&(cancelAnimationFrame(x),x=null)}return{attach:N,detach:G}}function ee(t){let e=document.createElement("span");return e.className="smartphoto-sr-only",e.textContent=t,e}function we(){let t=document.createElement("button");return t.type="button",t}function $e(t){return t.replace(/"/g,'\\"')}function Xe({id:t,options:e},i,{signal:o}){let{classNames:r,message:s}=e,n=document.createElement("div");n.setAttribute("data-id",t);let m=document.createElement("dialog");m.className=r.smartPhoto,m.setAttribute("aria-labelledby",`smartphoto-${t}-title`),m.style.setProperty("--smartphoto-animation-speed",`${e.animationSpeed}ms`);let p=document.createElement("div");p.className=r.smartPhotoBody;let u=document.createElement("div");u.className=r.smartPhotoInner;let v=document.createElement("div");v.className=r.smartPhotoHeader;let P=document.createElement("span");P.className=r.smartPhotoCount;let b=document.createElement("h1");b.id=`smartphoto-${t}-title`,b.className=r.smartPhotoCaption,b.setAttribute("tabindex","-1");let S=document.createElement("button");S.className=r.smartPhotoDismiss,S.appendChild(ee(s.closeDialog)),S.addEventListener("click",()=>i.onDismiss(),{signal:o}),v.append(P,b,S);let O=document.createElement("div");O.className=r.smartPhotoContent,O.addEventListener("click",c=>{c.target===O&&i.onBackdropClick()},{signal:o});let D=document.createElement("ul");D.className=r.smartPhotoList,D.setAttribute("role","region"),D.setAttribute("aria-roledescription","carousel"),D.setAttribute("aria-label",s.carouselLabel),D.setAttribute("aria-live","polite"),D.setAttribute("aria-atomic","false"),u.append(v,O,D);let M=null,V=null,x=null;if(e.arrows){M=document.createElement("ul"),M.className=r.smartPhotoArrows,V=document.createElement("li"),V.className=r.smartPhotoArrowLeft;let c=we();c.appendChild(ee(s.gotoPrevImage)),c.addEventListener("click",()=>i.onPrev(),{signal:o}),V.appendChild(c),x=document.createElement("li"),x.className=r.smartPhotoArrowRight;let l=we();l.appendChild(ee(s.gotoNextImage)),l.addEventListener("click",()=>i.onNext(),{signal:o}),x.appendChild(l),M.append(V,x),u.appendChild(M)}let C=null,B=null;e.nav&&(C=document.createElement("nav"),C.className=r.smartPhotoNav,C.setAttribute("aria-label","Choose slide to display"),B=document.createElement("ul"),C.appendChild(B),u.appendChild(C)),p.appendChild(u),m.appendChild(p),n.appendChild(m);let d={dialog:m,count:P,caption:b,dismiss:S,content:O,list:D,arrows:M,arrowLeft:V,arrowRight:x,nav:C,navList:B,slides:new Map,imgClone:null};function W(){let c=document.createElement("div");c.className=r.smartPhotoLoaderWrap;let l=document.createElement("span");return l.className=r.smartPhotoLoader,c.appendChild(l),c}function U(c){var w,f;let l=document.createElement("div");l.className=r.smartPhotoImgWrap;let y=document.createElement("img");return y.className=r.smartPhotoImg,y.src=(w=c.src)!=null?w:"",y.alt=(f=c.alt)!=null?f:"",y.addEventListener("dragstart",I=>I.preventDefault(),{signal:o}),l.appendChild(y),{imgWrap:l,img:y}}function te(c,l){var y;d.list.replaceChildren(),(y=d.navList)==null||y.replaceChildren(),d.slides=new Map,c.forEach(w=>{var F,j;let f=document.createElement("li");f.setAttribute("role","group"),f.setAttribute("aria-roledescription","slide"),f.setAttribute("aria-label",`${w.index+1} of ${c.length}`);let I={li:f,loaderWrap:null,imgWrap:null,img:null,navLink:null};if(w.processed){let{imgWrap:N,img:G}=U(w);f.appendChild(N),I.imgWrap=N,I.img=G}else{let N=W();f.appendChild(N),I.loaderWrap=N}if(d.list.appendChild(f),d.slides.set(w,I),d.navList){let N=document.createElement("li"),G=we();G.style.backgroundImage=`url("${$e((F=w.thumb)!=null?F:"")}")`;let a=w.index;G.addEventListener("click",()=>i.onNavigate(a),{signal:o}),G.appendChild(ee(`go to ${(j=w.caption)!=null?j:""}`)),N.appendChild(G),d.navList.appendChild(N),I.navLink=G}}),J(l)}function ie(c,l){var f;if(l.imgWrap||!c.processed)return l;let{imgWrap:y,img:w}=U(c);return(f=l.loaderWrap)==null||f.replaceWith(y),l.loaderWrap=null,l.imgWrap=y,l.img=w,l}function X(c){c&&document.activeElement&&c.contains(document.activeElement)&&d.caption.focus()}function J(c){let{viewer:l}=c;d.count.textContent=`${l.currentIndex+1}/${l.total}`,d.slides.forEach((y,w)=>{var F;let f=ie(w,y),I=w.index===l.currentIndex;f.li.style.transform=`translate(${w.translateX}px,${w.translateY}px)`,f.li.classList.toggle("current",I),I?f.li.removeAttribute("aria-hidden"):f.li.setAttribute("aria-hidden","true"),I&&(d.caption.textContent=(F=w.caption)!=null?F:""),f.imgWrap&&f.img&&(f.imgWrap.style.transform=`translate(${w.x}px,${w.y}px) scale(${w.scale})`,f.img.style.width=`${w.width}px`,f.img.classList.toggle("active",l.appear),f.img.classList.toggle(r.smartPhotoImgOnMove,l.scale),f.img.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),f.navLink&&(f.navLink.classList.toggle("current",I),I?f.navLink.setAttribute("aria-current","true"):f.navLink.removeAttribute("aria-current"))}),d.arrowLeft&&(l.showPrevArrow?d.arrowLeft.removeAttribute("aria-hidden"):(X(d.arrowLeft),d.arrowLeft.setAttribute("aria-hidden","true"))),d.arrowRight&&(l.showNextArrow?d.arrowRight.removeAttribute("aria-hidden"):(X(d.arrowRight),d.arrowRight.setAttribute("aria-hidden","true"))),d.arrows&&(l.hideUi&&X(d.arrows),d.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false")),d.nav&&(l.hideUi&&X(d.nav),d.nav.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function oe(c){for(let[l,y]of d.slides)if(l.index===c.viewer.currentIndex)return y;return null}function re(c){let{viewer:l}=c,y=oe(c),w=y==null?void 0:y.img;w&&(w.style.transform=`translate(${l.photoPosX}px,${l.photoPosY}px) scale(${l.scaleSize})`,w.classList.toggle(r.smartPhotoImgOnMove,l.scale),w.classList.toggle(r.smartPhotoImgElasticMove,l.elastic)),d.nav&&(l.hideUi&&X(d.nav),d.nav.setAttribute("aria-hidden",l.hideUi?"true":"false")),d.arrows&&(l.hideUi&&X(d.arrows),d.arrows.setAttribute("aria-hidden",l.hideUi?"true":"false"))}function ne(c){let{viewer:l}=c;d.list.style.transform=`translate(${l.translateX}px,${l.translateY}px)`,d.list.classList.toggle(r.smartPhotoListOnMove,l.onMove)}function se(c){let l=document.createElement("img");l.className=r.smartPhotoImgClone,l.src=c.img,l.style.width=`${c.width}px`,l.style.height=`${c.height}px`,l.style.transform=`translate(${c.left}px,${c.top}px) scale(1)`,p.appendChild(l),d.imgClone=l}function ae(){var c;(c=d.imgClone)==null||c.remove(),d.imgClone=null}function le(){n.remove()}return{root:n,refs:d,render:J,syncSlides:te,updatePhotoTransform:re,updateListTransform:ne,showAppearEffect:se,removeAppearEffect:ae,destroy:le}}function A(){return document.documentElement.clientWidth}function k(){let t=window.visualViewport;return t?t.height*t.scale:document.documentElement.clientHeight}function Re(t){return t.length>0&&t[0]instanceof Element}function We(){return(Date.now().toString(36)+Math.random().toString(36).substring(2,7)).toUpperCase()}function Ne(){return{x:window.pageXOffset!==void 0?window.pageXOffset:document.documentElement.scrollLeft,y:window.pageYOffset!==void 0?window.pageYOffset:document.documentElement.scrollTop}}var _=class{constructor(e,i){this.id=We();this.abortController=new AbortController;this.isSmartPhoneFlag=K();this.lastTriggerElement=null;this.isFiringPublicCloseEvent=!1;this.finishHideEffect=null;this.timeouts=[];this.loadAllFired=new Set;this.syncedGroupId=null;this.rootSelector=null;this.itemsByElement=new Map;this.handleDocumentClick=e=>{if(!(e.target instanceof Element))return;let i=e;if(i.__smartphotoClaimed)return;let o=this.findRegisteredAncestor(e.target);if(!o&&this.rootSelector&&(o=e.target.closest(this.rootSelector)),!o)return;if(e.preventDefault(),i.__smartphotoClaimed=!0,!this.itemsByElement.has(o)&&this.rootSelector){let s=q(o);this.resyncGroupFromDom(s)&&this.syncCurrentGroupView()}let r=this.itemsByElement.get(o);r&&this.openPhoto(r,o)};this.updateViewportHeight=()=>{this.view.refs.dialog.style.setProperty("--smartphoto-vh",`${k()}px`)};this.handleResize=()=>{H(this.state)&&(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.commit())};this.handleKeydown=e=>{if(!this.state.viewer.isOpen)return;let i=e.keyCode||e.which;i===37?this.gotoSlide(this.state.viewer.prev):i===39?this.gotoSlide(this.state.viewer.next):i===27&&this.hidePhoto()};this.handleOrientationChange=()=>{if(!H(this.state))return;this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit();let e=A(),i=500,o=r=>{this.scheduleTimeout(()=>{e!==A()?(this.updateViewportHeight(),this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.commit()):r<=i&&o(r+25)},25)};o(0)};this.rootSelector=typeof e=="string"?e:null,this.state=Ce(i!=null?i:{}),this.view=Xe({id:this.id,options:this.state.options},this.buildViewHandlers(),{signal:this.abortController.signal}),document.body.appendChild(this.view.root),this.gestures=Be({state:this.state,callbacks:this.buildGestureCallbacks()},{signal:this.abortController.signal}),this.gestures.attach(this.view.refs.content,this.view.refs.list),this.view.refs.dialog.addEventListener("close",()=>{!this.isFiringPublicCloseEvent&&this.state.viewer.isOpen&&this.hidePhoto()},{signal:this.abortController.signal}),document.addEventListener("click",this.handleDocumentClick,{signal:this.abortController.signal}),this.ingestSource(e),this.syncCurrentGroupView();let o=this.restoreFromHash();if(o&&this.openPhoto(o,o.element),this.updateViewportHeight(),window.visualViewport?window.visualViewport.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}):window.addEventListener("resize",this.updateViewportHeight,{signal:this.abortController.signal}),!this.isSmartPhoneFlag){window.addEventListener("resize",this.handleResize,{signal:this.abortController.signal}),window.addEventListener("keydown",this.handleKeydown,{signal:this.abortController.signal});return}window.addEventListener("orientationchange",this.handleOrientationChange,{signal:this.abortController.signal})}on(e,i){let o=this.view.refs.dialog,r=s=>i.call(o,s);o.addEventListener(e,r,{signal:this.abortController.signal})}destroy(){this.state.viewer.isOpen=!1,this.view.refs.dialog.open&&this.view.refs.dialog.close(),this.abortController.abort(),this.timeouts.forEach(e=>{clearTimeout(e)}),this.timeouts=[],this.itemsByElement.clear(),this.gestures.detach(),this.view.destroy()}[Symbol.dispose](){this.destroy()}gotoSlide(e){this.state.viewer.currentIndex=Number.parseInt(String(e),10),this.state.viewer.currentIndex||(this.state.viewer.currentIndex=0),this.slideList()}hidePhoto(e="bottom"){var o;if(!this.state.viewer.isOpen)return;this.state.viewer.isOpen=!1,this.state.viewer.appear=!1,this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.scaleSize=1;let i=Ne();location.hash&&this.setHash(""),window.scroll(i.x,i.y),this.syncDialog(),(o=this.lastTriggerElement)!=null&&o.isConnected&&this.lastTriggerElement.focus(),this.lastTriggerElement=null,this.doHideEffect(e).then(()=>{this.view.render(this.state),this.isFiringPublicCloseEvent=!0,this.fireEvent("close"),this.isFiringPublicCloseEvent=!1})}zoomPhoto(){let e=z(this.state);e&&(this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(e,A(),k(),this.isSmartPhoneFlag),!(this.state.viewer.scaleSize<=1)&&(this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.scheduleTimeout(()=>{this.state.viewer.scale=!0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomin")},300)))}zoomOutPhoto(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.view.updatePhotoTransform(this.state),this.fireEvent("zoomout")}addNewItem(e){return this.addItem(e)}show(e=0,i={}){var p,u,v;let o=(p=i.group)!=null?p:this.state.viewer.currentGroup;if(o===null)return;let r=this.state.groups.get(o);if(!(r!=null&&r.length))return;let s=typeof e=="number"?r[e]:r.find(P=>P.id===e);if(!s)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null,m=(v=(u=i.trigger)!=null?u:s.element)!=null?v:n;this.openPhoto(s,m)}hide(){this.hidePhoto()}next(){this.state.viewer.showNextArrow&&this.gotoSlide(this.state.viewer.next)}prev(){this.state.viewer.showPrevArrow&&this.gotoSlide(this.state.viewer.prev)}addItem(e){let i=e instanceof HTMLElement?this.addElementItem(e):this.addSlideItem(e);return this.syncCurrentGroupView(),i}get currentIndex(){return this.state.viewer.currentIndex}ingestSource(e){if(Array.isArray(e)&&!Re(e)){e.forEach(o=>{this.addSlideItem(o)});return}Array.from(typeof e=="string"?document.querySelectorAll(e):e).forEach(o=>{this.addElementItem(o)})}addElementItem(e){var s,n;let i=q(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=ce(e,this.state.options,o,A());return me(this.state,r),this.loadAllFired.delete(i),this.itemsByElement.set(e,r),r}addSlideItem(e){var s,n;let i=de(e),o=(n=(s=this.state.groups.get(i))==null?void 0:s.length)!=null?n:0,r=Te(e,o,A());return me(this.state,r),this.loadAllFired.delete(i),r}findRegisteredAncestor(e){let i=e;for(;i;){if(this.itemsByElement.has(i))return i;i=i.parentElement}return null}resyncGroupFromDom(e){var p;if(!this.rootSelector)return!1;let i=Array.from(document.querySelectorAll(this.rootSelector)).filter(u=>q(u)===e),o=new Set(i),r=(p=this.state.groups.get(e))!=null?p:[],s=new Map;r.forEach(u=>{u.element&&s.set(u.element,u)});let n=i.length!==r.length,m=i.map((u,v)=>{let P=s.get(u);if(P)return P.index!==v&&(n=!0,P.index=v),P;n=!0;let b=ce(u,this.state.options,v,A());return this.itemsByElement.set(u,b),b});return r.forEach(u=>{u.element&&!o.has(u.element)&&this.itemsByElement.delete(u.element)}),fe(m,A()),this.state.groups.set(e,m),n&&this.loadAllFired.delete(e),n}syncCurrentGroupView(){let e=H(this.state);e&&(this.view.syncSlides(e,this.state),this.syncedGroupId=this.state.viewer.currentGroup)}setHash(e){var o;if(!((o=window.history)!=null&&o.pushState)||!this.state.options.useHistoryApi)return;let i=`${location.pathname}${location.search}`;window.history.replaceState(null,"",e?`${i}#${e}`:i)}setHashByCurrentIndex(){let e=Ne();this.setHash(He(this.state)),window.scroll(e.x,e.y)}restoreFromHash(){let e=location.hash.substring(1);return e?ze(this.state,xe(e)):null}setPosByCurrentIndex(){let e=z(this.state);e&&(this.state.viewer.translateX=-e.translateX,this.state.viewer.translateY=0,this.view.updateListTransform(this.state))}setSizeByScreen(){let e=H(this.state);e&&Me(e,A(),k(),this.state.options.headerHeight,this.state.options.footerHeight)}resetTranslateCurrent(){fe(H(this.state),A())}currentImgElement(){for(let[e,i]of this.view.refs.slides)if(e.index===this.state.viewer.currentIndex)return i.img;return null}syncDialog(){let{dialog:e,caption:i}=this.view.refs;this.state.viewer.isOpen&&!e.open?(e.showModal(),i.focus()):!this.state.viewer.isOpen&&e.open&&e.close()}commit(){this.view.render(this.state),this.syncDialog()}initPhoto(){var i;(i=this.finishHideEffect)==null||i.call(this),this.view.refs.dialog.style.opacity="";let e=H(this.state);if(this.state.viewer.total=e.length,this.state.viewer.isOpen=!0,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.setPosByCurrentIndex(),this.setSizeByScreen(),pe(this.state),this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag){let o=z(this.state);this.state.viewer.scale=!0,this.state.viewer.hideUi=!0,this.state.viewer.scaleSize=Q(o,A(),k(),this.isSmartPhoneFlag)}}supportsViewTransition(){return typeof document.startViewTransition=="function"}openPhotoWithViewTransition(e){var n,m;document.documentElement.style.setProperty("--smartphoto-animation-speed",`${this.state.options.animationSpeed}ms`);let i="smartphoto-hero",o=(n=e==null?void 0:e.querySelector("img"))!=null?n:null;o&&(o.style.viewTransitionName=i);let r=()=>{o&&(o.style.viewTransitionName="");let p=this.currentImgElement();p&&(p.style.viewTransitionName="")},s=(m=document.startViewTransition)==null?void 0:m.call(document,()=>{this.initPhoto(),this.state.viewer.appear=!0,this.commit(),o&&(o.style.viewTransitionName=""),this.currentImgElement().style.viewTransitionName=i});s==null||s.ready.catch(()=>{r()}),s==null||s.finished.then(r,r)}addAppearEffect(e,i){var O;let o=(O=e==null?void 0:e.querySelector("img"))!=null?O:null;if(!o){this.state.viewer.appear=!0;return}let r=Ie(o),s=o.offsetWidth,n=o.offsetHeight,m=A(),p=k(),u=p-this.state.options.headerHeight-this.state.options.footerHeight,v=1;this.state.options.resizeStyle==="fill"&&this.isSmartPhoneFlag?s>n?v=p/n:v=m/s:(s>=n?i.height<u?v=i.width/s:v=u/n:i.height<u?v=i.height/n:v=u/n,s*v>m&&(v=m/s));let P=(v-1)/2*s+(m-s*v)/2,b=(v-1)/2*n+(p-n*v)/2,S=o.getAttribute(this.state.options.lazyAttribute);this.state.viewer.appearEffect={width:s,height:n,top:r.top,left:r.left,once:!0,img:S||i.src||"",afterX:P,afterY:b,scale:v}}runAppearEffect(e){this.view.showAppearEffect(e);let i=this.view.refs.imgClone;return new Promise(o=>{let r=()=>{i.removeEventListener("transitionend",r,!0),o()};i.addEventListener("transitionend",r,!0),this.scheduleTimeout(()=>{i.style.transform=`translate(${e.afterX}px, ${e.afterY}px) scale(${e.scale})`},10)})}doOpen(e,i){if(this.state.options.showAnimation!==!1&&this.supportsViewTransition())this.openPhotoWithViewTransition(e);else if(this.state.options.showAnimation===!1)this.initPhoto(),this.state.viewer.appear=!0,this.commit();else{this.initPhoto(),this.addAppearEffect(e,i),this.commit();let o=this.state.viewer.appearEffect;o&&this.runAppearEffect(o).then(()=>{this.state.viewer.appearEffect=null,this.view.removeAppearEffect(),this.state.viewer.appear=!0,this.commit()})}this.fireEvent("open"),this.resyncSizeAfterOpen()}resyncSizeAfterOpen(){let e=A(),i=k();requestAnimationFrame(()=>{this.state.viewer.isOpen&&(A()===e&&k()===i||(this.resetTranslateCurrent(),this.setPosByCurrentIndex(),this.setSizeByScreen(),this.view.render(this.state)))})}openPhoto(e,i){let o=this.rootSelector?this.resyncGroupFromDom(e.groupId):!1;this.lastTriggerElement=i,this.state.viewer.currentGroup=e.groupId,this.state.viewer.currentIndex=e.index,(this.syncedGroupId!==e.groupId||o)&&this.syncCurrentGroupView(),this.setHashByCurrentIndex(),e.loaded?this.doOpen(i,e):this.loadItem(e).then(()=>{this.doOpen(i,e)})}doHideEffect(e){return new Promise(i=>{let o=this.view.refs.dialog,r=this.currentImgElement(),s=k(),n=e==="top"?`translateY(-${s}px)`:`translateY(${s}px)`,m=()=>{this.finishHideEffect===m&&(this.finishHideEffect=null,o.removeEventListener("transitionend",m,!0),r&&r.style.transform===n&&(r.style.transform=""),i())};this.finishHideEffect=m,r&&(r.style.transform=n),o.addEventListener("transitionend",m,!0),this.scheduleTimeout(m,this.state.options.animationSpeed+100)})}loadItem(e){return new Promise(i=>{var r;let o=new Image;o.onload=()=>{e.width=o.width,e.height=o.height,e.loaded=!0,this.checkLoadAll(e.groupId),i()},o.onerror=()=>i(),o.src=(r=e.src)!=null?r:""})}checkLoadAll(e){if(this.loadAllFired.has(e))return;let i=this.state.groups.get(e);i!=null&&i.length&&i.every(o=>o.loaded)&&(this.loadAllFired.add(e),this.fireEvent("loadall"))}loadNeighborItems(){let e=H(this.state);if(!e)return;let{currentIndex:i}=this.state.viewer,{loadOffset:o}=this.state.options,r=[];for(let s=i-o;s<i+o;s++){let n=e[s];n&&!n.loaded&&r.push(this.loadItem(n))}r.length&&Promise.all(r).then(()=>{this.initPhoto(),this.commit()})}slideList(){this.state.viewer.scaleSize=1,this.state.viewer.hideUi=!1,this.state.viewer.scale=!1,this.state.viewer.photoPosX=0,this.state.viewer.photoPosY=0,this.state.viewer.onMove=!0,this.updateViewportHeight(),this.setPosByCurrentIndex(),this.setHashByCurrentIndex(),this.setSizeByScreen(),this.scheduleTimeout(()=>{let e=z(this.state);this.state.viewer.onMove=!1,pe(this.state),this.commit(),this.state.viewer.oldIndex!==this.state.viewer.currentIndex&&this.fireEvent("change"),this.state.viewer.oldIndex=this.state.viewer.currentIndex,this.loadNeighborItems(),e&&!e.loaded&&this.loadItem(e).then(()=>{this.initPhoto(),this.commit()})},200)}scheduleTimeout(e,i){let o=window.setTimeout(()=>{this.timeouts=this.timeouts.filter(r=>r!==o),e()},i);return this.timeouts.push(o),o}fireEvent(e){Se(this.view.refs.dialog,e)}buildViewHandlers(){return{onDismiss:()=>this.hidePhoto(),onPrev:()=>this.prev(),onNext:()=>this.next(),onNavigate:e=>this.gotoSlide(e),onBackdropClick:()=>this.hidePhoto()}}buildGestureCallbacks(){return{onSwipeStart:()=>this.fireEvent("swipestart"),onSwipeMove:()=>this.view.updateListTransform(this.state),onSwipeEnd:e=>{if(this.fireEvent("swipeend"),e==="close-bottom"){this.hidePhoto("bottom");return}if(e==="close-top"){this.hidePhoto("top");return}e==="prev"?this.state.viewer.currentIndex-=1:e==="next"&&(this.state.viewer.currentIndex+=1),this.slideList()},onTap:()=>this.zoomPhoto(),onGestureStart:()=>{this.fireEvent("gesturestart"),this.view.updatePhotoTransform(this.state)},onGestureMove:()=>this.view.updatePhotoTransform(this.state),onGestureEnd:()=>{this.fireEvent("gestureend"),this.view.updatePhotoTransform(this.state)},onPhotoDragMove:()=>this.view.updatePhotoTransform(this.state),onPhotoDragEnd:e=>{if(e==="zoom-out"){this.zoomOutPhoto();return}if(e==="prev"){this.gotoSlide(this.state.viewer.prev);return}if(e==="next"){this.gotoSlide(this.state.viewer.next);return}this.view.updatePhotoTransform(this.state)}}}};var Ye=_;var ge=t=>{t.fn.SmartPhoto=function(e){return typeof e=="string"||new Ye(this,e),this}};if(typeof define=="function"&&define.amd)define(["jquery"],ge);else{let t=window,e=t.jQuery?t.jQuery:t.$;typeof e!="undefined"&&ge(e)}var ot=ge;})();
|