zoomora 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -73
- package/dist/zoomora.css +2 -2
- package/dist/zoomora.es.js +1210 -1221
- package/dist/zoomora.es.js.map +1 -1
- package/dist/zoomora.es.min.js +508 -519
- package/dist/zoomora.umd.js +1200 -1215
- package/dist/zoomora.umd.js.map +1 -1
- package/dist/zoomora.umd.min.js +507 -522
- package/package.json +2 -1
- package/src/styles/zoomora.scss +23 -4
- package/src/zoomora.js +1463 -1434
package/dist/zoomora.es.min.js
CHANGED
|
@@ -1,50 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
try {
|
|
4
|
-
return t && (e = t(t = 0)), e;
|
|
5
|
-
} catch (t) {
|
|
6
|
-
throw s = [t], t;
|
|
7
|
-
}
|
|
8
|
-
}, e = (t, e) => () => (e || (t((e = { exports: {} }).exports, e), t = null), e.exports), s = t(() => {});
|
|
9
|
-
function o(t) {
|
|
10
|
-
return o = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
|
|
1
|
+
function t(e) {
|
|
2
|
+
return t = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
|
|
11
3
|
return typeof t;
|
|
12
4
|
} : function(t) {
|
|
13
5
|
return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
|
|
14
|
-
},
|
|
6
|
+
}, t(e);
|
|
15
7
|
}
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var s = t[Symbol.toPrimitive];
|
|
24
|
-
if (void 0 !== s) {
|
|
25
|
-
var i = s.call(t, e || "default");
|
|
26
|
-
if ("object" != o(i)) return i;
|
|
8
|
+
function e(e) {
|
|
9
|
+
var s = function(e, s) {
|
|
10
|
+
if ("object" != t(e) || !e) return e;
|
|
11
|
+
var o = e[Symbol.toPrimitive];
|
|
12
|
+
if (void 0 !== o) {
|
|
13
|
+
var i = o.call(e, s || "default");
|
|
14
|
+
if ("object" != t(i)) return i;
|
|
27
15
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
28
16
|
}
|
|
29
|
-
return ("string" ===
|
|
30
|
-
}(
|
|
31
|
-
return "symbol" ==
|
|
17
|
+
return ("string" === s ? String : Number)(e);
|
|
18
|
+
}(e, "string");
|
|
19
|
+
return "symbol" == t(s) ? s : s + "";
|
|
32
20
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function l(t, e, s) {
|
|
37
|
-
return (e = a(e)) in t ? Object.defineProperty(t, e, {
|
|
38
|
-
value: s,
|
|
21
|
+
function s(t, s, o) {
|
|
22
|
+
return (s = e(s)) in t ? Object.defineProperty(t, s, {
|
|
23
|
+
value: o,
|
|
39
24
|
enumerable: !0,
|
|
40
25
|
configurable: !0,
|
|
41
26
|
writable: !0
|
|
42
|
-
}) : t[
|
|
27
|
+
}) : t[s] = o, t;
|
|
43
28
|
}
|
|
44
|
-
|
|
45
|
-
r();
|
|
46
|
-
});
|
|
47
|
-
function c(t, e) {
|
|
29
|
+
function o(t, e) {
|
|
48
30
|
var s = Object.keys(t);
|
|
49
31
|
if (Object.getOwnPropertySymbols) {
|
|
50
32
|
var o = Object.getOwnPropertySymbols(t);
|
|
@@ -54,494 +36,501 @@ function c(t, e) {
|
|
|
54
36
|
}
|
|
55
37
|
return s;
|
|
56
38
|
}
|
|
57
|
-
function
|
|
39
|
+
function i(t) {
|
|
58
40
|
for (var e = 1; e < arguments.length; e++) {
|
|
59
|
-
var
|
|
60
|
-
e % 2 ?
|
|
61
|
-
|
|
62
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(
|
|
63
|
-
Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(
|
|
41
|
+
var i = null != arguments[e] ? arguments[e] : {};
|
|
42
|
+
e % 2 ? o(Object(i), !0).forEach(function(e) {
|
|
43
|
+
s(t, e, i[e]);
|
|
44
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(i)) : o(Object(i)).forEach(function(e) {
|
|
45
|
+
Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(i, e));
|
|
64
46
|
});
|
|
65
47
|
}
|
|
66
48
|
return t;
|
|
67
49
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}, n.
|
|
336
|
-
|
|
337
|
-
}, o.appendChild(
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
document.exitFullscreen ? document.exitFullscreen().then(() => {
|
|
466
|
-
this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons();
|
|
467
|
-
}).catch((t) => {
|
|
468
|
-
this.fallbackExitFullscreen();
|
|
469
|
-
}) : document.webkitExitFullscreen ? (document.webkitExitFullscreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : document.mozCancelFullScreen ? (document.mozCancelFullScreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : document.msExitFullscreen ? (document.msExitFullscreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : this.fallbackExitFullscreen();
|
|
470
|
-
} catch (t) {
|
|
471
|
-
this.fallbackExitFullscreen();
|
|
472
|
-
}
|
|
473
|
-
else this.fallbackExitFullscreen();
|
|
474
|
-
}
|
|
475
|
-
fallbackFullscreen() {
|
|
50
|
+
/*!
|
|
51
|
+
* Zoomora Lightbox Plugin v1.4.0
|
|
52
|
+
* A modern, responsive lightbox plugin with zoom, fullscreen, and gallery features
|
|
53
|
+
*
|
|
54
|
+
* Copyright (c) 2026 Faruk Ahmed (FrontTheme)
|
|
55
|
+
* Licensed under MIT License
|
|
56
|
+
*/ var n = class t {
|
|
57
|
+
static get defaults() {
|
|
58
|
+
return {
|
|
59
|
+
selector: "[data-zoomora]",
|
|
60
|
+
showCounter: !0,
|
|
61
|
+
showThumbnails: !0,
|
|
62
|
+
showFullscreen: !0,
|
|
63
|
+
showZoom: !0,
|
|
64
|
+
transition: "fade",
|
|
65
|
+
useHref: !1,
|
|
66
|
+
maxZoomScale: 3,
|
|
67
|
+
zoomStep: .1,
|
|
68
|
+
animationDuration: 300,
|
|
69
|
+
closeOnBackgroundClick: !0,
|
|
70
|
+
autoplayVideos: !1,
|
|
71
|
+
onOpen: null,
|
|
72
|
+
onClose: null,
|
|
73
|
+
onNext: null,
|
|
74
|
+
onPrev: null,
|
|
75
|
+
showAutoHideToggle: !0,
|
|
76
|
+
autoHideDelay: 3e3,
|
|
77
|
+
autoHideEnabled: !1
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
constructor(e = {}) {
|
|
81
|
+
this.options = i(i({}, t.defaults), e), this.currentIndex = 0, this.items = [], this.isZoomed = !1, this.isFullscreen = !1, this.isDragging = !1, this.thumbnailsVisible = !0, this.startX = 0, this.startY = 0, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.isInitialized = !1, this.eventListeners = /* @__PURE__ */ new Map(), this.autoHideEnabled = !1, this.autoHideTimeout = null, this.autoHideDelay = 3e3, this.isControlsVisible = !0, this.lastDragTime = 0, this.boundMethods = {
|
|
82
|
+
handleDocumentClick: this.handleDocumentClick.bind(this),
|
|
83
|
+
handleKeydown: this.handleKeydown.bind(this),
|
|
84
|
+
handleFullscreenChange: this.handleFullscreenChange.bind(this),
|
|
85
|
+
handleZoomoraClick: this.handleZoomoraClick.bind(this),
|
|
86
|
+
handleContentClick: this.handleContentClick.bind(this),
|
|
87
|
+
handleMouseDown: this.handleMouseDown.bind(this),
|
|
88
|
+
handleMouseMove: this.handleMouseMove.bind(this),
|
|
89
|
+
handleMouseUp: this.handleMouseUp.bind(this),
|
|
90
|
+
handleTouchStart: this.handleTouchStart.bind(this),
|
|
91
|
+
handleTouchMove: this.handleTouchMove.bind(this),
|
|
92
|
+
handleTouchEnd: this.handleTouchEnd.bind(this),
|
|
93
|
+
handleWheel: this.handleWheel.bind(this)
|
|
94
|
+
}, this.init();
|
|
95
|
+
}
|
|
96
|
+
init() {
|
|
97
|
+
if (!this.isInitialized) try {
|
|
98
|
+
this.createLightbox(), this.bindEvents(), this.isInitialized = !0;
|
|
99
|
+
} catch (t) {}
|
|
100
|
+
}
|
|
101
|
+
static bind(e, s = {}) {
|
|
102
|
+
return new t(i(i({}, s), {}, {
|
|
103
|
+
selector: e,
|
|
104
|
+
useHref: !0
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
createLightbox() {
|
|
108
|
+
if (document.getElementById("zoomoraLightbox")) return;
|
|
109
|
+
const t = this.options.showAutoHideToggle ? "\n <button class=\"zoomora-btn\" id=\"zoomoraAutoHideBtn\" title=\"Toggle Auto-Hide Controls\">\n <i class=\"zoomorai-controls-off\"></i>\n </button>\n " : "", e = `\n <div class="zoomora" id="zoomoraLightbox">\n <div class="zoomora-container">\n <div class="zoomora-header" id="zoomoraHeader">\n <div class="zoomora-counter" id="zoomoraCounter" ${this.options.showCounter ? "" : "style=\"opacity:0;visibility:hidden;\""}>1 / 1</div>\n <div class="zoomora-controls">\n ${this.options.showThumbnails ? "\n <button class=\"zoomora-btn\" id=\"zoomoraThumbnailBtn\" title=\"Toggle Thumbnails\">\n <i class=\"zoomorai-thumbnails\"></i>\n </button>\n " : ""}\n ${t}\n ${this.options.showZoom ? "\n <button class=\"zoomora-btn\" id=\"zoomoraZoomBtn\" title=\"Zoom\">\n <i class=\"zoomorai-zoom\"></i>\n </button>\n " : ""}\n ${this.options.showFullscreen ? "\n <button class=\"zoomora-btn\" id=\"zoomoraFullscreenBtn\" title=\"Fullscreen\">\n <i class=\"zoomorai-expand\"></i>\n </button>\n <button class=\"zoomora-btn\" id=\"zoomoraCollapseBtn\" title=\"Exit Fullscreen\" style=\"display: none;\">\n <i class=\"zoomorai-collapse\"></i>\n </button>\n " : ""}\n <button class="zoomora-btn" id="zoomoraCloseBtn" title="Close">\n <i class="zoomorai-close"></i>\n </button>\n </div>\n </div>\n \n <div class="zoomora-content" id="zoomoraContent">\n <div class="zoomora-loading" id="zoomoraLoading"></div>\n <div class="zoomora-slides-container" id="zoomoraSlidesContainer"></div>\n </div>\n \n <button class="zoomora-nav prev" id="zoomoraPrevBtn">\n <i class="zoomorai-arrow-left"></i>\n </button>\n <button class="zoomora-nav next" id="zoomoraNextBtn">\n <i class="zoomorai-arrow-right"></i>\n </button>\n \n <div class="zoomora-caption" id="zoomoraCaption" ${this.options.showThumbnails ? "" : "style=\"bottom:20px;\""}></div>\n <div class="zoomora-thumbnails" id="zoomoraThumbs" ${this.options.showThumbnails ? "" : "style=\"display:none;\""}></div>\n </div>\n </div>\n `;
|
|
110
|
+
if (document.body.insertAdjacentHTML("beforeend", e), this.zoomora = document.getElementById("zoomoraLightbox"), this.header = document.getElementById("zoomoraHeader"), this.content = document.getElementById("zoomoraContent"), this.slidesContainer = document.getElementById("zoomoraSlidesContainer"), this.counter = document.getElementById("zoomoraCounter"), this.thumbs = document.getElementById("zoomoraThumbs"), this.loading = document.getElementById("zoomoraLoading"), this.caption = document.getElementById("zoomoraCaption"), this.prevBtn = document.getElementById("zoomoraPrevBtn"), this.nextBtn = document.getElementById("zoomoraNextBtn"), !(this.zoomora && this.content && this.counter && this.thumbs && this.loading && this.caption)) throw new Error("Failed to create required DOM elements");
|
|
111
|
+
}
|
|
112
|
+
bindEvents() {
|
|
113
|
+
this.addEventListener(document, "click", this.boundMethods.handleDocumentClick), this.addEventListener(document.getElementById("zoomoraCloseBtn"), "click", () => this.close()), this.addEventListener(document.getElementById("zoomoraPrevBtn"), "click", () => this.prev()), this.addEventListener(document.getElementById("zoomoraNextBtn"), "click", () => this.next()), this.options.showZoom && this.addEventListener(document.getElementById("zoomoraZoomBtn"), "click", () => this.toggleZoom()), this.options.showFullscreen && (this.addEventListener(document.getElementById("zoomoraFullscreenBtn"), "click", () => this.toggleFullscreen()), this.addEventListener(document.getElementById("zoomoraCollapseBtn"), "click", () => this.exitFullscreen())), this.options.showThumbnails && this.addEventListener(document.getElementById("zoomoraThumbnailBtn"), "click", () => this.toggleThumbnails()), this.addEventListener(document, "fullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "webkitfullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "mozfullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "MSFullscreenChange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "keydown", this.boundMethods.handleKeydown), this.addEventListener(this.zoomora, "click", this.boundMethods.handleZoomoraClick), this.addEventListener(this.content, "click", this.boundMethods.handleContentClick), this.addEventListener(this.content, "mousedown", this.boundMethods.handleMouseDown), this.addEventListener(this.content, "mousemove", this.boundMethods.handleMouseMove), this.addEventListener(this.content, "mouseup", this.boundMethods.handleMouseUp), this.addEventListener(this.content, "mouseleave", this.boundMethods.handleMouseUp), this.addEventListener(this.content, "touchstart", this.boundMethods.handleTouchStart, { passive: !1 }), this.addEventListener(this.content, "touchmove", this.boundMethods.handleTouchMove, { passive: !1 }), this.addEventListener(this.content, "touchend", this.boundMethods.handleTouchEnd), this.options.showZoom && this.addEventListener(this.content, "wheel", this.boundMethods.handleWheel, { passive: !1 }), this.options.showAutoHideToggle && (this.addEventListener(document.getElementById("zoomoraAutoHideBtn"), "click", () => this.toggleAutoHide()), this.addEventListener(this.zoomora, "mousemove", () => this.handleUserActivity()), this.addEventListener(this.zoomora, "touchstart", () => this.handleUserActivity()), this.addEventListener(this.zoomora, "keydown", () => this.handleUserActivity()));
|
|
114
|
+
}
|
|
115
|
+
addEventListener(t, e, s, o = {}) {
|
|
116
|
+
if (!t) return;
|
|
117
|
+
t.addEventListener(e, s, o);
|
|
118
|
+
const i = `${t.constructor.name}_${e}`;
|
|
119
|
+
this.eventListeners.has(i) || this.eventListeners.set(i, []), this.eventListeners.get(i).push({
|
|
120
|
+
element: t,
|
|
121
|
+
event: e,
|
|
122
|
+
handler: s,
|
|
123
|
+
options: o
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
handleDocumentClick(t) {
|
|
127
|
+
const e = t.target.closest(this.options.selector);
|
|
128
|
+
e && (t.preventDefault(), this.open(e));
|
|
129
|
+
}
|
|
130
|
+
handleKeydown(t) {
|
|
131
|
+
if (this.zoomora.classList.contains("active")) switch (t.key) {
|
|
132
|
+
case "Escape":
|
|
133
|
+
this.isFullscreen ? this.exitFullscreen() : this.close();
|
|
134
|
+
break;
|
|
135
|
+
case "ArrowLeft":
|
|
136
|
+
this.prev();
|
|
137
|
+
break;
|
|
138
|
+
case "ArrowRight":
|
|
139
|
+
this.next();
|
|
140
|
+
break;
|
|
141
|
+
case "z":
|
|
142
|
+
case "Z":
|
|
143
|
+
this.toggleZoom();
|
|
144
|
+
break;
|
|
145
|
+
case "f":
|
|
146
|
+
case "F":
|
|
147
|
+
this.toggleFullscreen();
|
|
148
|
+
break;
|
|
149
|
+
case "t":
|
|
150
|
+
case "T": this.toggleThumbnails();
|
|
151
|
+
}
|
|
152
|
+
else this.handleTriggerKeydown(t);
|
|
153
|
+
}
|
|
154
|
+
handleTriggerKeydown(t) {
|
|
155
|
+
if ("Enter" !== t.key && " " !== t.key) return;
|
|
156
|
+
const e = t.target.closest(this.options.selector);
|
|
157
|
+
e && (t.preventDefault(), this.open(e));
|
|
158
|
+
}
|
|
159
|
+
handleFullscreenChange() {
|
|
160
|
+
const t = !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement);
|
|
161
|
+
!t && this.isFullscreen ? (this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : t && !this.isFullscreen && (this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons());
|
|
162
|
+
}
|
|
163
|
+
handleZoomoraClick(t) {
|
|
164
|
+
t.target === this.zoomora && this.options.closeOnBackgroundClick && this.close();
|
|
165
|
+
}
|
|
166
|
+
handleContentClick(t) {
|
|
167
|
+
if (Date.now() - this.lastDragTime < 200) return;
|
|
168
|
+
if (this.header && this.header.contains(t.target)) return;
|
|
169
|
+
if (t.target.closest("button")) return;
|
|
170
|
+
const e = t.target.closest(".zoomora-media, .zoomora-video, .zoomora-iframe");
|
|
171
|
+
if (e) return void (e.classList.contains("zoomora-media") && !e.classList.contains("no-zoom") && this.toggleZoom());
|
|
172
|
+
if (t.target.closest(".zoomora-video-container")) {
|
|
173
|
+
if (t.target.closest(".zoomora-play-button")) return;
|
|
174
|
+
this.options.closeOnBackgroundClick && this.close();
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const s = t.target;
|
|
178
|
+
((s.classList.contains("zoomora-content") || s.classList.contains("zoomora-slide-container") || s.classList.contains("zoomora-slide") || s.classList.contains("zoomora-slides-container") || "zoomoraContent" === s.id || "zoomoraSlidesContainer" === s.id) && this.options.closeOnBackgroundClick || this.options.closeOnBackgroundClick) && this.close();
|
|
179
|
+
}
|
|
180
|
+
handleMouseDown(t) {
|
|
181
|
+
this.startDrag(t);
|
|
182
|
+
}
|
|
183
|
+
handleMouseMove(t) {
|
|
184
|
+
this.drag(t);
|
|
185
|
+
}
|
|
186
|
+
handleMouseUp() {
|
|
187
|
+
this.endDrag();
|
|
188
|
+
}
|
|
189
|
+
handleTouchStart(t) {
|
|
190
|
+
this.startDrag(t);
|
|
191
|
+
}
|
|
192
|
+
handleTouchMove(t) {
|
|
193
|
+
this.drag(t);
|
|
194
|
+
}
|
|
195
|
+
handleTouchEnd() {
|
|
196
|
+
this.endDrag();
|
|
197
|
+
}
|
|
198
|
+
handleWheel(t) {
|
|
199
|
+
const e = this.content.querySelector(".zoomora-media");
|
|
200
|
+
if (!e || "IMG" !== e.tagName) return;
|
|
201
|
+
const s = this.calculateZoomLevels(e);
|
|
202
|
+
if (!s.canZoom) return;
|
|
203
|
+
t.preventDefault();
|
|
204
|
+
const o = s.levels[s.levels.length - 1], i = this.options.zoomStep || .1, n = t.deltaY < 0 ? 1 : -1;
|
|
205
|
+
let a = (this.currentScale || 1) + n * i * o;
|
|
206
|
+
if (a = Math.max(1, Math.min(o, a)), a === this.currentScale) return;
|
|
207
|
+
this.currentScale = a, this.isZoomed = a > 1, this.currentX = 0, this.currentY = 0, this.isZoomed ? (e.style.transform = `scale(${a})`, e.style.cursor = "grab", e.classList.add("zoomed")) : (e.style.transform = "", e.style.cursor = "pointer", e.classList.remove("zoomed"));
|
|
208
|
+
let r = 0;
|
|
209
|
+
s.levels.forEach((t, e) => {
|
|
210
|
+
Math.abs(t - a) < Math.abs(s.levels[r] - a) && (r = e);
|
|
211
|
+
}), e.dataset.zoomLevel = r.toString();
|
|
212
|
+
}
|
|
213
|
+
getImageSource(t) {
|
|
214
|
+
const e = t.dataset.src || t.getAttribute("href") || t.src || t.getAttribute("src");
|
|
215
|
+
return "video" === (t.dataset.type || "image") && e ? this.convertToEmbedUrl(e) : e;
|
|
216
|
+
}
|
|
217
|
+
convertToEmbedUrl(t) {
|
|
218
|
+
if (t.includes("youtube.com/embed/")) return t;
|
|
219
|
+
let e = null, s = null;
|
|
220
|
+
if (t.includes("youtube.com/watch")) {
|
|
221
|
+
const o = new URLSearchParams(t.split("?")[1]);
|
|
222
|
+
e = o.get("v");
|
|
223
|
+
const i = o.get("t");
|
|
224
|
+
i && (s = i.replace("s", ""));
|
|
225
|
+
} else if (t.includes("youtu.be/")) {
|
|
226
|
+
const o = t.split("/"), i = o[o.length - 1];
|
|
227
|
+
if (i.includes("?")) {
|
|
228
|
+
e = i.split("?")[0];
|
|
229
|
+
const t = new URLSearchParams(i.split("?")[1]).get("t");
|
|
230
|
+
t && (s = t.replace("s", ""));
|
|
231
|
+
} else e = i;
|
|
232
|
+
}
|
|
233
|
+
if (e) {
|
|
234
|
+
let t = `https://www.youtube.com/embed/${e}`;
|
|
235
|
+
const o = new URLSearchParams();
|
|
236
|
+
return s && o.append("start", s), o.append("rel", "0"), o.append("modestbranding", "1"), this.options.autoplayVideos && o.append("autoplay", "1"), o.toString() && (t += "?" + o.toString()), t;
|
|
237
|
+
}
|
|
238
|
+
return t;
|
|
239
|
+
}
|
|
240
|
+
getThumbnailSource(t) {
|
|
241
|
+
var e;
|
|
242
|
+
if (t.dataset.thumbnail) return t.dataset.thumbnail;
|
|
243
|
+
const s = null === (e = t.querySelector) || void 0 === e ? void 0 : e.call(t, "img"), o = t.getAttribute("src") || (null == s ? void 0 : s.getAttribute("src"));
|
|
244
|
+
return "video" === (t.dataset.type || "image") ? o : o || t.dataset.src || t.getAttribute("href");
|
|
245
|
+
}
|
|
246
|
+
getGroup(t) {
|
|
247
|
+
return this.options.useHref ? t.dataset.lightbox || t.dataset.gallery || "default" : t.dataset.zoomora || "default";
|
|
248
|
+
}
|
|
249
|
+
open(t) {
|
|
250
|
+
if (!t) return;
|
|
251
|
+
const e = this.getGroup(t);
|
|
252
|
+
let s;
|
|
253
|
+
s = this.options.useHref ? t.dataset.lightbox ? `[data-lightbox="${e}"]` : t.dataset.gallery ? `[data-gallery="${e}"]` : this.options.selector : `[data-zoomora="${e}"]`, this.items = Array.from(document.querySelectorAll(s)), this.currentIndex = Math.max(0, this.items.indexOf(t)), this._activateLightbox(), "function" == typeof this.options.onOpen && this.options.onOpen(t, this.currentIndex);
|
|
254
|
+
}
|
|
255
|
+
openImage(t, e = {}) {
|
|
256
|
+
const s = Array.isArray(t) ? t : [t];
|
|
257
|
+
this.items = s.map((t) => this.createVirtualItem("string" == typeof t ? { src: t } : t)), this.currentIndex = Math.max(0, Math.min(e.startIndex || 0, this.items.length - 1)), this._activateLightbox(), "function" == typeof this.options.onOpen && this.options.onOpen(this.items[this.currentIndex], this.currentIndex);
|
|
258
|
+
}
|
|
259
|
+
createVirtualItem({ src: t, thumb: e, type: s = "image", caption: o = "", alt: i = "" }) {
|
|
260
|
+
const n = e || t;
|
|
261
|
+
return {
|
|
262
|
+
dataset: {
|
|
263
|
+
src: t,
|
|
264
|
+
type: s,
|
|
265
|
+
caption: o
|
|
266
|
+
},
|
|
267
|
+
src: n,
|
|
268
|
+
alt: i,
|
|
269
|
+
title: o,
|
|
270
|
+
getAttribute: (t) => "src" === t ? n : null
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
_activateLightbox() {
|
|
274
|
+
this.isZoomed = !1, this.isFullscreen = !1, this.thumbnailsVisible = !0, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.zoomora.classList.add("active"), document.body.style.overflow = "hidden", this.loadContent(), this.updateThumbnails(), this.updateCounter(), this.updateNavigation(), this.updateCaption(), this.updateButtons(), this.autoHideEnabled ? this.startAutoHideTimer() : this.showControls();
|
|
275
|
+
}
|
|
276
|
+
close() {
|
|
277
|
+
this.isFullscreen && this.exitFullscreen(), this.zoomora.classList.remove("active"), document.body.style.overflow = "";
|
|
278
|
+
const t = this.content.querySelector("video");
|
|
279
|
+
t && t.pause();
|
|
280
|
+
const e = this.content.querySelector("iframe");
|
|
281
|
+
e && (e.src = "about:blank"), this.isZoomed = !1, this.isFullscreen = !1, this.currentX = 0, this.currentY = 0, this.currentScale = 1;
|
|
282
|
+
const s = this.content.querySelector(".zoomora-media");
|
|
283
|
+
s && (s.classList.remove("zoomed"), s.style.transform = "", s.style.cursor = ""), this.zoomora.classList.remove("fullscreen"), this.updateButtons(), this.stopAutoHideTimer(), this.showControls(), "function" == typeof this.options.onClose && this.options.onClose(this.currentIndex);
|
|
284
|
+
}
|
|
285
|
+
prev() {
|
|
286
|
+
this.currentIndex > 0 && (this.currentIndex--, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption(), "function" == typeof this.options.onPrev && this.options.onPrev(this.currentIndex));
|
|
287
|
+
}
|
|
288
|
+
next() {
|
|
289
|
+
this.currentIndex < this.items.length - 1 && (this.currentIndex++, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption(), "function" == typeof this.options.onNext && this.options.onNext(this.currentIndex));
|
|
290
|
+
}
|
|
291
|
+
loadContent() {
|
|
292
|
+
if (!this.items[this.currentIndex]) return;
|
|
293
|
+
const t = this.items[this.currentIndex], e = this.getImageSource(t), s = t.dataset.type || "image";
|
|
294
|
+
e && (this.isZoomed = !1, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.loading.style.display = "block", this.slidesContainer && (this.slidesContainer.innerHTML = ""), setTimeout(() => {
|
|
295
|
+
this.renderContent(e, s, t);
|
|
296
|
+
}, 100));
|
|
297
|
+
}
|
|
298
|
+
renderContent(t, e, s) {
|
|
299
|
+
const o = document.createElement("div");
|
|
300
|
+
o.className = "zoomora-slide-container";
|
|
301
|
+
const i = document.createElement("div");
|
|
302
|
+
let n;
|
|
303
|
+
i.className = "zoomora-slide " + ("slide" === this.options.transition ? "slide-effect" : "fade-effect"), i.style.opacity = "0", i.style.transform = "slide" === this.options.transition ? "translateX(100%)" : "scale(0.8)";
|
|
304
|
+
try {
|
|
305
|
+
switch (e) {
|
|
306
|
+
case "video":
|
|
307
|
+
if (t.endsWith(".mp4") || t.endsWith(".webm") || t.endsWith(".ogg")) {
|
|
308
|
+
const e = document.createElement("div");
|
|
309
|
+
e.className = "zoomora-video-container", n = document.createElement("video"), n.src = t, n.className = "zoomora-video", n.setAttribute("preload", "metadata");
|
|
310
|
+
const i = s.src || s.getAttribute("src");
|
|
311
|
+
i && n.setAttribute("poster", i);
|
|
312
|
+
const a = document.createElement("div");
|
|
313
|
+
a.className = "zoomora-play-button", a.innerHTML = "<svg viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M8 5v14l11-7z\"/></svg>", a.addEventListener("click", () => {
|
|
314
|
+
n.play(), a.style.display = "none", n.setAttribute("controls", "");
|
|
315
|
+
}), n.addEventListener("ended", () => {
|
|
316
|
+
a.style.display = "flex";
|
|
317
|
+
}), e.appendChild(n), e.appendChild(a), this.options.autoplayVideos && n.play().then(() => {
|
|
318
|
+
a.style.display = "none", n.setAttribute("controls", "");
|
|
319
|
+
}).catch(() => {}), o.appendChild(e);
|
|
320
|
+
} else n = document.createElement("iframe"), n.src = t, n.className = "zoomora-video", n.setAttribute("allowfullscreen", ""), n.setAttribute("allow", "autoplay; fullscreen; picture-in-picture"), n.setAttribute("frameborder", "0"), o.appendChild(n);
|
|
321
|
+
break;
|
|
322
|
+
case "iframe":
|
|
323
|
+
n = document.createElement("iframe"), n.src = t, n.className = "zoomora-iframe", n.setAttribute("frameborder", "0"), o.appendChild(n);
|
|
324
|
+
break;
|
|
325
|
+
default: n = document.createElement("img"), n.src = t, n.className = "zoomora-media", n.alt = s.alt || s.title || "", n.onload = () => {
|
|
326
|
+
this.loading.style.display = "none", this.checkZoomability(n), this.animateSlideIn(i);
|
|
327
|
+
}, n.onerror = () => {
|
|
328
|
+
this.loading.style.display = "none", this.animateSlideIn(i);
|
|
329
|
+
}, o.appendChild(n);
|
|
330
|
+
}
|
|
331
|
+
i.appendChild(o), this.slidesContainer.innerHTML = "", this.slidesContainer.appendChild(i), "image" !== e && (this.loading.style.display = "none", this.animateSlideIn(i));
|
|
332
|
+
} catch (t) {
|
|
333
|
+
this.loading.style.display = "none";
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
animateSlideIn(t) {
|
|
337
|
+
t.offsetHeight, t.classList.add("active"), "slide" === this.options.transition ? (t.style.transition = `transform ${this.options.animationDuration}ms ease, opacity ${this.options.animationDuration}ms ease`, t.style.transform = "translateX(0)", t.style.opacity = "1") : (t.style.transition = `transform ${this.options.animationDuration}ms ease, opacity ${this.options.animationDuration}ms ease`, t.style.transform = "scale(1)", t.style.opacity = "1");
|
|
338
|
+
}
|
|
339
|
+
toggleAutoHide() {
|
|
340
|
+
this.autoHideEnabled = !this.autoHideEnabled;
|
|
341
|
+
const t = document.getElementById("zoomoraAutoHideBtn");
|
|
342
|
+
this.autoHideEnabled ? (t.classList.add("active"), t.title = "Disable Auto-Hide Controls", this.startAutoHideTimer()) : (t.classList.remove("active"), t.title = "Enable Auto-Hide Controls", this.stopAutoHideTimer(), this.showControls());
|
|
343
|
+
}
|
|
344
|
+
handleUserActivity() {
|
|
345
|
+
this.autoHideEnabled && (this.showControls(), this.startAutoHideTimer());
|
|
346
|
+
}
|
|
347
|
+
startAutoHideTimer() {
|
|
348
|
+
this.stopAutoHideTimer(), this.autoHideTimeout = setTimeout(() => {
|
|
349
|
+
this.hideControls();
|
|
350
|
+
}, this.options.autoHideDelay);
|
|
351
|
+
}
|
|
352
|
+
stopAutoHideTimer() {
|
|
353
|
+
this.autoHideTimeout && (clearTimeout(this.autoHideTimeout), this.autoHideTimeout = null);
|
|
354
|
+
}
|
|
355
|
+
showControls() {
|
|
356
|
+
this.isControlsVisible || (this.isControlsVisible = !0, this.zoomora.classList.remove("controls-hidden"), this.header && (this.header.style.transform = "translateY(0)", this.header.style.opacity = "1"), this.caption && (this.caption.style.transform = "translateX(-50%) translateY(0)", this.caption.style.opacity = "1"), this.thumbs && (this.thumbs.style.transform = "translateX(-50%) translateY(0)", this.thumbs.style.opacity = "1"), this.prevBtn && (this.prevBtn.style.transform = "translateX(0)", this.prevBtn.style.opacity = "1"), this.nextBtn && (this.nextBtn.style.transform = "translateX(0)", this.nextBtn.style.opacity = "1"));
|
|
357
|
+
}
|
|
358
|
+
hideControls() {
|
|
359
|
+
this.isControlsVisible && (this.isControlsVisible = !1, this.zoomora.classList.add("controls-hidden"), this.header && (this.header.style.transform = "translateY(-100%)", this.header.style.opacity = "0"), this.caption && (this.caption.style.transform = "translateX(-50%) translateY(100%)", this.caption.style.opacity = "0"), this.thumbs && (this.thumbs.style.transform = "translateX(-50%) translateY(100%)", this.thumbs.style.opacity = "0"), this.prevBtn && (this.prevBtn.style.transform = "translateX(-100%)", this.prevBtn.style.opacity = "0"), this.nextBtn && (this.nextBtn.style.transform = "translateX(100%)", this.nextBtn.style.opacity = "0"));
|
|
360
|
+
}
|
|
361
|
+
checkZoomability(t) {
|
|
362
|
+
if (!t || !t.naturalWidth || !t.naturalHeight) return;
|
|
363
|
+
const e = t.getBoundingClientRect(), s = e.width, o = e.height, i = t.naturalWidth, n = t.naturalHeight, a = i > s || n > o, r = i / s, l = n / o, h = Math.max(r, l);
|
|
364
|
+
t.dataset.zoomRatio = h.toString(), t.dataset.naturalWidth = i.toString(), t.dataset.naturalHeight = n.toString(), t.dataset.renderedWidth = s.toString(), t.dataset.renderedHeight = o.toString(), a && h > 1.1 ? t.classList.remove("no-zoom") : t.classList.add("no-zoom");
|
|
365
|
+
}
|
|
366
|
+
calculateZoomLevels(t) {
|
|
367
|
+
if (!t || !t.naturalWidth || !t.naturalHeight) return {
|
|
368
|
+
canZoom: !1,
|
|
369
|
+
levels: [],
|
|
370
|
+
currentLevel: 0
|
|
371
|
+
};
|
|
372
|
+
const e = this.content.getBoundingClientRect(), s = e.width, o = e.height, i = t.naturalWidth, n = t.naturalHeight, a = s / i, r = o / n, l = Math.min(a, r);
|
|
373
|
+
if (l >= .95) return {
|
|
374
|
+
canZoom: !1,
|
|
375
|
+
levels: [],
|
|
376
|
+
currentLevel: 0
|
|
377
|
+
};
|
|
378
|
+
const h = Number(this.options.maxZoomScale), c = Number.isFinite(h) && h > 0 ? Math.max(1, h) : 3, d = [1];
|
|
379
|
+
[
|
|
380
|
+
1.5,
|
|
381
|
+
2,
|
|
382
|
+
3,
|
|
383
|
+
4,
|
|
384
|
+
5
|
|
385
|
+
].forEach((t) => {
|
|
386
|
+
t <= c && l * t <= 1 && d.push(t);
|
|
387
|
+
});
|
|
388
|
+
const u = Math.min(1 / l, c);
|
|
389
|
+
return u > d[d.length - 1] && d.push(u), {
|
|
390
|
+
canZoom: d.length > 1,
|
|
391
|
+
levels: d,
|
|
392
|
+
currentLevel: 0,
|
|
393
|
+
baseScale: l,
|
|
394
|
+
naturalWidth: i,
|
|
395
|
+
naturalHeight: n
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
updateCounter() {
|
|
399
|
+
this.options.showCounter && this.counter && (this.counter.textContent = `${this.currentIndex + 1} / ${this.items.length}`);
|
|
400
|
+
}
|
|
401
|
+
updateCaption() {
|
|
402
|
+
if (!this.caption || !this.items[this.currentIndex]) return;
|
|
403
|
+
const t = this.items[this.currentIndex], e = t.dataset.caption || t.title || "";
|
|
404
|
+
e ? (this.caption.textContent = e, this.caption.style.transform = "translateX(-50%) translateY(0)", this.caption.style.opacity = "1", this.caption.style.pointerEvents = "auto", this.caption.style.transition = "opacity 0.3s ease, transform 0.3s ease") : (this.caption.style.transform = "translateX(-50%) translateY(100%)", this.caption.style.opacity = "0", this.caption.style.pointerEvents = "none", this.caption.style.transition = "opacity 0.3s ease, transform 0.3s ease");
|
|
405
|
+
}
|
|
406
|
+
updateThumbnails() {
|
|
407
|
+
if (this.options.showThumbnails && this.thumbs) {
|
|
408
|
+
if (1 === this.items.length) return this.caption.classList.add("single-item-thumbnail"), void (this.thumbs.style.display = "none");
|
|
409
|
+
this.caption.classList.remove("single-item-thumbnail"), this.thumbs.style.display = "flex", this.thumbs.innerHTML = "", this.items.forEach((t, e) => {
|
|
410
|
+
const s = document.createElement("div");
|
|
411
|
+
s.className = "zoomora-thumb", e === this.currentIndex && s.classList.add("active");
|
|
412
|
+
const o = document.createElement("img"), i = this.getThumbnailSource(t);
|
|
413
|
+
i && (o.src = i, o.alt = t.alt || t.title || "", o.onerror = () => {
|
|
414
|
+
s.style.display = "none";
|
|
415
|
+
}), s.appendChild(o), s.addEventListener("click", () => {
|
|
416
|
+
this.currentIndex = e, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption();
|
|
417
|
+
}), this.thumbs.appendChild(s);
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
updateNavigation() {
|
|
422
|
+
const t = document.getElementById("zoomoraPrevBtn"), e = document.getElementById("zoomoraNextBtn");
|
|
423
|
+
t && (t.style.display = this.currentIndex > 0 ? "flex" : "none"), e && (e.style.display = this.currentIndex < this.items.length - 1 ? "flex" : "none");
|
|
424
|
+
}
|
|
425
|
+
updateButtons() {
|
|
426
|
+
const t = document.getElementById("zoomoraFullscreenBtn"), e = document.getElementById("zoomoraCollapseBtn");
|
|
427
|
+
t && e && (this.isFullscreen ? (t.style.display = "none", e.style.display = "flex") : (t.style.display = "flex", e.style.display = "none"));
|
|
428
|
+
}
|
|
429
|
+
toggleZoom() {
|
|
430
|
+
const t = this.content.querySelector(".zoomora-media");
|
|
431
|
+
if (!t || "IMG" !== t.tagName) return;
|
|
432
|
+
const e = this.calculateZoomLevels(t);
|
|
433
|
+
if (!e.canZoom) return;
|
|
434
|
+
t.dataset.zoomLevel || (t.dataset.zoomLevel = "0");
|
|
435
|
+
let s = parseInt(t.dataset.zoomLevel) || 0;
|
|
436
|
+
s++, s >= e.levels.length && (s = 0);
|
|
437
|
+
const o = e.levels[s];
|
|
438
|
+
t.dataset.zoomLevel = s.toString(), 0 === s ? (this.isZoomed = !1, this.isDragging = !1, t.classList.remove("dragging"), t.style.transform = "", t.style.cursor = "pointer", t.classList.remove("zoomed"), this.currentX = 0, this.currentY = 0, this.currentScale = 1) : (this.isZoomed = !0, this.currentScale = o, this.currentX = 0, this.currentY = 0, t.style.transform = `translate(0px, 0px) scale(${o})`, t.style.cursor = "grab", t.classList.add("zoomed"));
|
|
439
|
+
}
|
|
440
|
+
toggleFullscreen() {
|
|
441
|
+
this.isFullscreen ? this.exitFullscreen() : this.enterFullscreen();
|
|
442
|
+
}
|
|
443
|
+
enterFullscreen() {
|
|
444
|
+
const t = this.zoomora;
|
|
445
|
+
try {
|
|
446
|
+
t.requestFullscreen ? t.requestFullscreen().then(() => {
|
|
476
447
|
this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons();
|
|
477
|
-
}
|
|
478
|
-
|
|
448
|
+
}).catch((t) => {
|
|
449
|
+
this.fallbackFullscreen();
|
|
450
|
+
}) : t.webkitRequestFullscreen ? (t.webkitRequestFullscreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : t.mozRequestFullScreen ? (t.mozRequestFullScreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : t.msRequestFullscreen ? (t.msRequestFullscreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : this.fallbackFullscreen();
|
|
451
|
+
} catch (t) {
|
|
452
|
+
this.fallbackFullscreen();
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
exitFullscreen() {
|
|
456
|
+
if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) try {
|
|
457
|
+
document.exitFullscreen ? document.exitFullscreen().then(() => {
|
|
479
458
|
this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons();
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
(t.dataset.caption || t.title) && this.thumbs.classList.contains("thumbs-hidden") ? (this.caption.style.bottom = "20px", this.caption.style.transition = "bottom 0.3s ease, transform 0.3s ease") : this.caption.style.bottom = "120px";
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
startDrag(t) {
|
|
489
|
-
const e = this.content.querySelector(".zoomora-media");
|
|
490
|
-
if (!e || !this.isZoomed) return;
|
|
491
|
-
this.isDragging = !0, e.classList.add("dragging"), e.style.cursor = "grabbing", this.startX = t.clientX || t.touches && t.touches[0].clientX || 0, this.startY = t.clientY || t.touches && t.touches[0].clientY || 0;
|
|
492
|
-
const s = window.getComputedStyle(e).transform;
|
|
493
|
-
if (s && "none" !== s) {
|
|
494
|
-
const t = new DOMMatrix(s);
|
|
495
|
-
this.currentX = t.m41, this.currentY = t.m42;
|
|
496
|
-
} else this.currentX = 0, this.currentY = 0;
|
|
497
|
-
t.preventDefault();
|
|
498
|
-
}
|
|
499
|
-
drag(t) {
|
|
500
|
-
if (!this.isDragging) return;
|
|
501
|
-
t.preventDefault();
|
|
502
|
-
const e = this.content.querySelector(".zoomora-media");
|
|
503
|
-
if (!e) return;
|
|
504
|
-
const s = t.clientX || t.touches && t.touches[0].clientX || 0, o = t.clientY || t.touches && t.touches[0].clientY || 0, i = s - this.startX, n = o - this.startY;
|
|
505
|
-
let a = this.currentX + i, r = this.currentY + n;
|
|
506
|
-
const l = this.content.getBoundingClientRect(), h = e.getBoundingClientRect(), c = Math.max(0, (h.width - l.width) / 2), d = Math.max(0, (h.height - l.height) / 2);
|
|
507
|
-
a = c > 0 ? Math.max(-c, Math.min(c, a)) : 0, r = d > 0 ? Math.max(-d, Math.min(d, r)) : 0, e.style.transform = `translate(${a}px, ${r}px) scale(${this.currentScale})`, this.startX = s, this.startY = o, this.currentX = a, this.currentY = r;
|
|
508
|
-
}
|
|
509
|
-
endDrag() {
|
|
510
|
-
if (!this.isDragging) return;
|
|
511
|
-
this.isDragging = !1, this.lastDragTime = Date.now();
|
|
512
|
-
const t = this.content.querySelector(".zoomora-media");
|
|
513
|
-
t && (t.classList.remove("dragging"), this.isZoomed && (t.style.cursor = "grab"));
|
|
514
|
-
}
|
|
515
|
-
goTo(t) {
|
|
516
|
-
t < 0 || t >= this.items.length || (this.currentIndex = t, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption());
|
|
517
|
-
}
|
|
518
|
-
getCurrentIndex() {
|
|
519
|
-
return this.currentIndex;
|
|
520
|
-
}
|
|
521
|
-
getTotalItems() {
|
|
522
|
-
return this.items.length;
|
|
523
|
-
}
|
|
524
|
-
isOpen() {
|
|
525
|
-
return this.zoomora && this.zoomora.classList.contains("active");
|
|
526
|
-
}
|
|
527
|
-
updateOptions(t) {
|
|
528
|
-
this.options = d(d({}, this.options), t);
|
|
529
|
-
}
|
|
530
|
-
refresh() {
|
|
531
|
-
if (this.isOpen()) {
|
|
532
|
-
const t = this.items[this.currentIndex];
|
|
533
|
-
t && this.open(t);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
destroy() {
|
|
537
|
-
this.isInitialized && (this.isOpen() && this.close(), this.stopAutoHideTimer(), this.eventListeners.forEach((t, e) => {
|
|
538
|
-
t.forEach(({ element: t, event: e, handler: s, options: o }) => {
|
|
539
|
-
t && t.removeEventListener && t.removeEventListener(e, s, o);
|
|
540
|
-
});
|
|
541
|
-
}), this.eventListeners.clear(), this.zoomora && this.zoomora.parentNode && this.zoomora.parentNode.removeChild(this.zoomora), this.isInitialized = !1, this.items = [], this.currentIndex = 0, this.zoomora = null, this.content = null, this.counter = null, this.thumbs = null, this.loading = null, this.caption = null);
|
|
542
|
-
}
|
|
459
|
+
}).catch((t) => {
|
|
460
|
+
this.fallbackExitFullscreen();
|
|
461
|
+
}) : document.webkitExitFullscreen ? (document.webkitExitFullscreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : document.mozCancelFullScreen ? (document.mozCancelFullScreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : document.msExitFullscreen ? (document.msExitFullscreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : this.fallbackExitFullscreen();
|
|
462
|
+
} catch (t) {
|
|
463
|
+
this.fallbackExitFullscreen();
|
|
543
464
|
}
|
|
544
|
-
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
|
|
465
|
+
else this.fallbackExitFullscreen();
|
|
466
|
+
}
|
|
467
|
+
fallbackFullscreen() {
|
|
468
|
+
this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons();
|
|
469
|
+
}
|
|
470
|
+
fallbackExitFullscreen() {
|
|
471
|
+
this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons();
|
|
472
|
+
}
|
|
473
|
+
toggleThumbnails() {
|
|
474
|
+
if (1 !== this.items.length && (this.thumbnailsVisible = !this.thumbnailsVisible, this.thumbs)) {
|
|
475
|
+
if (this.thumbs.classList.toggle("thumbs-hidden", !this.thumbnailsVisible), !this.caption || !this.items[this.currentIndex]) return;
|
|
476
|
+
const t = this.items[this.currentIndex];
|
|
477
|
+
(t.dataset.caption || t.title) && this.thumbs.classList.contains("thumbs-hidden") ? (this.caption.style.bottom = "20px", this.caption.style.transition = "bottom 0.3s ease, transform 0.3s ease") : this.caption.style.bottom = "120px";
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
startDrag(t) {
|
|
481
|
+
const e = this.content.querySelector(".zoomora-media");
|
|
482
|
+
if (!e || !this.isZoomed) return;
|
|
483
|
+
this.isDragging = !0, e.classList.add("dragging"), e.style.cursor = "grabbing", this.startX = t.clientX || t.touches && t.touches[0].clientX || 0, this.startY = t.clientY || t.touches && t.touches[0].clientY || 0;
|
|
484
|
+
const s = window.getComputedStyle(e).transform;
|
|
485
|
+
if (s && "none" !== s) {
|
|
486
|
+
const t = new DOMMatrix(s);
|
|
487
|
+
this.currentX = t.m41, this.currentY = t.m42;
|
|
488
|
+
} else this.currentX = 0, this.currentY = 0;
|
|
489
|
+
t.preventDefault();
|
|
490
|
+
}
|
|
491
|
+
drag(t) {
|
|
492
|
+
if (!this.isDragging) return;
|
|
493
|
+
t.preventDefault();
|
|
494
|
+
const e = this.content.querySelector(".zoomora-media");
|
|
495
|
+
if (!e) return;
|
|
496
|
+
const s = t.clientX || t.touches && t.touches[0].clientX || 0, o = t.clientY || t.touches && t.touches[0].clientY || 0, i = s - this.startX, n = o - this.startY;
|
|
497
|
+
let a = this.currentX + i, r = this.currentY + n;
|
|
498
|
+
const l = this.content.getBoundingClientRect(), h = e.getBoundingClientRect(), c = Math.max(0, (h.width - l.width) / 2), d = Math.max(0, (h.height - l.height) / 2);
|
|
499
|
+
a = c > 0 ? Math.max(-c, Math.min(c, a)) : 0, r = d > 0 ? Math.max(-d, Math.min(d, r)) : 0, e.style.transform = `translate(${a}px, ${r}px) scale(${this.currentScale})`, this.startX = s, this.startY = o, this.currentX = a, this.currentY = r;
|
|
500
|
+
}
|
|
501
|
+
endDrag() {
|
|
502
|
+
if (!this.isDragging) return;
|
|
503
|
+
this.isDragging = !1, this.lastDragTime = Date.now();
|
|
504
|
+
const t = this.content.querySelector(".zoomora-media");
|
|
505
|
+
t && (t.classList.remove("dragging"), this.isZoomed && (t.style.cursor = "grab"));
|
|
506
|
+
}
|
|
507
|
+
goTo(t) {
|
|
508
|
+
t < 0 || t >= this.items.length || (this.currentIndex = t, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption());
|
|
509
|
+
}
|
|
510
|
+
getCurrentIndex() {
|
|
511
|
+
return this.currentIndex;
|
|
512
|
+
}
|
|
513
|
+
getTotalItems() {
|
|
514
|
+
return this.items.length;
|
|
515
|
+
}
|
|
516
|
+
isOpen() {
|
|
517
|
+
return this.zoomora && this.zoomora.classList.contains("active");
|
|
518
|
+
}
|
|
519
|
+
updateOptions(t) {
|
|
520
|
+
this.options = i(i({}, this.options), t);
|
|
521
|
+
}
|
|
522
|
+
refresh() {
|
|
523
|
+
if (this.isOpen()) {
|
|
524
|
+
const t = this.items[this.currentIndex];
|
|
525
|
+
t && this.open(t);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
destroy() {
|
|
529
|
+
this.isInitialized && (this.isOpen() && this.close(), this.stopAutoHideTimer(), this.eventListeners.forEach((t, e) => {
|
|
530
|
+
t.forEach(({ element: t, event: e, handler: s, options: o }) => {
|
|
531
|
+
t && t.removeEventListener && t.removeEventListener(e, s, o);
|
|
532
|
+
});
|
|
533
|
+
}), this.eventListeners.clear(), this.zoomora && this.zoomora.parentNode && this.zoomora.parentNode.removeChild(this.zoomora), this.isInitialized = !1, this.items = [], this.currentIndex = 0, this.zoomora = null, this.content = null, this.counter = null, this.thumbs = null, this.loading = null, this.caption = null);
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
export { n as default };
|