react-motion-gallery 2.0.4 → 2.0.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/dist/index.css +1 -708
- package/dist/index.d.mts +832 -194
- package/dist/index.mjs +43 -7396
- package/dist/metafile-esm.json +1 -1
- package/package.json +40 -7
- package/dist/FullscreenRuntime-CEYIXWZZ.mjs +0 -2666
- package/dist/FullscreenRuntime-CEYIXWZZ.mjs.map +0 -1
- package/dist/FullscreenRuntime-D6G3BRAU.css +0 -123
- package/dist/FullscreenRuntime-D6G3BRAU.css.map +0 -1
- package/dist/chunk-HOCUKMYX.mjs +0 -2634
- package/dist/chunk-HOCUKMYX.mjs.map +0 -1
- package/dist/index.css.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -1,2666 +0,0 @@
|
|
|
1
|
-
import { Limit, createBaseLimit, ScrollTarget, FullscreenAxis, Vector1D, TranslateFullscreen, Counter, ScrollLooper, ScrollBody, Animations, EventStore, createDragTracker, isMouseEvent, factorAbs, mathSign, runFullscreenIntro, createIndexChannel, ThumbnailSlider, parseObjectPosition, objectFitContentRect, containTransformForRect, coverTransformForRect } from './chunk-HOCUKMYX.mjs';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import React__default, { forwardRef, useRef, useCallback, useEffect, Children, useImperativeHandle, useMemo } from 'react';
|
|
4
|
-
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
5
|
-
|
|
6
|
-
function DefaultCloseIcon({
|
|
7
|
-
size = 35,
|
|
8
|
-
className
|
|
9
|
-
}) {
|
|
10
|
-
return /* @__PURE__ */ jsx(
|
|
11
|
-
"svg",
|
|
12
|
-
{
|
|
13
|
-
className,
|
|
14
|
-
width: size,
|
|
15
|
-
height: size,
|
|
16
|
-
viewBox: "0 0 16 16",
|
|
17
|
-
"aria-hidden": "true",
|
|
18
|
-
focusable: "false",
|
|
19
|
-
children: /* @__PURE__ */ jsx(
|
|
20
|
-
"path",
|
|
21
|
-
{
|
|
22
|
-
fill: "white",
|
|
23
|
-
stroke: "#4f4f4f",
|
|
24
|
-
strokeWidth: 0.5,
|
|
25
|
-
d: "M12.96 4.46l-1.42-1.42-3.54 3.55-3.54-3.55-1.42 1.42 3.55 3.54-3.55 3.54 1.42 1.42 3.54-3.55 3.54 3.55 1.42-1.42-3.55-3.54 3.55-3.54z"
|
|
26
|
-
}
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
function DefaultChevronIcon({ side }) {
|
|
32
|
-
return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", width: "100%", height: "100%", focusable: "false", "aria-hidden": "true", style: { display: "block" }, children: /* @__PURE__ */ jsx(
|
|
33
|
-
"polygon",
|
|
34
|
-
{
|
|
35
|
-
points: "4.586,3.414 9.172,8 4.586,12.586 6,14 12,8 6,2",
|
|
36
|
-
fill: "white",
|
|
37
|
-
stroke: "#4f4f4f",
|
|
38
|
-
strokeWidth: "0.5"
|
|
39
|
-
}
|
|
40
|
-
) });
|
|
41
|
-
}
|
|
42
|
-
function DefaultCounterText({ index, count }) {
|
|
43
|
-
return /* @__PURE__ */ jsxs("span", { children: [
|
|
44
|
-
index + 1,
|
|
45
|
-
" / ",
|
|
46
|
-
count
|
|
47
|
-
] });
|
|
48
|
-
}
|
|
49
|
-
function freezeRect(el) {
|
|
50
|
-
const r = el.getBoundingClientRect();
|
|
51
|
-
el.style.width = `${Math.max(1, Math.round(r.width))}px`;
|
|
52
|
-
el.style.height = `${Math.max(1, Math.round(r.height))}px`;
|
|
53
|
-
}
|
|
54
|
-
var px = (n) => `${Math.round(n)}px`;
|
|
55
|
-
function getViewportEl(track) {
|
|
56
|
-
if (!track) return null;
|
|
57
|
-
return track.parentElement ?? track;
|
|
58
|
-
}
|
|
59
|
-
function getTotalCellsWidth(slides) {
|
|
60
|
-
if (!slides) return 0;
|
|
61
|
-
let totalWidth = 0;
|
|
62
|
-
slides.forEach((slide) => {
|
|
63
|
-
slide.cells.forEach((cell) => {
|
|
64
|
-
totalWidth += cell.element.offsetWidth;
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
return totalWidth;
|
|
68
|
-
}
|
|
69
|
-
function isCellVisible(cellEl, viewportEl, allowPartial = true) {
|
|
70
|
-
const c = viewportEl.getBoundingClientRect();
|
|
71
|
-
const r = cellEl.getBoundingClientRect();
|
|
72
|
-
const fully = r.left >= c.left && r.right <= c.right && r.top >= c.top && r.bottom <= c.bottom;
|
|
73
|
-
const intersects = r.right > c.left && r.left < c.right && r.bottom > c.top && r.top < c.bottom;
|
|
74
|
-
return allowPartial ? intersects : fully;
|
|
75
|
-
}
|
|
76
|
-
function createClipper({ DURATION_MS, EASING }) {
|
|
77
|
-
const clipper = document.createElement("div");
|
|
78
|
-
Object.assign(clipper.style, {
|
|
79
|
-
position: "fixed",
|
|
80
|
-
inset: "0",
|
|
81
|
-
clipPath: "inset(0px 0px 0px 0px)",
|
|
82
|
-
willChange: "clip-path",
|
|
83
|
-
pointerEvents: "none",
|
|
84
|
-
transition: `clip-path ${DURATION_MS}ms ${EASING}`,
|
|
85
|
-
zIndex: "9998",
|
|
86
|
-
background: "transparent"
|
|
87
|
-
});
|
|
88
|
-
document.body.appendChild(clipper);
|
|
89
|
-
void clipper.offsetWidth;
|
|
90
|
-
return clipper;
|
|
91
|
-
}
|
|
92
|
-
function insetForRect(r) {
|
|
93
|
-
const vw = window.innerWidth;
|
|
94
|
-
const vh = window.innerHeight;
|
|
95
|
-
const top = r.top;
|
|
96
|
-
const left = r.left;
|
|
97
|
-
const right = vw - (r.left + r.width);
|
|
98
|
-
const bottom = vh - (r.top + r.height);
|
|
99
|
-
return `inset(${px(top)} ${px(right)} ${px(bottom)} ${px(left)})`;
|
|
100
|
-
}
|
|
101
|
-
function findThumbInfoEnsuringVisible(wrapIndex, centerAlign, sliderRef, slidesRef, selectedIndex, sliderX, sliderVelocity, centerSlider, isWrappingRef, visibleImagesRef, setSliderIndex) {
|
|
102
|
-
const slider = sliderRef.current;
|
|
103
|
-
const slides = slidesRef.current;
|
|
104
|
-
if (!slider || !slides?.length) return null;
|
|
105
|
-
const matchSlide = slides.find((s) => s.cells.some((c) => c.index === wrapIndex));
|
|
106
|
-
if (!matchSlide) return null;
|
|
107
|
-
const slideIdx = slides.indexOf(matchSlide);
|
|
108
|
-
const targetCell = matchSlide.cells.find((c) => c.index === wrapIndex)?.element ?? matchSlide.cells[0]?.element ?? null;
|
|
109
|
-
if (!targetCell) return null;
|
|
110
|
-
const viewport = getViewportEl(slider);
|
|
111
|
-
if (!viewport) return null;
|
|
112
|
-
const fullyVisible = isCellVisible(
|
|
113
|
-
targetCell,
|
|
114
|
-
viewport,
|
|
115
|
-
/*allowPartial*/
|
|
116
|
-
false
|
|
117
|
-
);
|
|
118
|
-
if (!fullyVisible) {
|
|
119
|
-
moveBaseSliderToSlide(
|
|
120
|
-
centerAlign,
|
|
121
|
-
sliderRef,
|
|
122
|
-
slidesRef,
|
|
123
|
-
selectedIndex,
|
|
124
|
-
sliderX,
|
|
125
|
-
sliderVelocity,
|
|
126
|
-
centerSlider,
|
|
127
|
-
slideIdx,
|
|
128
|
-
setSliderIndex
|
|
129
|
-
);
|
|
130
|
-
void slider.offsetWidth;
|
|
131
|
-
}
|
|
132
|
-
const isWrapping = !!isWrappingRef.current;
|
|
133
|
-
const visibleImages = visibleImagesRef.current;
|
|
134
|
-
const cloneOffset = isWrapping ? visibleImages || 0 : 0;
|
|
135
|
-
const domSlideIdx = isWrapping ? slideIdx + cloneOffset : slideIdx;
|
|
136
|
-
const cropRect = targetCell.getBoundingClientRect();
|
|
137
|
-
const imgEl = targetCell.querySelector("img");
|
|
138
|
-
const cs = imgEl ? getComputedStyle(imgEl) : null;
|
|
139
|
-
const objPos = parseObjectPosition(cs?.objectPosition ?? null) ?? { x: 0.5, y: 0.5 };
|
|
140
|
-
const renderedRect = imgEl?.getBoundingClientRect() ?? null;
|
|
141
|
-
const renderedW = renderedRect ? renderedRect.width : 0;
|
|
142
|
-
const renderedH = renderedRect ? renderedRect.height : 0;
|
|
143
|
-
return {
|
|
144
|
-
slideIdx,
|
|
145
|
-
domSlideIdx,
|
|
146
|
-
cropRect,
|
|
147
|
-
imgEl,
|
|
148
|
-
objPos,
|
|
149
|
-
renderedW,
|
|
150
|
-
renderedH,
|
|
151
|
-
renderedRect
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
function moveBaseSliderToSlide(centerAlign, sliderRef, slidesRef, selectedIndex, sliderX, sliderVelocity, centerSlider, newIndex, setSliderIndex) {
|
|
155
|
-
const slider = sliderRef.current;
|
|
156
|
-
const slides = slidesRef.current;
|
|
157
|
-
if (!slider || !slides) return;
|
|
158
|
-
const viewport = getViewportEl(slider);
|
|
159
|
-
if (!viewport) return;
|
|
160
|
-
const totalWidth = getTotalCellsWidth(slides);
|
|
161
|
-
const containerWidth = viewport.clientWidth;
|
|
162
|
-
const firstCellWidthOfSlide = slides[newIndex].cells[0].element.clientWidth;
|
|
163
|
-
const center = centerAlign ? (containerWidth - firstCellWidthOfSlide) / 2 : 0;
|
|
164
|
-
const matchSlide = slides[newIndex];
|
|
165
|
-
selectedIndex.current = newIndex;
|
|
166
|
-
setSliderIndex(newIndex, "instant");
|
|
167
|
-
sliderX.current = totalWidth <= containerWidth ? 0 : -matchSlide.target + center;
|
|
168
|
-
sliderVelocity.current = 0;
|
|
169
|
-
slider.style.transform = `translate3d(${px(sliderX.current)},0,0)`;
|
|
170
|
-
centerSlider?.();
|
|
171
|
-
}
|
|
172
|
-
async function captureVideoFrame(video) {
|
|
173
|
-
try {
|
|
174
|
-
const w = video.videoWidth || Math.round(video.getBoundingClientRect().width) || 1;
|
|
175
|
-
const h = video.videoHeight || Math.round(video.getBoundingClientRect().height) || 1;
|
|
176
|
-
if (!w || !h) ;
|
|
177
|
-
const canvas = document.createElement("canvas");
|
|
178
|
-
canvas.width = w;
|
|
179
|
-
canvas.height = h;
|
|
180
|
-
const ctx = canvas.getContext("2d");
|
|
181
|
-
if (!ctx) return null;
|
|
182
|
-
ctx.drawImage(video, 0, 0, w, h);
|
|
183
|
-
const dataURL = canvas.toDataURL("image/png");
|
|
184
|
-
const img = new Image();
|
|
185
|
-
img.decoding = "async";
|
|
186
|
-
img.src = dataURL;
|
|
187
|
-
await img.decode().catch(() => {
|
|
188
|
-
});
|
|
189
|
-
return img;
|
|
190
|
-
} catch {
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
function extractPlyrPoster(wrapperEl) {
|
|
195
|
-
if (!wrapperEl) return null;
|
|
196
|
-
const v = wrapperEl.querySelector("video");
|
|
197
|
-
if (v?.poster) return v.poster;
|
|
198
|
-
const posterEl = wrapperEl.querySelector(".plyr__poster");
|
|
199
|
-
if (posterEl) {
|
|
200
|
-
const bg = getComputedStyle(posterEl).backgroundImage;
|
|
201
|
-
const match = bg && /url\(["']?(.*?)["']?\)/.exec(bg);
|
|
202
|
-
if (match?.[1]) return match[1];
|
|
203
|
-
}
|
|
204
|
-
return null;
|
|
205
|
-
}
|
|
206
|
-
async function makeVideoProxy(movingVideo, wrapperEl) {
|
|
207
|
-
const frame = await captureVideoFrame(movingVideo);
|
|
208
|
-
if (frame) return frame;
|
|
209
|
-
const posterURL = extractPlyrPoster(wrapperEl);
|
|
210
|
-
const img = new Image();
|
|
211
|
-
img.decoding = "async";
|
|
212
|
-
if (posterURL) {
|
|
213
|
-
img.src = posterURL;
|
|
214
|
-
try {
|
|
215
|
-
await img.decode();
|
|
216
|
-
} catch {
|
|
217
|
-
}
|
|
218
|
-
} else {
|
|
219
|
-
const w = movingVideo.videoWidth || 1;
|
|
220
|
-
const h = movingVideo.videoHeight || 1;
|
|
221
|
-
const c = document.createElement("canvas");
|
|
222
|
-
c.width = Math.max(1, w);
|
|
223
|
-
c.height = Math.max(1, h);
|
|
224
|
-
img.src = c.toDataURL("image/png");
|
|
225
|
-
}
|
|
226
|
-
return img;
|
|
227
|
-
}
|
|
228
|
-
function getVideoObjPos(videoEl) {
|
|
229
|
-
if (!videoEl) return { x: 0.5, y: 0.5 };
|
|
230
|
-
const cs = getComputedStyle(videoEl);
|
|
231
|
-
return parseObjectPosition(cs?.objectPosition ?? null);
|
|
232
|
-
}
|
|
233
|
-
function styleProxyImage(img, objPos) {
|
|
234
|
-
img.decoding = "async";
|
|
235
|
-
img.loading = "eager";
|
|
236
|
-
img.draggable = false;
|
|
237
|
-
img.style.pointerEvents = "none";
|
|
238
|
-
img.style.objectFit = "cover";
|
|
239
|
-
img.style.objectPosition = `${Math.round(objPos.x * 100)}% ${Math.round(objPos.y * 100)}%`;
|
|
240
|
-
}
|
|
241
|
-
function isElementOnScreen(el, visibleThreshold = 0.4) {
|
|
242
|
-
const rect = el.getBoundingClientRect();
|
|
243
|
-
const vh = window.innerHeight || document.documentElement.clientHeight;
|
|
244
|
-
const visibleHeight = Math.min(rect.bottom, vh) - Math.max(rect.top, 0);
|
|
245
|
-
if (visibleHeight <= 0) return false;
|
|
246
|
-
return visibleHeight >= rect.height * visibleThreshold;
|
|
247
|
-
}
|
|
248
|
-
async function scrollEntrySectionIntoView(entryIndex) {
|
|
249
|
-
if (typeof window === "undefined") return;
|
|
250
|
-
const section = document.querySelector(
|
|
251
|
-
`[data-rmg-entry-owner="${entryIndex}"]`
|
|
252
|
-
);
|
|
253
|
-
if (!section) return;
|
|
254
|
-
if (isElementOnScreen(section, 0.5)) return;
|
|
255
|
-
const rect = section.getBoundingClientRect();
|
|
256
|
-
const currentScroll = window.scrollY || document.documentElement.scrollTop || 0;
|
|
257
|
-
const viewportHeight = window.innerHeight || document.documentElement.clientHeight || rect.height;
|
|
258
|
-
const targetTop = rect.top + currentScroll - (viewportHeight - rect.height) / 2;
|
|
259
|
-
window.scrollTo({
|
|
260
|
-
top: targetTop,
|
|
261
|
-
behavior: "instant"
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
async function scrollElementIntoCenterView(el) {
|
|
265
|
-
if (!el) return;
|
|
266
|
-
if (isElementOnScreen(el, 0.5)) return;
|
|
267
|
-
const rect = el.getBoundingClientRect();
|
|
268
|
-
const scrollY = window.scrollY || document.documentElement.scrollTop || 0;
|
|
269
|
-
const viewportHeight = window.innerHeight || document.documentElement.clientHeight || rect.height;
|
|
270
|
-
const targetTop = rect.top + scrollY - (viewportHeight - rect.height) / 2;
|
|
271
|
-
window.scrollTo({
|
|
272
|
-
top: targetTop,
|
|
273
|
-
behavior: "instant"
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
async function animateVideoCloseProxy({
|
|
277
|
-
fsSliderEl,
|
|
278
|
-
nodeIdx,
|
|
279
|
-
thumbCropRect,
|
|
280
|
-
endObjPos,
|
|
281
|
-
captionClone,
|
|
282
|
-
safeTeardown,
|
|
283
|
-
onCaptionCloneGone,
|
|
284
|
-
DURATION_MS,
|
|
285
|
-
EASING
|
|
286
|
-
}) {
|
|
287
|
-
const wrapperEl = fsSliderEl.querySelector(`.rmg__player[data-index="${nodeIdx}"]`) || fsSliderEl.querySelector(".rmg__player") || null;
|
|
288
|
-
const fsVideo = wrapperEl?.querySelector("video");
|
|
289
|
-
const fsRect = wrapperEl?.getBoundingClientRect?.() || fsVideo?.getBoundingClientRect?.();
|
|
290
|
-
if (!fsRect) {
|
|
291
|
-
safeTeardown();
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
if (wrapperEl) {
|
|
295
|
-
freezeRect(wrapperEl);
|
|
296
|
-
wrapperEl.style.visibility = "hidden";
|
|
297
|
-
wrapperEl.style.opacity = "0";
|
|
298
|
-
const poster = wrapperEl.querySelector(".plyr__poster");
|
|
299
|
-
if (poster) poster.style.opacity = "0";
|
|
300
|
-
const controls = wrapperEl.querySelector(".plyr__controls");
|
|
301
|
-
if (controls) controls.style.opacity = "0";
|
|
302
|
-
}
|
|
303
|
-
if (fsVideo) {
|
|
304
|
-
try {
|
|
305
|
-
fsVideo.pause();
|
|
306
|
-
} catch {
|
|
307
|
-
}
|
|
308
|
-
fsVideo.muted = true;
|
|
309
|
-
}
|
|
310
|
-
const vidForProxy = fsVideo || wrapperEl?.querySelector("video");
|
|
311
|
-
if (!vidForProxy) {
|
|
312
|
-
safeTeardown();
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
const proxyImg = await makeVideoProxy(vidForProxy, wrapperEl);
|
|
316
|
-
styleProxyImage(proxyImg, endObjPos);
|
|
317
|
-
const natW = proxyImg.naturalWidth || 1;
|
|
318
|
-
const natH = proxyImg.naturalHeight || 1;
|
|
319
|
-
const startObjPos = getVideoObjPos(fsVideo);
|
|
320
|
-
const startT = coverTransformForRect(natW, natH, fsRect, startObjPos);
|
|
321
|
-
const endT = coverTransformForRect(natW, natH, thumbCropRect, endObjPos);
|
|
322
|
-
const movingProxy = proxyImg;
|
|
323
|
-
Object.assign(movingProxy.style, {
|
|
324
|
-
position: "fixed",
|
|
325
|
-
left: "0",
|
|
326
|
-
top: "0",
|
|
327
|
-
width: `${natW}px`,
|
|
328
|
-
height: `${natH}px`,
|
|
329
|
-
maxWidth: "none",
|
|
330
|
-
maxHeight: "none",
|
|
331
|
-
transformOrigin: "50% 50%",
|
|
332
|
-
willChange: "transform",
|
|
333
|
-
zIndex: "2147483601",
|
|
334
|
-
opacity: "1",
|
|
335
|
-
transition: "none"
|
|
336
|
-
});
|
|
337
|
-
movingProxy.style.transform = `translate3d(${startT.cx}px, ${startT.cy}px, 0) translate3d(${-natW / 2}px, ${-natH / 2}px, 0) scale(${startT.scale})`;
|
|
338
|
-
const clipper = createClipper({ DURATION_MS, EASING });
|
|
339
|
-
clipper.style.clipPath = insetForRect(fsRect);
|
|
340
|
-
clipper.appendChild(movingProxy);
|
|
341
|
-
void movingProxy.offsetWidth;
|
|
342
|
-
void clipper.offsetWidth;
|
|
343
|
-
const cleanup = () => {
|
|
344
|
-
if (captionClone) {
|
|
345
|
-
try {
|
|
346
|
-
captionClone.remove();
|
|
347
|
-
} catch {
|
|
348
|
-
}
|
|
349
|
-
onCaptionCloneGone?.();
|
|
350
|
-
}
|
|
351
|
-
try {
|
|
352
|
-
document.body.removeChild(clipper);
|
|
353
|
-
} catch {
|
|
354
|
-
}
|
|
355
|
-
try {
|
|
356
|
-
movingProxy.remove();
|
|
357
|
-
} catch {
|
|
358
|
-
}
|
|
359
|
-
safeTeardown();
|
|
360
|
-
};
|
|
361
|
-
const onEnd = (ev) => {
|
|
362
|
-
if (ev.propertyName !== "transform") return;
|
|
363
|
-
movingProxy.removeEventListener("transitionend", onEnd);
|
|
364
|
-
cleanup();
|
|
365
|
-
};
|
|
366
|
-
requestAnimationFrame(() => {
|
|
367
|
-
clipper.style.clipPath = insetForRect(thumbCropRect);
|
|
368
|
-
movingProxy.style.transition = `transform ${DURATION_MS}ms ${EASING}`;
|
|
369
|
-
movingProxy.style.transform = `translate3d(${endT.cx}px, ${endT.cy}px, 0) translate3d(${-natW / 2}px, ${-natH / 2}px, 0) scale(${endT.scale})`;
|
|
370
|
-
movingProxy.addEventListener("transitionend", onEnd, { once: true });
|
|
371
|
-
window.setTimeout(() => {
|
|
372
|
-
movingProxy.removeEventListener("transitionend", onEnd);
|
|
373
|
-
cleanup();
|
|
374
|
-
}, DURATION_MS + 120);
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
var FullscreenModal = ({
|
|
378
|
-
children,
|
|
379
|
-
fsSub,
|
|
380
|
-
open,
|
|
381
|
-
onClose,
|
|
382
|
-
isClick,
|
|
383
|
-
isAnimating,
|
|
384
|
-
overlayDivRef,
|
|
385
|
-
closeButtonRef,
|
|
386
|
-
counterRef,
|
|
387
|
-
leftChevronRef,
|
|
388
|
-
rightChevronRef,
|
|
389
|
-
cells,
|
|
390
|
-
setShowFullscreenSlider,
|
|
391
|
-
imageCount,
|
|
392
|
-
setClosingModal,
|
|
393
|
-
slides,
|
|
394
|
-
slider,
|
|
395
|
-
visibleImagesRef,
|
|
396
|
-
selectedIndex,
|
|
397
|
-
sliderX,
|
|
398
|
-
sliderVelocity,
|
|
399
|
-
isWrapping,
|
|
400
|
-
wrappedItems,
|
|
401
|
-
centerAlign,
|
|
402
|
-
centerSlider,
|
|
403
|
-
setSliderIndex,
|
|
404
|
-
onForceResetZoom,
|
|
405
|
-
layout,
|
|
406
|
-
expandableImgRefs,
|
|
407
|
-
entryMapRef,
|
|
408
|
-
entryMediaLayout,
|
|
409
|
-
introFade,
|
|
410
|
-
introDuration = 300,
|
|
411
|
-
introEasing = "cubic-bezier(.4,0,.22,1)",
|
|
412
|
-
requestFsCloseRef,
|
|
413
|
-
fs,
|
|
414
|
-
styles,
|
|
415
|
-
direction
|
|
416
|
-
}) => {
|
|
417
|
-
const DURATION_MS = introDuration;
|
|
418
|
-
const EASING = introEasing;
|
|
419
|
-
const modalRef = React__default.useRef(null);
|
|
420
|
-
const pointerDownX = React__default.useRef(0);
|
|
421
|
-
const pointerDownY = React__default.useRef(0);
|
|
422
|
-
const shieldRef = React__default.useRef(null);
|
|
423
|
-
function mountShield() {
|
|
424
|
-
if (shieldRef.current) return;
|
|
425
|
-
const shield = document.createElement("div");
|
|
426
|
-
shield.setAttribute("data-rmg-fs-shield", "true");
|
|
427
|
-
Object.assign(shield.style, {
|
|
428
|
-
position: "fixed",
|
|
429
|
-
inset: "0",
|
|
430
|
-
zIndex: "2147483606",
|
|
431
|
-
background: "transparent",
|
|
432
|
-
pointerEvents: "auto",
|
|
433
|
-
touchAction: "none",
|
|
434
|
-
cursor: "default"
|
|
435
|
-
});
|
|
436
|
-
const stop = (e) => {
|
|
437
|
-
e.preventDefault?.();
|
|
438
|
-
e.stopPropagation?.();
|
|
439
|
-
};
|
|
440
|
-
shield.addEventListener("pointerdown", stop, { capture: true });
|
|
441
|
-
shield.addEventListener("pointerup", stop, { capture: true });
|
|
442
|
-
shield.addEventListener("pointermove", stop, { capture: true });
|
|
443
|
-
shield.addEventListener("click", stop, { capture: true });
|
|
444
|
-
shield.addEventListener("dblclick", stop, { capture: true });
|
|
445
|
-
shield.addEventListener("contextmenu", stop, { capture: true });
|
|
446
|
-
shield.addEventListener("touchstart", stop, { capture: true, passive: false });
|
|
447
|
-
shield.addEventListener("touchmove", stop, { capture: true, passive: false });
|
|
448
|
-
shield.addEventListener("touchend", stop, { capture: true, passive: false });
|
|
449
|
-
shield.addEventListener("wheel", stop, { capture: true, passive: false });
|
|
450
|
-
shield.addEventListener(
|
|
451
|
-
"keydown",
|
|
452
|
-
stop,
|
|
453
|
-
{ capture: true }
|
|
454
|
-
);
|
|
455
|
-
document.body.appendChild(shield);
|
|
456
|
-
shieldRef.current = shield;
|
|
457
|
-
}
|
|
458
|
-
function unmountShield() {
|
|
459
|
-
const shield = shieldRef.current;
|
|
460
|
-
if (!shield) return;
|
|
461
|
-
try {
|
|
462
|
-
shield.remove();
|
|
463
|
-
} catch {
|
|
464
|
-
}
|
|
465
|
-
shieldRef.current = null;
|
|
466
|
-
}
|
|
467
|
-
useEffect(() => {
|
|
468
|
-
return () => unmountShield();
|
|
469
|
-
}, []);
|
|
470
|
-
function mergeClassNames(...parts) {
|
|
471
|
-
return parts.filter(Boolean).join(" ");
|
|
472
|
-
}
|
|
473
|
-
function styleFromElementStyle(es) {
|
|
474
|
-
return es?.style ?? void 0;
|
|
475
|
-
}
|
|
476
|
-
function classFromElementStyle(es) {
|
|
477
|
-
return es?.className ?? "";
|
|
478
|
-
}
|
|
479
|
-
function getArrowAction(side, isRtl2) {
|
|
480
|
-
if (side === "left") return isRtl2 ? "next" : "prev";
|
|
481
|
-
return isRtl2 ? "prev" : "next";
|
|
482
|
-
}
|
|
483
|
-
function runArrowAction(fsSub2, action) {
|
|
484
|
-
if (action === "next") fsSub2.requestNext();
|
|
485
|
-
else fsSub2.requestPrev();
|
|
486
|
-
}
|
|
487
|
-
function withinFs(sel) {
|
|
488
|
-
const root = modalRef.current;
|
|
489
|
-
return root ? root.querySelector(sel) : null;
|
|
490
|
-
}
|
|
491
|
-
useEffect(() => {
|
|
492
|
-
if (!open) return;
|
|
493
|
-
const onKeyDown = (e) => {
|
|
494
|
-
if (e.key !== "Escape") return;
|
|
495
|
-
e.preventDefault();
|
|
496
|
-
e.stopPropagation();
|
|
497
|
-
proceedToClose();
|
|
498
|
-
};
|
|
499
|
-
window.addEventListener("keydown", onKeyDown, { capture: true });
|
|
500
|
-
return () => window.removeEventListener("keydown", onKeyDown, { capture: true });
|
|
501
|
-
}, [open]);
|
|
502
|
-
function nodeIdxFromFs(fsIdx, imageCount2) {
|
|
503
|
-
const fsSlider = withinFs(".fullscreen_slider");
|
|
504
|
-
if (!fsSlider) return Math.max(0, Math.min(imageCount2 + 1, fsIdx + 1));
|
|
505
|
-
let currentTranslateX = 0;
|
|
506
|
-
const transform = getComputedStyle(fsSlider).transform;
|
|
507
|
-
if (transform !== "none") {
|
|
508
|
-
const matrix = new DOMMatrixReadOnly(transform);
|
|
509
|
-
currentTranslateX = matrix.m41;
|
|
510
|
-
}
|
|
511
|
-
if (imageCount2 === 1) return 0;
|
|
512
|
-
if (fsIdx === 0 && Math.abs(currentTranslateX) >= fsSlider.getBoundingClientRect().width) return imageCount2 + 1;
|
|
513
|
-
if (fsIdx === 0) return 1;
|
|
514
|
-
if (fsIdx === imageCount2 + 1) return imageCount2 + 1;
|
|
515
|
-
return Math.max(1, Math.min(imageCount2, fsIdx + 1));
|
|
516
|
-
}
|
|
517
|
-
function cloneFsCaptionForNode(fsRoot, nodeIdx) {
|
|
518
|
-
if (!fsRoot) return null;
|
|
519
|
-
const activeMediaEl = fsRoot.querySelector(`[data-index="${nodeIdx}"]`) ?? null;
|
|
520
|
-
const activeSlideEl = activeMediaEl ? activeMediaEl.closest('[data-rmg-fs-slide="true"]') : null;
|
|
521
|
-
const activeCaptionEl = activeSlideEl?.querySelector('[data-rmg-fs-caption="true"]') ?? null;
|
|
522
|
-
if (!activeCaptionEl) return null;
|
|
523
|
-
const r = activeCaptionEl.getBoundingClientRect();
|
|
524
|
-
const captionClone = activeCaptionEl.cloneNode(true);
|
|
525
|
-
Object.assign(captionClone.style, {
|
|
526
|
-
position: "fixed",
|
|
527
|
-
left: `${Math.round(r.left)}px`,
|
|
528
|
-
top: `${Math.round(r.top)}px`,
|
|
529
|
-
width: `${Math.round(r.width)}px`,
|
|
530
|
-
height: `${Math.round(r.height)}px`,
|
|
531
|
-
margin: "0",
|
|
532
|
-
transform: "none",
|
|
533
|
-
zIndex: "2147483602",
|
|
534
|
-
pointerEvents: "none"
|
|
535
|
-
});
|
|
536
|
-
document.body.appendChild(captionClone);
|
|
537
|
-
activeCaptionEl.style.visibility = "hidden";
|
|
538
|
-
return captionClone;
|
|
539
|
-
}
|
|
540
|
-
function fadeChrome() {
|
|
541
|
-
const els = [
|
|
542
|
-
leftChevronRef.current,
|
|
543
|
-
rightChevronRef.current,
|
|
544
|
-
counterRef.current,
|
|
545
|
-
closeButtonRef.current
|
|
546
|
-
];
|
|
547
|
-
els.forEach((el) => {
|
|
548
|
-
if (!el) return;
|
|
549
|
-
el.classList.remove(styles.open);
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
function fadeNonActiveSlides(fsSlider, nodeIdx, targetImg, isVideoSlide) {
|
|
553
|
-
if (isVideoSlide) {
|
|
554
|
-
fsSlider.querySelectorAll("[data-index]").forEach((el) => {
|
|
555
|
-
if (el.dataset.index === String(nodeIdx)) return;
|
|
556
|
-
el.style.transition = "opacity 0.3s cubic-bezier(.4,0,.22,1)";
|
|
557
|
-
el.style.opacity = "0";
|
|
558
|
-
});
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
|
-
fsSlider.querySelectorAll('[data-rmg-fs-slide="true"]').forEach((slide) => {
|
|
562
|
-
if (targetImg && slide.contains(targetImg)) return;
|
|
563
|
-
slide.style.transition = "opacity 0.3s cubic-bezier(.4,0,.22,1)";
|
|
564
|
-
slide.style.opacity = "0";
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
function fadeOverlay() {
|
|
568
|
-
const ov = overlayDivRef.current;
|
|
569
|
-
if (!ov) return;
|
|
570
|
-
ov.style.transition = `opacity ${DURATION_MS}ms ${EASING}`;
|
|
571
|
-
ov.style.opacity = "0";
|
|
572
|
-
ov.style.pointerEvents = "none";
|
|
573
|
-
}
|
|
574
|
-
function isVideoItem(m) {
|
|
575
|
-
if (!m) return false;
|
|
576
|
-
return m.kind === "video" || /\.(mp4|webm|ogg)$/i.test(m.src || "");
|
|
577
|
-
}
|
|
578
|
-
function fadeCloseAndTeardown() {
|
|
579
|
-
fadeChrome();
|
|
580
|
-
fadeOverlay();
|
|
581
|
-
const fsSlider = withinFs(".fullscreen_slider");
|
|
582
|
-
if (fsSlider) {
|
|
583
|
-
fsSlider.style.transition = `opacity ${DURATION_MS}ms ${EASING}`;
|
|
584
|
-
fsSlider.style.opacity = "0";
|
|
585
|
-
}
|
|
586
|
-
const modal = withinFs(".fs_modal");
|
|
587
|
-
if (modal) {
|
|
588
|
-
modal.style.transition = `opacity ${DURATION_MS}ms ${EASING}`;
|
|
589
|
-
modal.style.opacity = "0";
|
|
590
|
-
modal.style.pointerEvents = "none";
|
|
591
|
-
}
|
|
592
|
-
window.setTimeout(() => {
|
|
593
|
-
safeTeardown();
|
|
594
|
-
}, DURATION_MS + 40);
|
|
595
|
-
}
|
|
596
|
-
async function proceedToClose() {
|
|
597
|
-
if (!open) return;
|
|
598
|
-
mountShield();
|
|
599
|
-
isAnimating.current = false;
|
|
600
|
-
isClick.current = false;
|
|
601
|
-
cells.current = [];
|
|
602
|
-
setClosingModal(true);
|
|
603
|
-
const originals = wrappedItems.slice(1, wrappedItems.length - 1);
|
|
604
|
-
if (!originals.length) {
|
|
605
|
-
safeTeardown();
|
|
606
|
-
return;
|
|
607
|
-
}
|
|
608
|
-
const fsIdx = fsSub.get();
|
|
609
|
-
const isGridish = layout === "grid" || layout === "masonry" || entryMediaLayout === "grid" || entryMediaLayout === "masonry";
|
|
610
|
-
const computeThumbCropRectFromImg = (img) => {
|
|
611
|
-
const box = img.getBoundingClientRect();
|
|
612
|
-
const cs = getComputedStyle(img);
|
|
613
|
-
const objPos = parseObjectPosition(cs?.objectPosition ?? null) ?? { x: 0.5, y: 0.5 };
|
|
614
|
-
const fit = cs?.objectFit ?? "cover";
|
|
615
|
-
if (fit !== "contain") return { cropRect: box, objPos };
|
|
616
|
-
const natW = Math.max(1, img.naturalWidth || 0);
|
|
617
|
-
const natH = Math.max(1, img.naturalHeight || 0);
|
|
618
|
-
const cropRect = objectFitContentRect(natW, natH, box, "contain", objPos);
|
|
619
|
-
return { cropRect, objPos };
|
|
620
|
-
};
|
|
621
|
-
const animateCloseToThumb = async (args) => {
|
|
622
|
-
const fsSlider = withinFs(".fullscreen_slider");
|
|
623
|
-
if (!fsSlider) {
|
|
624
|
-
safeTeardown();
|
|
625
|
-
return;
|
|
626
|
-
}
|
|
627
|
-
const nodeIdx = nodeIdxFromFs(fsSub.get(), imageCount);
|
|
628
|
-
const targetImg = !args.isVideoSlide ? fsSlider.querySelector(`img[data-index="${nodeIdx}"]`) ?? null : null;
|
|
629
|
-
if (!targetImg && !args.isVideoSlide) {
|
|
630
|
-
safeTeardown();
|
|
631
|
-
return;
|
|
632
|
-
}
|
|
633
|
-
fadeNonActiveSlides(fsSlider, nodeIdx, targetImg, args.isVideoSlide);
|
|
634
|
-
let captionClone = cloneFsCaptionForNode(fsSlider, nodeIdx);
|
|
635
|
-
if (captionClone) {
|
|
636
|
-
captionClone.style.transition = `opacity ${DURATION_MS}ms ${EASING}`;
|
|
637
|
-
void captionClone.offsetWidth;
|
|
638
|
-
captionClone.style.opacity = "0";
|
|
639
|
-
}
|
|
640
|
-
if (args.isVideoSlide) {
|
|
641
|
-
await animateVideoCloseProxy({
|
|
642
|
-
fsSliderEl: fsSlider,
|
|
643
|
-
nodeIdx,
|
|
644
|
-
thumbCropRect: args.thumbCropRect,
|
|
645
|
-
endObjPos: args.endObjPos ?? { x: 0.5, y: 0.5 },
|
|
646
|
-
captionClone,
|
|
647
|
-
safeTeardown,
|
|
648
|
-
DURATION_MS,
|
|
649
|
-
EASING
|
|
650
|
-
});
|
|
651
|
-
return;
|
|
652
|
-
}
|
|
653
|
-
const movingEl = targetImg;
|
|
654
|
-
if (!movingEl) {
|
|
655
|
-
safeTeardown();
|
|
656
|
-
return;
|
|
657
|
-
}
|
|
658
|
-
const restoreIntoParent = movingEl.parentNode || null;
|
|
659
|
-
const restoreNextSibling = movingEl.nextSibling || null;
|
|
660
|
-
const fsCS = targetImg ? getComputedStyle(targetImg) : null;
|
|
661
|
-
const fsObjPos = parseObjectPosition(fsCS?.objectPosition ?? null);
|
|
662
|
-
const imgEl = movingEl;
|
|
663
|
-
const fsFit = getComputedStyle(targetImg).objectFit || "contain";
|
|
664
|
-
const curRect = movingEl.getBoundingClientRect();
|
|
665
|
-
const natW = imgEl.naturalWidth || curRect.width || 1;
|
|
666
|
-
const natH = imgEl.naturalHeight || curRect.height || 1;
|
|
667
|
-
const startT = fsFit === "contain" ? containTransformForRect(natW, natH, curRect, fsObjPos) : coverTransformForRect(natW, natH, curRect, fsObjPos);
|
|
668
|
-
const endT = coverTransformForRect(natW, natH, args.thumbCropRect, args.endObjPos);
|
|
669
|
-
const clipper = createClipper({ DURATION_MS, EASING });
|
|
670
|
-
const previous = {
|
|
671
|
-
position: movingEl.style.position,
|
|
672
|
-
left: movingEl.style.left,
|
|
673
|
-
top: movingEl.style.top,
|
|
674
|
-
width: movingEl.style.width,
|
|
675
|
-
height: movingEl.style.height,
|
|
676
|
-
maxWidth: movingEl.style.maxWidth,
|
|
677
|
-
maxHeight: movingEl.style.maxHeight,
|
|
678
|
-
transformOrigin: movingEl.style.transformOrigin,
|
|
679
|
-
transform: movingEl.style.transform,
|
|
680
|
-
transition: movingEl.style.transition,
|
|
681
|
-
willChange: movingEl.style.willChange,
|
|
682
|
-
zIndex: movingEl.style.zIndex,
|
|
683
|
-
opacity: movingEl.style.opacity
|
|
684
|
-
};
|
|
685
|
-
Object.assign(movingEl.style, {
|
|
686
|
-
position: "fixed",
|
|
687
|
-
left: "0",
|
|
688
|
-
top: "0",
|
|
689
|
-
width: `${natW}px`,
|
|
690
|
-
height: `${natH}px`,
|
|
691
|
-
maxWidth: "none",
|
|
692
|
-
maxHeight: "none",
|
|
693
|
-
transformOrigin: "50% 50%",
|
|
694
|
-
willChange: "transform",
|
|
695
|
-
zIndex: "1",
|
|
696
|
-
opacity: "1",
|
|
697
|
-
transition: "none"
|
|
698
|
-
});
|
|
699
|
-
movingEl.style.transform = `translate3d(${startT.cx}px, ${startT.cy}px, 0) translate3d(${-natW / 2}px, ${-natH / 2}px, 0) scale(${startT.scale})`;
|
|
700
|
-
clipper.appendChild(movingEl);
|
|
701
|
-
void movingEl.offsetWidth;
|
|
702
|
-
void clipper.offsetWidth;
|
|
703
|
-
const targetInset = insetForRect(args.thumbCropRect);
|
|
704
|
-
requestAnimationFrame(() => {
|
|
705
|
-
clipper.style.clipPath = targetInset;
|
|
706
|
-
movingEl.style.transition = `transform ${DURATION_MS}ms ${EASING}`;
|
|
707
|
-
movingEl.style.transform = `translate3d(${endT.cx}px, ${endT.cy}px, 0) translate3d(${-natW / 2}px, ${-natH / 2}px, 0) scale(${endT.scale})`;
|
|
708
|
-
});
|
|
709
|
-
const finish = () => {
|
|
710
|
-
if (captionClone) {
|
|
711
|
-
try {
|
|
712
|
-
captionClone.remove();
|
|
713
|
-
} catch {
|
|
714
|
-
}
|
|
715
|
-
captionClone = null;
|
|
716
|
-
}
|
|
717
|
-
movingEl.removeEventListener("transitionend", onEnd);
|
|
718
|
-
try {
|
|
719
|
-
if (restoreIntoParent) {
|
|
720
|
-
if (restoreNextSibling) restoreIntoParent.insertBefore(movingEl, restoreNextSibling);
|
|
721
|
-
else restoreIntoParent.appendChild(movingEl);
|
|
722
|
-
}
|
|
723
|
-
} catch {
|
|
724
|
-
}
|
|
725
|
-
try {
|
|
726
|
-
document.body.removeChild(clipper);
|
|
727
|
-
} catch {
|
|
728
|
-
}
|
|
729
|
-
Object.assign(movingEl.style, previous);
|
|
730
|
-
safeTeardown();
|
|
731
|
-
};
|
|
732
|
-
const onEnd = (ev) => {
|
|
733
|
-
if (ev.propertyName !== "transform") return;
|
|
734
|
-
finish();
|
|
735
|
-
};
|
|
736
|
-
movingEl.addEventListener("transitionend", onEnd, { once: true });
|
|
737
|
-
window.setTimeout(() => finish(), DURATION_MS + 80);
|
|
738
|
-
};
|
|
739
|
-
let canonicalIdx2 = 0;
|
|
740
|
-
let localSlideIdx = 0;
|
|
741
|
-
if (!isGridish) {
|
|
742
|
-
if (!slider.current || !slides.current?.length) return;
|
|
743
|
-
const fsIndex = fsIdx;
|
|
744
|
-
if (isWrapping.current) {
|
|
745
|
-
if (slider.current && fsIndex >= slider.current.children.length - (visibleImagesRef.current || 0) * 2 && layout !== "entries") {
|
|
746
|
-
canonicalIdx2 = 0;
|
|
747
|
-
} else {
|
|
748
|
-
canonicalIdx2 = fsIndex;
|
|
749
|
-
}
|
|
750
|
-
} else {
|
|
751
|
-
const maxMedia = Math.max(0, originals.length - 1);
|
|
752
|
-
canonicalIdx2 = Math.min(Math.max(0, fsIndex), maxMedia);
|
|
753
|
-
}
|
|
754
|
-
localSlideIdx = canonicalIdx2;
|
|
755
|
-
if (layout === "entries" && entryMapRef?.current) {
|
|
756
|
-
const link = entryMapRef.current[canonicalIdx2];
|
|
757
|
-
if (link) {
|
|
758
|
-
localSlideIdx = link.mediaIndex;
|
|
759
|
-
await scrollEntrySectionIntoView(link.entryIndex);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
} else {
|
|
763
|
-
canonicalIdx2 = Math.max(0, Math.min(originals.length - 1, fsIdx));
|
|
764
|
-
localSlideIdx = canonicalIdx2;
|
|
765
|
-
const el = document.querySelector(`[data-rmg-idx="${canonicalIdx2}"]`);
|
|
766
|
-
await scrollElementIntoCenterView(el);
|
|
767
|
-
if (layout === "entries" && entryMapRef?.current) {
|
|
768
|
-
const link = entryMapRef.current[canonicalIdx2];
|
|
769
|
-
if (link) {
|
|
770
|
-
await scrollEntrySectionIntoView(link.entryIndex);
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
const url = originals[canonicalIdx2];
|
|
775
|
-
const isVideoSlide = isVideoItem(url);
|
|
776
|
-
if (introFade || isVideoSlide) {
|
|
777
|
-
fadeCloseAndTeardown();
|
|
778
|
-
return;
|
|
779
|
-
}
|
|
780
|
-
fadeChrome();
|
|
781
|
-
fadeOverlay();
|
|
782
|
-
if (!isGridish) {
|
|
783
|
-
if (!slider.current || !slides.current?.length) {
|
|
784
|
-
safeTeardown();
|
|
785
|
-
return;
|
|
786
|
-
}
|
|
787
|
-
const viewport = getViewportEl(slider.current);
|
|
788
|
-
if (!viewport) {
|
|
789
|
-
safeTeardown();
|
|
790
|
-
return;
|
|
791
|
-
}
|
|
792
|
-
const slideArr = slides.current;
|
|
793
|
-
let matchSlide = slideArr.find((s) => s.cells.some((c) => c.index === localSlideIdx));
|
|
794
|
-
let newIndex = matchSlide ? slideArr.indexOf(matchSlide) : -1;
|
|
795
|
-
if (newIndex < 0) {
|
|
796
|
-
newIndex = slideArr.length - 1;
|
|
797
|
-
matchSlide = slideArr[slideArr.length - 1];
|
|
798
|
-
}
|
|
799
|
-
if (!matchSlide) {
|
|
800
|
-
safeTeardown();
|
|
801
|
-
return;
|
|
802
|
-
}
|
|
803
|
-
const targetCellEl = matchSlide.cells.find((c) => c.index === localSlideIdx)?.element ?? matchSlide.cells[0]?.element ?? null;
|
|
804
|
-
const shouldMove = !!(viewport && targetCellEl) && !isCellVisible(targetCellEl, viewport, true);
|
|
805
|
-
const measureAndAnimate = async () => {
|
|
806
|
-
const thumbInfo = findThumbInfoEnsuringVisible(
|
|
807
|
-
localSlideIdx,
|
|
808
|
-
centerAlign,
|
|
809
|
-
slider,
|
|
810
|
-
slides,
|
|
811
|
-
selectedIndex,
|
|
812
|
-
sliderX,
|
|
813
|
-
sliderVelocity,
|
|
814
|
-
centerSlider,
|
|
815
|
-
isWrapping,
|
|
816
|
-
visibleImagesRef,
|
|
817
|
-
setSliderIndex
|
|
818
|
-
);
|
|
819
|
-
if (!thumbInfo) {
|
|
820
|
-
safeTeardown();
|
|
821
|
-
return;
|
|
822
|
-
}
|
|
823
|
-
let thumbCropRect2 = thumbInfo.cropRect;
|
|
824
|
-
let endObjPos2 = thumbInfo.objPos ?? { x: 0.5, y: 0.5 };
|
|
825
|
-
if (thumbInfo.imgEl) {
|
|
826
|
-
const { cropRect, objPos } = computeThumbCropRectFromImg(thumbInfo.imgEl);
|
|
827
|
-
thumbCropRect2 = cropRect;
|
|
828
|
-
endObjPos2 = objPos;
|
|
829
|
-
}
|
|
830
|
-
await animateCloseToThumb({
|
|
831
|
-
thumbCropRect: thumbCropRect2,
|
|
832
|
-
endObjPos: endObjPos2,
|
|
833
|
-
isVideoSlide: false
|
|
834
|
-
});
|
|
835
|
-
};
|
|
836
|
-
if (shouldMove) {
|
|
837
|
-
moveBaseSliderToSlide(
|
|
838
|
-
centerAlign,
|
|
839
|
-
slider,
|
|
840
|
-
slides,
|
|
841
|
-
selectedIndex,
|
|
842
|
-
sliderX,
|
|
843
|
-
sliderVelocity,
|
|
844
|
-
centerSlider,
|
|
845
|
-
newIndex,
|
|
846
|
-
setSliderIndex
|
|
847
|
-
);
|
|
848
|
-
requestAnimationFrame(() => {
|
|
849
|
-
requestAnimationFrame(() => {
|
|
850
|
-
void measureAndAnimate();
|
|
851
|
-
});
|
|
852
|
-
});
|
|
853
|
-
} else {
|
|
854
|
-
await measureAndAnimate();
|
|
855
|
-
}
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
if (!expandableImgRefs?.current) {
|
|
859
|
-
safeTeardown();
|
|
860
|
-
return;
|
|
861
|
-
}
|
|
862
|
-
const origImgRef = expandableImgRefs.current?.[canonicalIdx2] ?? null;
|
|
863
|
-
if (!origImgRef) {
|
|
864
|
-
safeTeardown();
|
|
865
|
-
return;
|
|
866
|
-
}
|
|
867
|
-
const { cropRect: thumbCropRect, objPos: endObjPos } = computeThumbCropRectFromImg(origImgRef);
|
|
868
|
-
await animateCloseToThumb({
|
|
869
|
-
thumbCropRect,
|
|
870
|
-
endObjPos,
|
|
871
|
-
isVideoSlide: false
|
|
872
|
-
});
|
|
873
|
-
}
|
|
874
|
-
useEffect(() => {
|
|
875
|
-
requestFsCloseRef.current = () => {
|
|
876
|
-
void proceedToClose();
|
|
877
|
-
};
|
|
878
|
-
return () => {
|
|
879
|
-
if (requestFsCloseRef.current) requestFsCloseRef.current = null;
|
|
880
|
-
};
|
|
881
|
-
}, [requestFsCloseRef, proceedToClose]);
|
|
882
|
-
function safeTeardown() {
|
|
883
|
-
unmountShield();
|
|
884
|
-
if (!introFade) {
|
|
885
|
-
const fsSlider = withinFs(".fullscreen_slider");
|
|
886
|
-
if (fsSlider) fsSlider.style.opacity = "0";
|
|
887
|
-
const modal = withinFs(".fs_modal");
|
|
888
|
-
if (modal) {
|
|
889
|
-
modal.style.opacity = "0";
|
|
890
|
-
modal.style.pointerEvents = "none";
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
overlayDivRef.current?.remove();
|
|
894
|
-
overlayDivRef.current = null;
|
|
895
|
-
onForceResetZoom();
|
|
896
|
-
onClose();
|
|
897
|
-
setShowFullscreenSlider(false);
|
|
898
|
-
setClosingModal(false);
|
|
899
|
-
}
|
|
900
|
-
const closeEnabled = fs?.controls?.close?.enabled !== false;
|
|
901
|
-
const close = () => void proceedToClose();
|
|
902
|
-
const userNode = typeof fs?.controls?.close?.render === "function" ? fs?.controls?.close.render() : null;
|
|
903
|
-
const allowFsArrows = fs?.controls?.arrows?.enabled !== false && imageCount > 1;
|
|
904
|
-
const isRtl = direction === "rtl" || false;
|
|
905
|
-
const arrows = fs?.controls?.arrows;
|
|
906
|
-
const renderArrowNode = (dir, side) => {
|
|
907
|
-
const explicit = dir === "prev" ? typeof arrows?.renderPrev === "function" ? arrows.renderPrev() : null : typeof arrows?.renderNext === "function" ? arrows.renderNext() : null;
|
|
908
|
-
if (explicit != null) return explicit;
|
|
909
|
-
if (typeof arrows?.render === "function") {
|
|
910
|
-
const node = arrows.render({ dir });
|
|
911
|
-
if (node != null) return node;
|
|
912
|
-
}
|
|
913
|
-
return /* @__PURE__ */ jsx(DefaultChevronIcon, { side });
|
|
914
|
-
};
|
|
915
|
-
function canonicalFromFsIndex(fsIndex, originalsLen2) {
|
|
916
|
-
return Math.max(0, Math.min(originalsLen2 - 1, fsIndex));
|
|
917
|
-
}
|
|
918
|
-
const originalsLen = Math.max(0, wrappedItems.length - 2);
|
|
919
|
-
const canonicalIdx = canonicalFromFsIndex(fsSub.get(), Math.max(1, originalsLen));
|
|
920
|
-
const counterEnabled = fs?.controls?.counter?.enabled !== false;
|
|
921
|
-
const showCounter = counterEnabled && imageCount > 1;
|
|
922
|
-
const userCounterNode = typeof fs?.controls?.counter?.render === "function" ? fs.controls.counter.render({ index: canonicalIdx, count: imageCount }) : null;
|
|
923
|
-
return /* @__PURE__ */ jsxs(
|
|
924
|
-
"div",
|
|
925
|
-
{
|
|
926
|
-
ref: modalRef,
|
|
927
|
-
onPointerDown: (e) => {
|
|
928
|
-
pointerDownX.current = e.clientX;
|
|
929
|
-
pointerDownY.current = e.clientY;
|
|
930
|
-
},
|
|
931
|
-
className: "fs_modal",
|
|
932
|
-
style: {
|
|
933
|
-
position: "fixed",
|
|
934
|
-
top: 0,
|
|
935
|
-
left: 0,
|
|
936
|
-
width: "100%",
|
|
937
|
-
height: "100%",
|
|
938
|
-
opacity: open ? 1 : 0,
|
|
939
|
-
pointerEvents: open ? "auto" : "none",
|
|
940
|
-
zIndex: 9999,
|
|
941
|
-
display: "block",
|
|
942
|
-
touchAction: "none",
|
|
943
|
-
contain: "layout style size",
|
|
944
|
-
overflow: "hidden"
|
|
945
|
-
},
|
|
946
|
-
children: [
|
|
947
|
-
closeEnabled && /* @__PURE__ */ jsx(
|
|
948
|
-
"button",
|
|
949
|
-
{
|
|
950
|
-
ref: closeButtonRef,
|
|
951
|
-
type: "button",
|
|
952
|
-
"aria-label": "Close",
|
|
953
|
-
onClick: () => close(),
|
|
954
|
-
className: [
|
|
955
|
-
styles?.closeBtn,
|
|
956
|
-
fs?.controls?.close?.className ?? "",
|
|
957
|
-
open ? styles.open : ""
|
|
958
|
-
].filter(Boolean).join(" "),
|
|
959
|
-
style: {
|
|
960
|
-
...fs?.controls?.close?.style
|
|
961
|
-
},
|
|
962
|
-
children: userNode ?? /* @__PURE__ */ jsx(DefaultCloseIcon, {})
|
|
963
|
-
}
|
|
964
|
-
),
|
|
965
|
-
allowFsArrows && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
966
|
-
/* @__PURE__ */ jsx(
|
|
967
|
-
"button",
|
|
968
|
-
{
|
|
969
|
-
ref: leftChevronRef,
|
|
970
|
-
type: "button",
|
|
971
|
-
"aria-label": getArrowAction("left", isRtl) === "prev" ? "Previous" : "Next",
|
|
972
|
-
onClick: () => runArrowAction(fsSub, getArrowAction("left", isRtl)),
|
|
973
|
-
className: mergeClassNames(
|
|
974
|
-
styles?.leftChevron,
|
|
975
|
-
classFromElementStyle(arrows?.arrow),
|
|
976
|
-
classFromElementStyle(arrows?.prev),
|
|
977
|
-
open ? styles.open : ""
|
|
978
|
-
),
|
|
979
|
-
style: {
|
|
980
|
-
...styleFromElementStyle(arrows?.arrow) ?? {},
|
|
981
|
-
...styleFromElementStyle(arrows?.prev) ?? {}
|
|
982
|
-
},
|
|
983
|
-
children: renderArrowNode(getArrowAction("left", isRtl), "left")
|
|
984
|
-
}
|
|
985
|
-
),
|
|
986
|
-
/* @__PURE__ */ jsx(
|
|
987
|
-
"button",
|
|
988
|
-
{
|
|
989
|
-
ref: rightChevronRef,
|
|
990
|
-
type: "button",
|
|
991
|
-
"aria-label": getArrowAction("right", isRtl) === "prev" ? "Previous" : "Next",
|
|
992
|
-
onClick: () => runArrowAction(fsSub, getArrowAction("right", isRtl)),
|
|
993
|
-
className: mergeClassNames(
|
|
994
|
-
styles?.rightChevron,
|
|
995
|
-
classFromElementStyle(arrows?.arrow),
|
|
996
|
-
classFromElementStyle(arrows?.next),
|
|
997
|
-
open ? styles.open : ""
|
|
998
|
-
),
|
|
999
|
-
style: {
|
|
1000
|
-
...styleFromElementStyle(arrows?.arrow) ?? {},
|
|
1001
|
-
...styleFromElementStyle(arrows?.next) ?? {}
|
|
1002
|
-
},
|
|
1003
|
-
children: renderArrowNode(getArrowAction("right", isRtl), "right")
|
|
1004
|
-
}
|
|
1005
|
-
)
|
|
1006
|
-
] }),
|
|
1007
|
-
showCounter && /* @__PURE__ */ jsx(
|
|
1008
|
-
"div",
|
|
1009
|
-
{
|
|
1010
|
-
ref: counterRef,
|
|
1011
|
-
className: [
|
|
1012
|
-
styles?.counter,
|
|
1013
|
-
fs?.controls?.counter?.className ?? "",
|
|
1014
|
-
open ? styles.open : ""
|
|
1015
|
-
].filter(Boolean).join(" "),
|
|
1016
|
-
style: {
|
|
1017
|
-
...fs?.controls?.counter?.style ?? {}
|
|
1018
|
-
},
|
|
1019
|
-
children: userCounterNode ?? /* @__PURE__ */ jsx(DefaultCounterText, { index: canonicalIdx, count: imageCount })
|
|
1020
|
-
}
|
|
1021
|
-
),
|
|
1022
|
-
children
|
|
1023
|
-
]
|
|
1024
|
-
}
|
|
1025
|
-
);
|
|
1026
|
-
};
|
|
1027
|
-
|
|
1028
|
-
// src/Gallery/fullscreen/FullscreenSlider.module.css
|
|
1029
|
-
var FullscreenSlider_default = {};
|
|
1030
|
-
var clamp01 = (n) => Math.max(0, Math.min(1, n));
|
|
1031
|
-
var easeOutCubic = (t) => 1 - Math.pow(1 - t, 3);
|
|
1032
|
-
function DragTracker(axis, ownerWindow) {
|
|
1033
|
-
return createDragTracker({
|
|
1034
|
-
ownerWindow,
|
|
1035
|
-
axis
|
|
1036
|
-
});
|
|
1037
|
-
}
|
|
1038
|
-
var FullscreenSlider = forwardRef(
|
|
1039
|
-
({
|
|
1040
|
-
sub,
|
|
1041
|
-
children,
|
|
1042
|
-
imageCount,
|
|
1043
|
-
slideIndex,
|
|
1044
|
-
isClick,
|
|
1045
|
-
isZoomed,
|
|
1046
|
-
windowSize,
|
|
1047
|
-
show,
|
|
1048
|
-
handleZoomToggle,
|
|
1049
|
-
imageRefs,
|
|
1050
|
-
cells,
|
|
1051
|
-
isPinching,
|
|
1052
|
-
isTouchPinching,
|
|
1053
|
-
showFullscreenSlider,
|
|
1054
|
-
isZooming,
|
|
1055
|
-
plyrRefs,
|
|
1056
|
-
plyrRef,
|
|
1057
|
-
closingModal,
|
|
1058
|
-
counterRef,
|
|
1059
|
-
leftChevronRef,
|
|
1060
|
-
rightChevronRef,
|
|
1061
|
-
closeButtonRef,
|
|
1062
|
-
overlayDivRef,
|
|
1063
|
-
direction,
|
|
1064
|
-
isWrapping,
|
|
1065
|
-
sliderDuration,
|
|
1066
|
-
sliderFriction,
|
|
1067
|
-
suppressLoopRef,
|
|
1068
|
-
fadeOpening,
|
|
1069
|
-
introFade,
|
|
1070
|
-
slideFade = false,
|
|
1071
|
-
slideFadeDuration = 120,
|
|
1072
|
-
slideFadeEasing = "cubic-bezier(.4,0,.22,1)",
|
|
1073
|
-
normalizedItems,
|
|
1074
|
-
introDuration = 300,
|
|
1075
|
-
introEasing = "cubic-bezier(.4,0,.22,1)",
|
|
1076
|
-
resetAllZoomDom,
|
|
1077
|
-
requestFsCloseRef
|
|
1078
|
-
}, ref) => {
|
|
1079
|
-
const isRtl = direction === "rtl" ? true : false;
|
|
1080
|
-
const rtlCls = isRtl ? FullscreenSlider_default.rtl : "";
|
|
1081
|
-
const sign = isRtl ? -1 : 1;
|
|
1082
|
-
const viewportRef = useRef(null);
|
|
1083
|
-
const slider = useRef(null);
|
|
1084
|
-
const axisRef = useRef(null);
|
|
1085
|
-
const locationRef = useRef(null);
|
|
1086
|
-
const previousLocationRef = useRef(null);
|
|
1087
|
-
const offsetLocationRef = useRef(null);
|
|
1088
|
-
const targetRef = useRef(null);
|
|
1089
|
-
const bodyRef = useRef(null);
|
|
1090
|
-
const translateRef = useRef(null);
|
|
1091
|
-
const animRef = useRef(null);
|
|
1092
|
-
const isAnimatingRef = useRef(false);
|
|
1093
|
-
const pointerDownRef = useRef(false);
|
|
1094
|
-
const yTemp = useRef(0);
|
|
1095
|
-
const dragThreshold = 5;
|
|
1096
|
-
const FADE_DISTANCE = 300;
|
|
1097
|
-
const selectedIndex = useRef(0);
|
|
1098
|
-
const hasPositioned = useRef(false);
|
|
1099
|
-
const perSlideRef = useRef(0);
|
|
1100
|
-
const contentSizeRef = useRef(0);
|
|
1101
|
-
const loopLimitRef = useRef(null);
|
|
1102
|
-
const scrollSnapsRef = useRef([]);
|
|
1103
|
-
const scrollContentSizeRef = useRef(0);
|
|
1104
|
-
const scrollLimitRef = useRef(null);
|
|
1105
|
-
const scrollTargetRef = useRef(null);
|
|
1106
|
-
const scrollToRef = useRef(null);
|
|
1107
|
-
const slides = useRef([]);
|
|
1108
|
-
const indexCurrentRef = useRef(null);
|
|
1109
|
-
const indexPreviousRef = useRef(null);
|
|
1110
|
-
const isPointerDown = useRef(false);
|
|
1111
|
-
const isVerticalScroll = useRef(false);
|
|
1112
|
-
const isScrolling = useRef(false);
|
|
1113
|
-
const isClosing = useRef(false);
|
|
1114
|
-
const clickedImgMargin = useRef(false);
|
|
1115
|
-
const dragStartY = useRef(0);
|
|
1116
|
-
const dragYForClose = useRef(0);
|
|
1117
|
-
const x = useRef(0);
|
|
1118
|
-
const y = useRef(0);
|
|
1119
|
-
const velocityX = useRef(0);
|
|
1120
|
-
const dragX = useRef(0);
|
|
1121
|
-
const previousDragX = useRef(0);
|
|
1122
|
-
const dragMoveTime = useRef(null);
|
|
1123
|
-
const activeTouchCount = useRef(0);
|
|
1124
|
-
const wasPinch = useRef(false);
|
|
1125
|
-
const appliedYRef = useRef(0);
|
|
1126
|
-
const dragMode = useRef("none");
|
|
1127
|
-
function useLatest(value) {
|
|
1128
|
-
const r = useRef(value);
|
|
1129
|
-
useEffect(() => {
|
|
1130
|
-
r.current = value;
|
|
1131
|
-
}, [value]);
|
|
1132
|
-
return r;
|
|
1133
|
-
}
|
|
1134
|
-
const isZoomedRef = useLatest(isZoomed);
|
|
1135
|
-
const recenterWithAnchor = useCallback(() => {
|
|
1136
|
-
const track = slider.current;
|
|
1137
|
-
if (!track || !locationRef.current || !previousLocationRef.current || !offsetLocationRef.current || !targetRef.current) {
|
|
1138
|
-
return;
|
|
1139
|
-
}
|
|
1140
|
-
const per = track.clientWidth || 1;
|
|
1141
|
-
perSlideRef.current = per;
|
|
1142
|
-
const len2 = slides.current.length || 1;
|
|
1143
|
-
const W = per * len2;
|
|
1144
|
-
contentSizeRef.current = W;
|
|
1145
|
-
loopLimitRef.current = Limit(-W, 0);
|
|
1146
|
-
const snaps = Array.from({ length: len2 }, (_, i) => -per * i);
|
|
1147
|
-
scrollSnapsRef.current = snaps;
|
|
1148
|
-
const fsLimit = createBaseLimit(-W, 0);
|
|
1149
|
-
scrollLimitRef.current = fsLimit;
|
|
1150
|
-
if (loopLimitRef.current) {
|
|
1151
|
-
scrollTargetRef.current = ScrollTarget(
|
|
1152
|
-
true,
|
|
1153
|
-
snaps,
|
|
1154
|
-
W,
|
|
1155
|
-
loopLimitRef.current,
|
|
1156
|
-
targetRef.current
|
|
1157
|
-
);
|
|
1158
|
-
}
|
|
1159
|
-
const idx = indexCurrentRef.current?.get() ?? selectedIndex.current ?? 0;
|
|
1160
|
-
const nx = -per * idx;
|
|
1161
|
-
setAllX(nx);
|
|
1162
|
-
setTranslateX(nx, 0);
|
|
1163
|
-
animRef.current?.resetBlend();
|
|
1164
|
-
}, []);
|
|
1165
|
-
useEffect(() => {
|
|
1166
|
-
const el = slider.current;
|
|
1167
|
-
if (!el) return;
|
|
1168
|
-
const update = () => {
|
|
1169
|
-
recenterWithAnchor();
|
|
1170
|
-
};
|
|
1171
|
-
update();
|
|
1172
|
-
const ro = new ResizeObserver(update);
|
|
1173
|
-
ro.observe(el);
|
|
1174
|
-
return () => ro.disconnect();
|
|
1175
|
-
}, [show, recenterWithAnchor]);
|
|
1176
|
-
useEffect(() => {
|
|
1177
|
-
const childrenArray = Children.toArray(children);
|
|
1178
|
-
slides.current = [];
|
|
1179
|
-
if (imageCount > 1) {
|
|
1180
|
-
for (let i = 1; i < childrenArray.length - 1; i++) {
|
|
1181
|
-
slides.current.push({ cells: [cells.current[i]] });
|
|
1182
|
-
}
|
|
1183
|
-
} else {
|
|
1184
|
-
for (let i = 0; i < childrenArray.length; i++) {
|
|
1185
|
-
slides.current.push({ cells: [cells.current[i]] });
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
}, [children]);
|
|
1189
|
-
function commitIndexChange(idx) {
|
|
1190
|
-
selectedIndex.current = idx;
|
|
1191
|
-
indexCurrentRef.current?.set(idx);
|
|
1192
|
-
sub.setLocalIndex(idx);
|
|
1193
|
-
updateCounterFromIndex(idx);
|
|
1194
|
-
resetAllZoomDom();
|
|
1195
|
-
}
|
|
1196
|
-
const GLOBAL_DRAG_ATTR = "data-rmg-global-drag";
|
|
1197
|
-
const GLOBAL_DRAG_STYLE_ID = "rmg-global-drag-style";
|
|
1198
|
-
function ensureGlobalDragStyle() {
|
|
1199
|
-
if (document.getElementById(GLOBAL_DRAG_STYLE_ID)) return;
|
|
1200
|
-
const style = document.createElement("style");
|
|
1201
|
-
style.id = GLOBAL_DRAG_STYLE_ID;
|
|
1202
|
-
style.textContent = `
|
|
1203
|
-
html[${GLOBAL_DRAG_ATTR}] * { cursor: grabbing !important; }
|
|
1204
|
-
html[${GLOBAL_DRAG_ATTR}] { cursor: grabbing !important; }
|
|
1205
|
-
`;
|
|
1206
|
-
document.head.appendChild(style);
|
|
1207
|
-
}
|
|
1208
|
-
function setGlobalGrabbing(on) {
|
|
1209
|
-
const html = document.documentElement;
|
|
1210
|
-
if (!html) return;
|
|
1211
|
-
if (on) html.setAttribute(GLOBAL_DRAG_ATTR, "");
|
|
1212
|
-
else html.removeAttribute(GLOBAL_DRAG_ATTR);
|
|
1213
|
-
}
|
|
1214
|
-
function useGlobalGrabbingGuards() {
|
|
1215
|
-
const guardsRef = useRef(null);
|
|
1216
|
-
const start = () => {
|
|
1217
|
-
if (guardsRef.current) return;
|
|
1218
|
-
ensureGlobalDragStyle();
|
|
1219
|
-
setGlobalGrabbing(true);
|
|
1220
|
-
guardsRef.current = EventStore().add(window, "mouseup", stop, true).add(window, "pointerup", stop, true).add(window, "touchend", stop, { passive: true }).add(window, "touchcancel", stop, { passive: true }).add(window, "blur", stop, true).add(document, "visibilitychange", () => {
|
|
1221
|
-
if (document.hidden) stop();
|
|
1222
|
-
});
|
|
1223
|
-
};
|
|
1224
|
-
const stop = () => {
|
|
1225
|
-
guardsRef.current?.clear();
|
|
1226
|
-
guardsRef.current = null;
|
|
1227
|
-
setGlobalGrabbing(false);
|
|
1228
|
-
};
|
|
1229
|
-
useEffect(() => stop, []);
|
|
1230
|
-
return { start, stop };
|
|
1231
|
-
}
|
|
1232
|
-
const { start: startGrabbing, stop: stopGrabbing } = useGlobalGrabbingGuards();
|
|
1233
|
-
const slideFadeBusyRef = useRef(false);
|
|
1234
|
-
const SLIDE_FADE_MS = slideFadeDuration;
|
|
1235
|
-
const SLIDE_FADE_EASING = slideFadeEasing;
|
|
1236
|
-
function jumpToIndexInstant(idx) {
|
|
1237
|
-
const per = perSlide();
|
|
1238
|
-
const nx = -per * idx;
|
|
1239
|
-
animRef.current?.stop();
|
|
1240
|
-
bodyRef.current?.useDuration(0).useFriction(1);
|
|
1241
|
-
setAllX(nx);
|
|
1242
|
-
setTranslateX(nx, 0);
|
|
1243
|
-
commitIndexChange(idx);
|
|
1244
|
-
}
|
|
1245
|
-
function fadeToIndex(idx) {
|
|
1246
|
-
if (!slideFade) return;
|
|
1247
|
-
const track = slider.current;
|
|
1248
|
-
if (!track) return;
|
|
1249
|
-
if (!showFullscreenSlider) return;
|
|
1250
|
-
slideFadeBusyRef.current = true;
|
|
1251
|
-
const prevTransition = track.style.transition;
|
|
1252
|
-
const prevOpacity = track.style.opacity;
|
|
1253
|
-
track.style.transition = `opacity ${SLIDE_FADE_MS}ms ${SLIDE_FADE_EASING}`;
|
|
1254
|
-
const computed = window.getComputedStyle(track).opacity;
|
|
1255
|
-
track.style.opacity = computed;
|
|
1256
|
-
track.offsetWidth;
|
|
1257
|
-
track.style.opacity = "0";
|
|
1258
|
-
const t1 = window.setTimeout(() => {
|
|
1259
|
-
jumpToIndexInstant(idx);
|
|
1260
|
-
track.offsetWidth;
|
|
1261
|
-
track.style.opacity = "1";
|
|
1262
|
-
const t2 = window.setTimeout(() => {
|
|
1263
|
-
track.style.transition = prevTransition;
|
|
1264
|
-
if (!prevTransition) track.style.opacity = prevOpacity;
|
|
1265
|
-
slideFadeBusyRef.current = false;
|
|
1266
|
-
window.clearTimeout(t2);
|
|
1267
|
-
}, SLIDE_FADE_MS + 40);
|
|
1268
|
-
window.clearTimeout(t1);
|
|
1269
|
-
}, SLIDE_FADE_MS + 20);
|
|
1270
|
-
}
|
|
1271
|
-
function perSlide() {
|
|
1272
|
-
return perSlideRef.current || slider.current?.clientWidth || 1;
|
|
1273
|
-
}
|
|
1274
|
-
function slideCount() {
|
|
1275
|
-
return slides.current.length || 1;
|
|
1276
|
-
}
|
|
1277
|
-
function commitXY(canonicalX, ny) {
|
|
1278
|
-
const nx = Math.round(canonicalX) * sign;
|
|
1279
|
-
translateRef.current?.to(nx, ny);
|
|
1280
|
-
if (overlayDivRef.current) {
|
|
1281
|
-
const progress = clamp01(Math.abs(ny) / FADE_DISTANCE);
|
|
1282
|
-
const o = 1 - easeOutCubic(progress);
|
|
1283
|
-
overlayDivRef.current.style.opacity = String(o);
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
useEffect(() => {
|
|
1287
|
-
if (closingModal) {
|
|
1288
|
-
animRef.current?.stop();
|
|
1289
|
-
pointerDownRef.current = false;
|
|
1290
|
-
}
|
|
1291
|
-
}, [closingModal]);
|
|
1292
|
-
useEffect(() => {
|
|
1293
|
-
if (!slider.current || hasPositioned.current) return;
|
|
1294
|
-
if (counterRef.current) {
|
|
1295
|
-
counterRef.current.textContent = `${!isWrapping.current ? slideIndex + 1 : slideIndex} / ${imageCount}`;
|
|
1296
|
-
}
|
|
1297
|
-
if (slideIndex === 1 && isWrapping.current === true || slideIndex === 0 && !isWrapping.current) {
|
|
1298
|
-
selectedIndex.current = 0;
|
|
1299
|
-
sub.setLocalIndex(0);
|
|
1300
|
-
setTimeout(() => {
|
|
1301
|
-
if (!slider.current) return;
|
|
1302
|
-
const startX = 0;
|
|
1303
|
-
x.current = startX;
|
|
1304
|
-
y.current = 0;
|
|
1305
|
-
if (locationRef.current && previousLocationRef.current && offsetLocationRef.current && targetRef.current) {
|
|
1306
|
-
locationRef.current.set(startX);
|
|
1307
|
-
previousLocationRef.current.set(startX);
|
|
1308
|
-
offsetLocationRef.current.set(startX);
|
|
1309
|
-
targetRef.current.set(startX);
|
|
1310
|
-
setTranslateX(startX, 0);
|
|
1311
|
-
} else {
|
|
1312
|
-
const sx = Math.round(startX) * sign;
|
|
1313
|
-
slider.current.style.transform = `translate3d(${sx}px, 0, 0)`;
|
|
1314
|
-
}
|
|
1315
|
-
}, 100);
|
|
1316
|
-
hasPositioned.current = true;
|
|
1317
|
-
return;
|
|
1318
|
-
}
|
|
1319
|
-
let actualIndex = slideIndex - 1;
|
|
1320
|
-
actualIndex = (actualIndex % imageCount + imageCount) % imageCount;
|
|
1321
|
-
if (actualIndex === 0) actualIndex = imageCount;
|
|
1322
|
-
const finalIndex = isWrapping.current === true ? actualIndex : slideIndex;
|
|
1323
|
-
selectedIndex.current = finalIndex;
|
|
1324
|
-
sub.setLocalIndex(finalIndex);
|
|
1325
|
-
setTimeout(() => {
|
|
1326
|
-
if (!slider.current) return;
|
|
1327
|
-
const per = perSlideRef.current || slider.current.clientWidth;
|
|
1328
|
-
const startX = -per * finalIndex;
|
|
1329
|
-
x.current = startX;
|
|
1330
|
-
y.current = 0;
|
|
1331
|
-
if (locationRef.current && previousLocationRef.current && offsetLocationRef.current && targetRef.current) {
|
|
1332
|
-
locationRef.current.set(startX);
|
|
1333
|
-
previousLocationRef.current.set(startX);
|
|
1334
|
-
offsetLocationRef.current.set(startX);
|
|
1335
|
-
targetRef.current.set(startX);
|
|
1336
|
-
setTranslateX(startX, 0);
|
|
1337
|
-
} else {
|
|
1338
|
-
const sx = Math.round(startX) * sign;
|
|
1339
|
-
slider.current.style.transform = `translate3d(${sx}px, 0, 0)`;
|
|
1340
|
-
}
|
|
1341
|
-
}, 100);
|
|
1342
|
-
hasPositioned.current = true;
|
|
1343
|
-
}, [show, slides.current]);
|
|
1344
|
-
const ySnapTweenId = { current: 0 };
|
|
1345
|
-
function snapBackY(ms = 300) {
|
|
1346
|
-
const startId = ++ySnapTweenId.current;
|
|
1347
|
-
const fromY = yTemp.current || 0;
|
|
1348
|
-
const start = performance.now();
|
|
1349
|
-
const step = (now) => {
|
|
1350
|
-
if (startId !== ySnapTweenId.current || isPointerDown.current) return;
|
|
1351
|
-
const t = Math.min(1, (now - start) / ms);
|
|
1352
|
-
const k = easeOutCubic(t);
|
|
1353
|
-
yTemp.current = fromY + (0 - fromY) * k;
|
|
1354
|
-
const xNow = offsetLocationRef.current.get();
|
|
1355
|
-
y.current = yTemp.current;
|
|
1356
|
-
commitXY(xNow, y.current);
|
|
1357
|
-
if (t < 1) requestAnimationFrame(step);
|
|
1358
|
-
};
|
|
1359
|
-
requestAnimationFrame(step);
|
|
1360
|
-
}
|
|
1361
|
-
function disableOverlayTransition() {
|
|
1362
|
-
if (overlayDivRef.current) overlayDivRef.current.style.transition = "opacity 0s";
|
|
1363
|
-
}
|
|
1364
|
-
function restoreOverlayTransition() {
|
|
1365
|
-
if (overlayDivRef.current) overlayDivRef.current.style.transition = "";
|
|
1366
|
-
}
|
|
1367
|
-
function scrollToIndex(requested, opts = {}) {
|
|
1368
|
-
const { jump = false, direction: direction2 } = opts;
|
|
1369
|
-
const indexCurrent = indexCurrentRef.current;
|
|
1370
|
-
const fsScrollTo = scrollToRef.current;
|
|
1371
|
-
const body = bodyRef.current;
|
|
1372
|
-
if (!fsScrollTo || !body || !indexCurrent) return;
|
|
1373
|
-
const len2 = slideCount();
|
|
1374
|
-
const from = ((selectedIndex.current || 0) % len2 + len2) % len2;
|
|
1375
|
-
const to = ((requested || 0) % len2 + len2) % len2;
|
|
1376
|
-
const crossesSeam = len2 > 1 && (from === 0 && to === len2 - 1 || from === len2 - 1 && to === 0);
|
|
1377
|
-
if (crossesSeam && isZoomedRef.current && imageCount > 1 && selectedIndex.current === 0) {
|
|
1378
|
-
const refs = imageRefs;
|
|
1379
|
-
const firstRealImg = refs[1]?.current?.querySelector("img");
|
|
1380
|
-
const firstCloneImg = refs[imageCount + 1]?.current?.querySelector("img");
|
|
1381
|
-
if (firstRealImg && firstCloneImg) {
|
|
1382
|
-
const extractScale = (el) => {
|
|
1383
|
-
if (!el) return 1;
|
|
1384
|
-
const tr = el.style.transform || "";
|
|
1385
|
-
const m = tr.match(/scale\(([^)]+)\)/);
|
|
1386
|
-
if (!m) return 1;
|
|
1387
|
-
const v = parseFloat(m[1]);
|
|
1388
|
-
return Number.isFinite(v) ? v : 1;
|
|
1389
|
-
};
|
|
1390
|
-
const readTransform = (el) => {
|
|
1391
|
-
let transform = el.style.transform;
|
|
1392
|
-
if (!transform) {
|
|
1393
|
-
const cs = window.getComputedStyle(el);
|
|
1394
|
-
transform = cs.transform !== "none" ? cs.transform : "";
|
|
1395
|
-
}
|
|
1396
|
-
return transform || "";
|
|
1397
|
-
};
|
|
1398
|
-
const realScale = extractScale(firstRealImg);
|
|
1399
|
-
const cloneScale = extractScale(firstCloneImg);
|
|
1400
|
-
if (realScale > 1.01 && cloneScale <= 1.01) {
|
|
1401
|
-
const transform = readTransform(firstRealImg);
|
|
1402
|
-
firstCloneImg.style.transition = "none";
|
|
1403
|
-
firstCloneImg.style.transform = transform;
|
|
1404
|
-
firstCloneImg.offsetWidth;
|
|
1405
|
-
}
|
|
1406
|
-
if (cloneScale > 1.01 && realScale <= 1.01) {
|
|
1407
|
-
const transform = readTransform(firstCloneImg);
|
|
1408
|
-
firstRealImg.style.transition = "none";
|
|
1409
|
-
firstRealImg.style.transform = transform;
|
|
1410
|
-
firstRealImg.offsetWidth;
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
|
-
const targetIndex = indexCurrent.clone().set(requested).get();
|
|
1415
|
-
if (jump) {
|
|
1416
|
-
body.useDuration(0);
|
|
1417
|
-
} else {
|
|
1418
|
-
body.useBaseDuration().useBaseFriction();
|
|
1419
|
-
}
|
|
1420
|
-
const dir = typeof direction2 === "number" ? direction2 : 0;
|
|
1421
|
-
fsScrollTo.index(targetIndex, dir);
|
|
1422
|
-
}
|
|
1423
|
-
function previous() {
|
|
1424
|
-
isVerticalScroll.current = false;
|
|
1425
|
-
isScrolling.current = false;
|
|
1426
|
-
isPinching.current = false;
|
|
1427
|
-
isTouchPinching.current = false;
|
|
1428
|
-
if (isZoomedRef.current && imageCount > 1 && selectedIndex.current === 0) {
|
|
1429
|
-
const refs = imageRefs;
|
|
1430
|
-
const firstRealImg = refs[1]?.current?.querySelector("img");
|
|
1431
|
-
const firstCloneImg = refs[imageCount + 1]?.current?.querySelector("img");
|
|
1432
|
-
if (firstRealImg && firstCloneImg) {
|
|
1433
|
-
const extractScale = (el) => {
|
|
1434
|
-
if (!el) return 1;
|
|
1435
|
-
const tr = el.style.transform || "";
|
|
1436
|
-
const m = tr.match(/scale\(([^)]+)\)/);
|
|
1437
|
-
if (!m) return 1;
|
|
1438
|
-
const v = parseFloat(m[1]);
|
|
1439
|
-
return Number.isFinite(v) ? v : 1;
|
|
1440
|
-
};
|
|
1441
|
-
const realScale = extractScale(firstRealImg);
|
|
1442
|
-
const cloneScale = extractScale(firstCloneImg);
|
|
1443
|
-
if (realScale > 1.01 && cloneScale <= 1.01) {
|
|
1444
|
-
let transform = firstRealImg.style.transform;
|
|
1445
|
-
if (!transform) {
|
|
1446
|
-
const cs = window.getComputedStyle(firstRealImg);
|
|
1447
|
-
transform = cs.transform !== "none" ? cs.transform : "";
|
|
1448
|
-
}
|
|
1449
|
-
firstCloneImg.style.transition = "none";
|
|
1450
|
-
firstCloneImg.style.transform = transform;
|
|
1451
|
-
firstCloneImg.offsetWidth;
|
|
1452
|
-
}
|
|
1453
|
-
if (cloneScale > 1.01 && realScale <= 1.01) {
|
|
1454
|
-
let transform = firstCloneImg.style.transform;
|
|
1455
|
-
if (!transform) {
|
|
1456
|
-
const cs = window.getComputedStyle(firstCloneImg);
|
|
1457
|
-
transform = cs.transform !== "none" ? cs.transform : "";
|
|
1458
|
-
}
|
|
1459
|
-
firstRealImg.style.transition = "none";
|
|
1460
|
-
firstRealImg.style.transform = transform;
|
|
1461
|
-
firstRealImg.offsetWidth;
|
|
1462
|
-
}
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
const len2 = slideCount();
|
|
1466
|
-
const cur = selectedIndex.current || 0;
|
|
1467
|
-
const nextIdx = ((cur - 1) % len2 + len2) % len2;
|
|
1468
|
-
if (slideFade) {
|
|
1469
|
-
fadeToIndex(nextIdx);
|
|
1470
|
-
return;
|
|
1471
|
-
}
|
|
1472
|
-
const fsScrollTo = scrollToRef.current;
|
|
1473
|
-
const body = bodyRef.current;
|
|
1474
|
-
if (!fsScrollTo || !body) return;
|
|
1475
|
-
const step = perSlide();
|
|
1476
|
-
body.useBaseDuration().useBaseFriction();
|
|
1477
|
-
fsScrollTo.distance(step, true);
|
|
1478
|
-
}
|
|
1479
|
-
function next() {
|
|
1480
|
-
isVerticalScroll.current = false;
|
|
1481
|
-
isScrolling.current = false;
|
|
1482
|
-
isPinching.current = false;
|
|
1483
|
-
isTouchPinching.current = false;
|
|
1484
|
-
if (isZoomedRef.current && imageCount > 1 && selectedIndex.current === 0) {
|
|
1485
|
-
const refs = imageRefs;
|
|
1486
|
-
const firstRealImg = refs[1]?.current?.querySelector("img");
|
|
1487
|
-
const firstCloneImg = refs[imageCount + 1]?.current?.querySelector("img");
|
|
1488
|
-
if (firstRealImg && firstCloneImg) {
|
|
1489
|
-
const extractScale = (el) => {
|
|
1490
|
-
if (!el) return 1;
|
|
1491
|
-
const tr = el.style.transform || "";
|
|
1492
|
-
const m = tr.match(/scale\(([^)]+)\)/);
|
|
1493
|
-
if (!m) return 1;
|
|
1494
|
-
const v = parseFloat(m[1]);
|
|
1495
|
-
return Number.isFinite(v) ? v : 1;
|
|
1496
|
-
};
|
|
1497
|
-
const realScale = extractScale(firstRealImg);
|
|
1498
|
-
const cloneScale = extractScale(firstCloneImg);
|
|
1499
|
-
if (realScale > 1.01 && cloneScale <= 1.01) {
|
|
1500
|
-
let transform = firstRealImg.style.transform;
|
|
1501
|
-
if (!transform) {
|
|
1502
|
-
const cs = window.getComputedStyle(firstRealImg);
|
|
1503
|
-
transform = cs.transform !== "none" ? cs.transform : "";
|
|
1504
|
-
}
|
|
1505
|
-
firstCloneImg.style.transition = "none";
|
|
1506
|
-
firstCloneImg.style.transform = transform;
|
|
1507
|
-
firstCloneImg.offsetWidth;
|
|
1508
|
-
}
|
|
1509
|
-
if (cloneScale > 1.01 && realScale <= 1.01) {
|
|
1510
|
-
let transform = firstCloneImg.style.transform;
|
|
1511
|
-
if (!transform) {
|
|
1512
|
-
const cs = window.getComputedStyle(firstCloneImg);
|
|
1513
|
-
transform = cs.transform !== "none" ? cs.transform : "";
|
|
1514
|
-
}
|
|
1515
|
-
firstRealImg.style.transition = "none";
|
|
1516
|
-
firstRealImg.style.transform = transform;
|
|
1517
|
-
firstRealImg.offsetWidth;
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
const len2 = slideCount();
|
|
1522
|
-
const cur = selectedIndex.current || 0;
|
|
1523
|
-
const nextIdx = ((cur + 1) % len2 + len2) % len2;
|
|
1524
|
-
if (slideFade) {
|
|
1525
|
-
fadeToIndex(nextIdx);
|
|
1526
|
-
return;
|
|
1527
|
-
}
|
|
1528
|
-
const fsScrollTo = scrollToRef.current;
|
|
1529
|
-
const body = bodyRef.current;
|
|
1530
|
-
if (!fsScrollTo || !body) return;
|
|
1531
|
-
const step = perSlide();
|
|
1532
|
-
body.useBaseDuration().useBaseFriction();
|
|
1533
|
-
fsScrollTo.distance(-step, true);
|
|
1534
|
-
}
|
|
1535
|
-
function updateCounterFromIndex(canonicalIndex) {
|
|
1536
|
-
const len2 = slides.current.length || 1;
|
|
1537
|
-
let actualIndex = canonicalIndex + 1;
|
|
1538
|
-
actualIndex = (actualIndex % len2 + len2) % len2;
|
|
1539
|
-
if (actualIndex === 0) actualIndex = imageCount;
|
|
1540
|
-
if (counterRef.current) {
|
|
1541
|
-
counterRef.current.textContent = `${actualIndex} / ${imageCount}`;
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
function toggleActiveVideoPlay() {
|
|
1545
|
-
const idx = selectedIndex.current ?? 0;
|
|
1546
|
-
const actualIndex = idx + 1;
|
|
1547
|
-
const api = plyrRefs.current[actualIndex] || plyrRef.current[0];
|
|
1548
|
-
const p = api?.plyr;
|
|
1549
|
-
if (!p) return;
|
|
1550
|
-
if (p.playing) p.pause();
|
|
1551
|
-
else p.play();
|
|
1552
|
-
}
|
|
1553
|
-
function isPlyrControlsEl(el) {
|
|
1554
|
-
return !!el?.closest?.(
|
|
1555
|
-
[
|
|
1556
|
-
".plyr__controls",
|
|
1557
|
-
".plyr__control--overlaid",
|
|
1558
|
-
".plyr__menu__container",
|
|
1559
|
-
".plyr__tooltip",
|
|
1560
|
-
".plyr__captions"
|
|
1561
|
-
].join(",")
|
|
1562
|
-
);
|
|
1563
|
-
}
|
|
1564
|
-
function getClientXY(evt) {
|
|
1565
|
-
const t = evt.changedTouches?.[0] ?? evt.touches?.[0];
|
|
1566
|
-
if (t) return { x: t.clientX, y: t.clientY };
|
|
1567
|
-
return { x: evt.clientX, y: evt.clientY };
|
|
1568
|
-
}
|
|
1569
|
-
function clickedVideoSurface(evt) {
|
|
1570
|
-
const { x: x2, y: y2 } = getClientXY(evt);
|
|
1571
|
-
const under = document.elementFromPoint(x2, y2);
|
|
1572
|
-
if (!under) return false;
|
|
1573
|
-
const slide = under.closest('[data-rmg-fs-slide="true"]');
|
|
1574
|
-
if (!slide) return false;
|
|
1575
|
-
const plyrRoot = slide.querySelector(".plyr");
|
|
1576
|
-
if (!plyrRoot) return false;
|
|
1577
|
-
const wrap = plyrRoot.querySelector(".plyr__video-wrapper");
|
|
1578
|
-
if (!wrap) return false;
|
|
1579
|
-
const r = wrap.getBoundingClientRect();
|
|
1580
|
-
const inside = x2 >= r.left && x2 <= r.right && y2 >= r.top && y2 <= r.bottom;
|
|
1581
|
-
if (under.closest(".plyr__controls")) return false;
|
|
1582
|
-
return inside;
|
|
1583
|
-
}
|
|
1584
|
-
function isYouTubeVideoEvent(evt) {
|
|
1585
|
-
const target = evt.target;
|
|
1586
|
-
if (!target) return false;
|
|
1587
|
-
const slide = target.closest('[data-rmg-fs-slide="true"]');
|
|
1588
|
-
if (!slide) return false;
|
|
1589
|
-
const plyrRoot = slide.querySelector(".rmg__player");
|
|
1590
|
-
if (!plyrRoot) return false;
|
|
1591
|
-
return plyrRoot.getAttribute("data-rmg-plyr-provider") === "youtube";
|
|
1592
|
-
}
|
|
1593
|
-
useEffect(() => {
|
|
1594
|
-
const root = viewportRef.current;
|
|
1595
|
-
const track = slider.current;
|
|
1596
|
-
if (!root || !track) return;
|
|
1597
|
-
const axis = FullscreenAxis();
|
|
1598
|
-
axisRef.current = axis;
|
|
1599
|
-
const per = perSlideRef.current || track.clientWidth || 1;
|
|
1600
|
-
const len2 = slides.current.length || 1;
|
|
1601
|
-
const W = per * len2;
|
|
1602
|
-
const counterMax = len2 - 1;
|
|
1603
|
-
const startIndex = selectedIndex.current || 0;
|
|
1604
|
-
const location = Vector1D(0);
|
|
1605
|
-
const previousLocation = Vector1D(0);
|
|
1606
|
-
const offsetLocation = Vector1D(0);
|
|
1607
|
-
const target = Vector1D(0);
|
|
1608
|
-
locationRef.current = location;
|
|
1609
|
-
previousLocationRef.current = previousLocation;
|
|
1610
|
-
offsetLocationRef.current = offsetLocation;
|
|
1611
|
-
targetRef.current = target;
|
|
1612
|
-
const scrollSnaps = Array.from({ length: len2 }, (_, i) => -per * i);
|
|
1613
|
-
scrollSnapsRef.current = scrollSnaps;
|
|
1614
|
-
const initialSnap = scrollSnaps[startIndex] ?? 0;
|
|
1615
|
-
location.set(initialSnap);
|
|
1616
|
-
previousLocation.set(initialSnap);
|
|
1617
|
-
offsetLocation.set(initialSnap);
|
|
1618
|
-
target.set(initialSnap);
|
|
1619
|
-
x.current = initialSnap;
|
|
1620
|
-
translateRef.current = TranslateFullscreen(track);
|
|
1621
|
-
setTranslateX(initialSnap, 0);
|
|
1622
|
-
const indexCurrent = Counter(counterMax, startIndex, true);
|
|
1623
|
-
const indexPrevious = Counter(counterMax, startIndex, true);
|
|
1624
|
-
indexCurrentRef.current = indexCurrent;
|
|
1625
|
-
indexPreviousRef.current = indexPrevious;
|
|
1626
|
-
selectedIndex.current = startIndex;
|
|
1627
|
-
sub.setLocalIndex(startIndex);
|
|
1628
|
-
updateCounterFromIndex(startIndex);
|
|
1629
|
-
contentSizeRef.current = W;
|
|
1630
|
-
loopLimitRef.current = Limit(-W, 0);
|
|
1631
|
-
scrollContentSizeRef.current = W;
|
|
1632
|
-
const fsLimit = createBaseLimit(-W, 0);
|
|
1633
|
-
scrollLimitRef.current = fsLimit;
|
|
1634
|
-
if (loopLimitRef.current) {
|
|
1635
|
-
scrollTargetRef.current = ScrollTarget(
|
|
1636
|
-
true,
|
|
1637
|
-
scrollSnaps,
|
|
1638
|
-
W,
|
|
1639
|
-
loopLimitRef.current,
|
|
1640
|
-
target
|
|
1641
|
-
);
|
|
1642
|
-
}
|
|
1643
|
-
function scrollTo(target2) {
|
|
1644
|
-
const indexCurrent2 = indexCurrentRef.current;
|
|
1645
|
-
const indexPrevious2 = indexPreviousRef.current;
|
|
1646
|
-
if (!indexCurrent2 || !indexPrevious2) return;
|
|
1647
|
-
const distanceDiff = target2.distance;
|
|
1648
|
-
const indexDiff = target2.index !== indexCurrent2.get();
|
|
1649
|
-
targetRef.current.add(distanceDiff);
|
|
1650
|
-
if (distanceDiff) {
|
|
1651
|
-
if (bodyRef.current.duration()) {
|
|
1652
|
-
animRef.current.start();
|
|
1653
|
-
} else {
|
|
1654
|
-
bodyRef.current.seek();
|
|
1655
|
-
positionSlider();
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
if (indexDiff) {
|
|
1659
|
-
indexPrevious2.set(indexCurrent2.get());
|
|
1660
|
-
indexCurrent2.set(target2.index);
|
|
1661
|
-
const idx = indexCurrent2.get();
|
|
1662
|
-
commitIndexChange(idx);
|
|
1663
|
-
}
|
|
1664
|
-
}
|
|
1665
|
-
const fsScrollTo = {
|
|
1666
|
-
distance(n, snap) {
|
|
1667
|
-
const st = scrollTargetRef.current;
|
|
1668
|
-
if (!st) return;
|
|
1669
|
-
const target2 = st.byDistance(n, snap);
|
|
1670
|
-
scrollTo(target2);
|
|
1671
|
-
},
|
|
1672
|
-
index(n, direction2) {
|
|
1673
|
-
const st = scrollTargetRef.current;
|
|
1674
|
-
const indexCurrent2 = indexCurrentRef.current;
|
|
1675
|
-
if (!st || !indexCurrent2) return;
|
|
1676
|
-
const targetIndex = indexCurrent2.clone().set(n).get();
|
|
1677
|
-
const target2 = st.byIndex(targetIndex, direction2);
|
|
1678
|
-
scrollTo(target2);
|
|
1679
|
-
}
|
|
1680
|
-
};
|
|
1681
|
-
scrollToRef.current = fsScrollTo;
|
|
1682
|
-
const looper = ScrollLooper(
|
|
1683
|
-
contentSizeRef.current,
|
|
1684
|
-
loopLimitRef.current,
|
|
1685
|
-
location,
|
|
1686
|
-
[location, previousLocation, offsetLocation, target]
|
|
1687
|
-
);
|
|
1688
|
-
const body = ScrollBody(location, offsetLocation, previousLocation, target, sliderDuration, sliderFriction);
|
|
1689
|
-
bodyRef.current = body;
|
|
1690
|
-
const anim = Animations(
|
|
1691
|
-
document,
|
|
1692
|
-
window,
|
|
1693
|
-
() => {
|
|
1694
|
-
bodyRef.current?.seek();
|
|
1695
|
-
const body2 = bodyRef.current;
|
|
1696
|
-
const dir = body2.direction() || Math.sign(target.get() - location.get()) || 0;
|
|
1697
|
-
if (!suppressLoopRef.current && imageCount > 1 && W > 0) {
|
|
1698
|
-
looper.loop(dir);
|
|
1699
|
-
}
|
|
1700
|
-
x.current = location.get();
|
|
1701
|
-
},
|
|
1702
|
-
(alpha) => {
|
|
1703
|
-
const cur = location.get();
|
|
1704
|
-
const prev = previousLocation.get();
|
|
1705
|
-
const loc = cur * alpha + prev * (1 - alpha);
|
|
1706
|
-
offsetLocation.set(loc);
|
|
1707
|
-
x.current = loc;
|
|
1708
|
-
y.current = isVerticalScroll.current ? yTemp.current : y.current;
|
|
1709
|
-
positionSlider();
|
|
1710
|
-
const settled = bodyRef.current?.settled();
|
|
1711
|
-
if (settled && !pointerDownRef.current) {
|
|
1712
|
-
animRef.current?.stop();
|
|
1713
|
-
isAnimatingRef.current = false;
|
|
1714
|
-
}
|
|
1715
|
-
if (!isZoomedRef.current && !isAnimatingRef.current) {
|
|
1716
|
-
updateActiveIndexFromX(loc);
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
);
|
|
1720
|
-
animRef.current = anim;
|
|
1721
|
-
anim.init();
|
|
1722
|
-
const dragStore = EventStore();
|
|
1723
|
-
const moveStore = EventStore();
|
|
1724
|
-
const trackerX = DragTracker(axis, window);
|
|
1725
|
-
const axisY = {
|
|
1726
|
-
scroll: "y",
|
|
1727
|
-
cross: "x",
|
|
1728
|
-
direction(n) {
|
|
1729
|
-
return n;
|
|
1730
|
-
},
|
|
1731
|
-
measureSize: (r) => r.height
|
|
1732
|
-
};
|
|
1733
|
-
const trackerY = DragTracker(axisY, window);
|
|
1734
|
-
let isMouse = false;
|
|
1735
|
-
let preventScroll = false;
|
|
1736
|
-
let startPX = 0;
|
|
1737
|
-
let startPY = 0;
|
|
1738
|
-
const dragThresholdLocal = dragThreshold;
|
|
1739
|
-
function addDragEvents() {
|
|
1740
|
-
const node = isMouse ? document : root;
|
|
1741
|
-
moveStore.add(node, "touchmove", onMove, { passive: false }).add(node, "touchend", onUp).add(node, "mousemove", onMove, { passive: false }).add(node, "mouseup", onUp);
|
|
1742
|
-
}
|
|
1743
|
-
function onDown(evt) {
|
|
1744
|
-
const targetEl = evt.target;
|
|
1745
|
-
if (isPlyrControlsEl(targetEl)) return;
|
|
1746
|
-
if (isZoomedRef.current || closingModal) return;
|
|
1747
|
-
const isMouseEvt = isMouseEvent(evt, window);
|
|
1748
|
-
isMouse = isMouseEvt;
|
|
1749
|
-
if (isMouseEvt && evt.button !== 0) return;
|
|
1750
|
-
startGrabbing();
|
|
1751
|
-
wasPinch.current = false;
|
|
1752
|
-
isTouchPinching.current = false;
|
|
1753
|
-
activeTouchCount.current = !isMouseEvt ? evt.touches?.length ?? 1 : 0;
|
|
1754
|
-
pointerDownRef.current = true;
|
|
1755
|
-
isPointerDown.current = true;
|
|
1756
|
-
isScrolling.current = false;
|
|
1757
|
-
isPinching.current = false;
|
|
1758
|
-
isTouchPinching.current = false;
|
|
1759
|
-
isClick.current = true;
|
|
1760
|
-
dragMode.current = "none";
|
|
1761
|
-
yTemp.current = 0;
|
|
1762
|
-
dragStartY.current = 0;
|
|
1763
|
-
dragYForClose.current = 0;
|
|
1764
|
-
trackerX.pointerDown(evt);
|
|
1765
|
-
trackerY.pointerDown(evt);
|
|
1766
|
-
startPX = trackerX.readPoint(evt, "x");
|
|
1767
|
-
startPY = trackerY.readPoint(evt, "y");
|
|
1768
|
-
bodyRef.current.useFriction(0).useDuration(0);
|
|
1769
|
-
targetRef.current.set(locationRef.current.get());
|
|
1770
|
-
addDragEvents();
|
|
1771
|
-
animRef.current?.start();
|
|
1772
|
-
}
|
|
1773
|
-
function onMove(evt) {
|
|
1774
|
-
if (isZoomedRef.current) return;
|
|
1775
|
-
const isTouchEvt = !isMouseEvent(evt, window);
|
|
1776
|
-
if (isTouchEvt) {
|
|
1777
|
-
const t = evt;
|
|
1778
|
-
activeTouchCount.current = t.touches?.length ?? 1;
|
|
1779
|
-
if (activeTouchCount.current >= 2) {
|
|
1780
|
-
wasPinch.current = true;
|
|
1781
|
-
isTouchPinching.current = true;
|
|
1782
|
-
isClick.current = false;
|
|
1783
|
-
dragMode.current = "none";
|
|
1784
|
-
animRef.current?.stop();
|
|
1785
|
-
if (t.cancelable) {
|
|
1786
|
-
t.preventDefault();
|
|
1787
|
-
}
|
|
1788
|
-
return;
|
|
1789
|
-
}
|
|
1790
|
-
}
|
|
1791
|
-
const lastScroll = trackerX.readPoint(evt, "x");
|
|
1792
|
-
const lastCross = trackerY.readPoint(evt, "y");
|
|
1793
|
-
const dxAbs = Math.abs(lastScroll - startPX);
|
|
1794
|
-
const dyAbs = Math.abs(lastCross - startPY);
|
|
1795
|
-
if (dragMode.current === "none") {
|
|
1796
|
-
if (dxAbs > dragThresholdLocal || dyAbs > dragThresholdLocal) {
|
|
1797
|
-
dragMode.current = dxAbs >= dyAbs ? "x" : "y";
|
|
1798
|
-
isClick.current = false;
|
|
1799
|
-
if (dragMode.current === "y") {
|
|
1800
|
-
isVerticalScroll.current = true;
|
|
1801
|
-
dragStartY.current = lastCross;
|
|
1802
|
-
yTemp.current = 0;
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
}
|
|
1806
|
-
disableOverlayTransition();
|
|
1807
|
-
const diffX = trackerX.pointerMove(evt).dx * sign;
|
|
1808
|
-
trackerY.pointerMove(evt);
|
|
1809
|
-
previousDragX.current = dragX.current;
|
|
1810
|
-
dragX.current = lastScroll * sign;
|
|
1811
|
-
velocityX.current = diffX;
|
|
1812
|
-
dragMoveTime.current = /* @__PURE__ */ new Date();
|
|
1813
|
-
if (!preventScroll && !isMouse && dragMode.current === "x") {
|
|
1814
|
-
if (!("cancelable" in evt) || !evt.cancelable) return;
|
|
1815
|
-
preventScroll = dxAbs > dyAbs;
|
|
1816
|
-
if (!preventScroll) return;
|
|
1817
|
-
}
|
|
1818
|
-
if (dragMode.current === "y") {
|
|
1819
|
-
const dy = lastCross - dragStartY.current;
|
|
1820
|
-
dragYForClose.current = dy;
|
|
1821
|
-
yTemp.current = dy * 0.5;
|
|
1822
|
-
y.current = yTemp.current;
|
|
1823
|
-
const xNow = offsetLocationRef.current.get();
|
|
1824
|
-
commitXY(xNow, y.current);
|
|
1825
|
-
if (overlayDivRef.current) {
|
|
1826
|
-
const progress = clamp01(Math.abs(dy) / FADE_DISTANCE);
|
|
1827
|
-
overlayDivRef.current.style.opacity = String(1 - progress);
|
|
1828
|
-
}
|
|
1829
|
-
evt.preventDefault?.();
|
|
1830
|
-
return;
|
|
1831
|
-
}
|
|
1832
|
-
bodyRef.current.useFriction(0.3).useDuration(0.75);
|
|
1833
|
-
const delta = axisRef.current.direction(diffX);
|
|
1834
|
-
targetRef.current.add(delta);
|
|
1835
|
-
animRef.current?.start();
|
|
1836
|
-
if (evt.cancelable) evt.preventDefault();
|
|
1837
|
-
}
|
|
1838
|
-
function onUp(evt) {
|
|
1839
|
-
const isTouchEvt = !isMouseEvent(evt, window);
|
|
1840
|
-
if (isTouchEvt && (isTouchPinching.current || wasPinch.current)) {
|
|
1841
|
-
const t = evt;
|
|
1842
|
-
activeTouchCount.current = t.touches?.length ?? 0;
|
|
1843
|
-
if (activeTouchCount.current > 0) {
|
|
1844
|
-
return;
|
|
1845
|
-
}
|
|
1846
|
-
stopGrabbing();
|
|
1847
|
-
isTouchPinching.current = false;
|
|
1848
|
-
wasPinch.current = false;
|
|
1849
|
-
pointerDownRef.current = false;
|
|
1850
|
-
isPointerDown.current = false;
|
|
1851
|
-
isClick.current = false;
|
|
1852
|
-
dragMode.current = "none";
|
|
1853
|
-
isVerticalScroll.current = false;
|
|
1854
|
-
yTemp.current = 0;
|
|
1855
|
-
moveStore.clear();
|
|
1856
|
-
preventScroll = false;
|
|
1857
|
-
return;
|
|
1858
|
-
}
|
|
1859
|
-
isPointerDown.current = false;
|
|
1860
|
-
pointerDownRef.current = false;
|
|
1861
|
-
moveStore.clear();
|
|
1862
|
-
preventScroll = false;
|
|
1863
|
-
if (isClick.current) {
|
|
1864
|
-
const target2 = evt.target;
|
|
1865
|
-
if (clickedVideoSurface(evt) && !isYouTubeVideoEvent(evt)) {
|
|
1866
|
-
evt.preventDefault?.();
|
|
1867
|
-
evt.stopPropagation?.();
|
|
1868
|
-
toggleActiveVideoPlay();
|
|
1869
|
-
dragMode.current = "none";
|
|
1870
|
-
suppressLoopRef.current = true;
|
|
1871
|
-
goToCanonical(selectedIndex.current);
|
|
1872
|
-
return;
|
|
1873
|
-
}
|
|
1874
|
-
if (target2.closest("[class*='plyr__']")) return;
|
|
1875
|
-
const t = evt;
|
|
1876
|
-
const clickedImg = target2.closest("img");
|
|
1877
|
-
if (!clickedImg) {
|
|
1878
|
-
restoreOverlayTransition();
|
|
1879
|
-
clickedImgMargin.current = true;
|
|
1880
|
-
animRef.current?.stop();
|
|
1881
|
-
requestFsCloseRef.current?.();
|
|
1882
|
-
if (t.cancelable) {
|
|
1883
|
-
t.preventDefault();
|
|
1884
|
-
}
|
|
1885
|
-
return;
|
|
1886
|
-
}
|
|
1887
|
-
const imgIndex = clickedImg.dataset.index;
|
|
1888
|
-
if (imgIndex == null) return;
|
|
1889
|
-
const matchedRef = imageRefs[parseInt(imgIndex)];
|
|
1890
|
-
const idx = selectedIndex.current;
|
|
1891
|
-
if (idx === imageCount - 1 && Number(imgIndex) === imageCount + 1) {
|
|
1892
|
-
suppressLoopRef.current = true;
|
|
1893
|
-
goToCanonical(0);
|
|
1894
|
-
return;
|
|
1895
|
-
}
|
|
1896
|
-
if (idx !== Number(imgIndex) && Number(imgIndex) !== idx + 2) {
|
|
1897
|
-
isZooming.current = true;
|
|
1898
|
-
handleZoomToggle(evt, matchedRef);
|
|
1899
|
-
}
|
|
1900
|
-
if (idx === imageCount - 1 && Number(imgIndex) === imageCount + 1) {
|
|
1901
|
-
isZooming.current = true;
|
|
1902
|
-
handleZoomToggle(evt, matchedRef);
|
|
1903
|
-
}
|
|
1904
|
-
if (slider.current && slider.current.children.length === 1) {
|
|
1905
|
-
isZooming.current = true;
|
|
1906
|
-
handleZoomToggle(evt, matchedRef);
|
|
1907
|
-
}
|
|
1908
|
-
suppressLoopRef.current = true;
|
|
1909
|
-
goToCanonical(idx);
|
|
1910
|
-
return;
|
|
1911
|
-
}
|
|
1912
|
-
if (dragMode.current === "y") {
|
|
1913
|
-
const rawY = trackerY.pointerUp(evt).fy;
|
|
1914
|
-
const tinyFlick = Math.abs(rawY) > 0.15;
|
|
1915
|
-
if (tinyFlick) {
|
|
1916
|
-
anim?.stop();
|
|
1917
|
-
translateRef.current?.lockY(yTemp.current);
|
|
1918
|
-
restoreOverlayTransition();
|
|
1919
|
-
isClosing.current = true;
|
|
1920
|
-
requestFsCloseRef.current?.();
|
|
1921
|
-
yTemp.current = 0;
|
|
1922
|
-
isVerticalScroll.current = false;
|
|
1923
|
-
return;
|
|
1924
|
-
}
|
|
1925
|
-
const dy = dragYForClose.current;
|
|
1926
|
-
const distanceThreshold = windowSize.height * 0.3;
|
|
1927
|
-
if (Math.abs(dy) > distanceThreshold) {
|
|
1928
|
-
anim?.stop();
|
|
1929
|
-
translateRef.current?.lockY(yTemp.current);
|
|
1930
|
-
restoreOverlayTransition();
|
|
1931
|
-
isClosing.current = true;
|
|
1932
|
-
requestFsCloseRef.current?.();
|
|
1933
|
-
yTemp.current = 0;
|
|
1934
|
-
isVerticalScroll.current = false;
|
|
1935
|
-
return;
|
|
1936
|
-
}
|
|
1937
|
-
snapBackY(300);
|
|
1938
|
-
dragMode.current = "none";
|
|
1939
|
-
isVerticalScroll.current = false;
|
|
1940
|
-
} else {
|
|
1941
|
-
let allowedForce2 = function(force2) {
|
|
1942
|
-
const len3 = slides.current.length || 1;
|
|
1943
|
-
const curIndex = selectedIndex.current || 0;
|
|
1944
|
-
const dirIndex = mathSign(force2) * -1;
|
|
1945
|
-
const nextIndex = ((curIndex + dirIndex) % len3 + len3) % len3;
|
|
1946
|
-
const dirBump = slides.current.length === 2 ? mathSign(force2) : 0;
|
|
1947
|
-
const nextTarget = fsScrollTarget.byIndex(nextIndex, dirBump);
|
|
1948
|
-
return nextTarget.distance;
|
|
1949
|
-
};
|
|
1950
|
-
const end = trackerX.pointerUp(evt);
|
|
1951
|
-
let rawForce = end.fx;
|
|
1952
|
-
if (isRtl) rawForce = -rawForce;
|
|
1953
|
-
const isMouseEvt = isMouseEvent(evt, window);
|
|
1954
|
-
const snapForceBoost = { mouse: 300, touch: 400 };
|
|
1955
|
-
const boost = snapForceBoost[isMouseEvt ? "mouse" : "touch"];
|
|
1956
|
-
const boostedForce = rawForce * boost;
|
|
1957
|
-
const fsScrollTarget = scrollTargetRef.current;
|
|
1958
|
-
const fsScrollTo2 = scrollToRef.current;
|
|
1959
|
-
const body2 = bodyRef.current;
|
|
1960
|
-
if (!fsScrollTarget || !fsScrollTo2 || !body2) {
|
|
1961
|
-
dragMode.current = "none";
|
|
1962
|
-
return;
|
|
1963
|
-
}
|
|
1964
|
-
const force = allowedForce2(boostedForce);
|
|
1965
|
-
const baseSpeed = sliderDuration;
|
|
1966
|
-
const baseFriction = sliderFriction;
|
|
1967
|
-
const forceFactor = factorAbs(boostedForce, force);
|
|
1968
|
-
const speed = baseSpeed - 10 * forceFactor;
|
|
1969
|
-
const friction = baseFriction + forceFactor / 50;
|
|
1970
|
-
body2.useDuration(speed).useFriction(friction);
|
|
1971
|
-
fsScrollTo2.distance(force, true);
|
|
1972
|
-
}
|
|
1973
|
-
dragMode.current = "none";
|
|
1974
|
-
}
|
|
1975
|
-
dragStore.add(root, "dragstart", (evt) => evt.preventDefault(), { passive: false }).add(root, "touchstart", onDown).add(root, "mousedown", onDown, { passive: true }).add(root, "touchcancel", () => {
|
|
1976
|
-
isTouchPinching.current = false;
|
|
1977
|
-
wasPinch.current = false;
|
|
1978
|
-
pointerDownRef.current = false;
|
|
1979
|
-
isPointerDown.current = false;
|
|
1980
|
-
dragMode.current = "none";
|
|
1981
|
-
isVerticalScroll.current = false;
|
|
1982
|
-
yTemp.current = 0;
|
|
1983
|
-
moveStore.clear();
|
|
1984
|
-
}).add(root, "contextmenu", onUp);
|
|
1985
|
-
return () => {
|
|
1986
|
-
dragStore.clear();
|
|
1987
|
-
moveStore.clear();
|
|
1988
|
-
animRef.current?.destroy();
|
|
1989
|
-
animRef.current = null;
|
|
1990
|
-
};
|
|
1991
|
-
}, [show, imageCount]);
|
|
1992
|
-
function goToCanonical(canonicalIdx, mode = "animated") {
|
|
1993
|
-
scrollToIndex(canonicalIdx, { jump: mode === "instant" });
|
|
1994
|
-
}
|
|
1995
|
-
useEffect(() => {
|
|
1996
|
-
const root = viewportRef.current;
|
|
1997
|
-
if (!root) return;
|
|
1998
|
-
let wheelTimer = null;
|
|
1999
|
-
function onWheel(e) {
|
|
2000
|
-
if (isZoomed) return;
|
|
2001
|
-
const track = slider.current;
|
|
2002
|
-
if (!track) return;
|
|
2003
|
-
const containerWidth = track.clientWidth;
|
|
2004
|
-
const contentWidth = (slides.current.length || 1) * (perSlideRef.current || containerWidth);
|
|
2005
|
-
const canScrollHorizontally = contentWidth > containerWidth;
|
|
2006
|
-
const isHorizontal = Math.abs(e.deltaX) > Math.abs(e.deltaY);
|
|
2007
|
-
if (!isHorizontal || !canScrollHorizontally) return;
|
|
2008
|
-
e.preventDefault();
|
|
2009
|
-
const cur = (offsetLocationRef.current?.get() ?? 0) - e.deltaX * sign;
|
|
2010
|
-
const next2 = cur;
|
|
2011
|
-
targetRef.current?.set(next2);
|
|
2012
|
-
bodyRef.current?.useDuration(0).useFriction(1);
|
|
2013
|
-
animRef.current?.start();
|
|
2014
|
-
x.current = next2;
|
|
2015
|
-
positionSlider();
|
|
2016
|
-
updateActiveIndexFromX(next2);
|
|
2017
|
-
if (wheelTimer) clearTimeout(wheelTimer);
|
|
2018
|
-
wheelTimer = window.setTimeout(() => {
|
|
2019
|
-
}, 120);
|
|
2020
|
-
}
|
|
2021
|
-
root.addEventListener("wheel", onWheel, { passive: false });
|
|
2022
|
-
return () => root.removeEventListener("wheel", onWheel);
|
|
2023
|
-
}, [isZoomed]);
|
|
2024
|
-
function updateActiveIndexFromX(loc) {
|
|
2025
|
-
const per = perSlide();
|
|
2026
|
-
const len2 = slideCount();
|
|
2027
|
-
let idx = Math.round(Math.abs(loc) / per);
|
|
2028
|
-
idx = (idx % len2 + len2) % len2;
|
|
2029
|
-
if (selectedIndex.current !== idx) {
|
|
2030
|
-
selectedIndex.current = idx;
|
|
2031
|
-
indexCurrentRef.current?.set(idx);
|
|
2032
|
-
sub.setLocalIndex(idx);
|
|
2033
|
-
let actualIndex = ((idx + 1) % imageCount + imageCount) % imageCount;
|
|
2034
|
-
if (actualIndex === 0) actualIndex = imageCount;
|
|
2035
|
-
if (counterRef.current) {
|
|
2036
|
-
counterRef.current.textContent = `${actualIndex} / ${imageCount}`;
|
|
2037
|
-
}
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
|
-
function setTranslateX(tx, ty) {
|
|
2041
|
-
if (!slider.current) return;
|
|
2042
|
-
let ny;
|
|
2043
|
-
if (isVerticalScroll.current) {
|
|
2044
|
-
ny = Math.round(ty);
|
|
2045
|
-
} else {
|
|
2046
|
-
const currentY = appliedYRef.current;
|
|
2047
|
-
const easedY = currentY + (0 - currentY) * 0.2;
|
|
2048
|
-
ny = Math.round(easedY);
|
|
2049
|
-
appliedYRef.current = ny;
|
|
2050
|
-
}
|
|
2051
|
-
commitXY(tx, ny);
|
|
2052
|
-
}
|
|
2053
|
-
function positionSlider() {
|
|
2054
|
-
setTranslateX(x.current, y.current);
|
|
2055
|
-
}
|
|
2056
|
-
useEffect(() => {
|
|
2057
|
-
const left = leftChevronRef.current;
|
|
2058
|
-
const right = rightChevronRef.current;
|
|
2059
|
-
const onClick = (ev) => {
|
|
2060
|
-
const target = ev.currentTarget;
|
|
2061
|
-
const action = target?.dataset.action;
|
|
2062
|
-
if (action === "prev") previous();
|
|
2063
|
-
else if (action === "next") next();
|
|
2064
|
-
};
|
|
2065
|
-
if (left) left.addEventListener("click", onClick);
|
|
2066
|
-
if (right) right.addEventListener("click", onClick);
|
|
2067
|
-
return () => {
|
|
2068
|
-
if (left) left.removeEventListener("click", onClick);
|
|
2069
|
-
if (right) right.removeEventListener("click", onClick);
|
|
2070
|
-
};
|
|
2071
|
-
}, [leftChevronRef.current, rightChevronRef.current, showFullscreenSlider, isRtl]);
|
|
2072
|
-
function setAllX(nx) {
|
|
2073
|
-
locationRef.current?.set(nx);
|
|
2074
|
-
previousLocationRef.current?.set(nx);
|
|
2075
|
-
offsetLocationRef.current?.set(nx);
|
|
2076
|
-
targetRef.current?.set(nx);
|
|
2077
|
-
x.current = nx;
|
|
2078
|
-
}
|
|
2079
|
-
useEffect(() => {
|
|
2080
|
-
let raf = 0;
|
|
2081
|
-
function onResize() {
|
|
2082
|
-
cancelAnimationFrame(raf);
|
|
2083
|
-
raf = requestAnimationFrame(() => {
|
|
2084
|
-
animRef.current?.stop();
|
|
2085
|
-
recenterWithAnchor();
|
|
2086
|
-
});
|
|
2087
|
-
}
|
|
2088
|
-
onResize();
|
|
2089
|
-
const roViewport = new ResizeObserver(onResize);
|
|
2090
|
-
if (viewportRef.current) roViewport.observe(viewportRef.current);
|
|
2091
|
-
window.addEventListener("orientationchange", onResize, { passive: true });
|
|
2092
|
-
return () => {
|
|
2093
|
-
cancelAnimationFrame(raf);
|
|
2094
|
-
window.removeEventListener("orientationchange", onResize);
|
|
2095
|
-
roViewport.disconnect();
|
|
2096
|
-
};
|
|
2097
|
-
}, [windowSize, recenterWithAnchor]);
|
|
2098
|
-
useEffect(() => {
|
|
2099
|
-
const offReq = sub.onRequest((req) => {
|
|
2100
|
-
switch (req.type) {
|
|
2101
|
-
case "requestSet": {
|
|
2102
|
-
const mode = req.mode ?? "animated";
|
|
2103
|
-
if (mode === "instant") {
|
|
2104
|
-
const per = perSlide();
|
|
2105
|
-
const nx = -per * req.index;
|
|
2106
|
-
setAllX(nx);
|
|
2107
|
-
setTranslateX(nx, 0);
|
|
2108
|
-
animRef.current?.stop();
|
|
2109
|
-
const idx = (req.index % slideCount() + slideCount()) % slideCount();
|
|
2110
|
-
commitIndexChange(idx);
|
|
2111
|
-
if (counterRef.current) {
|
|
2112
|
-
let actual = selectedIndex.current + 1;
|
|
2113
|
-
const len2 = slideCount();
|
|
2114
|
-
actual = (actual % len2 + len2) % len2;
|
|
2115
|
-
if (actual === 0) actual = imageCount;
|
|
2116
|
-
counterRef.current.textContent = `${actual} / ${imageCount}`;
|
|
2117
|
-
}
|
|
2118
|
-
} else {
|
|
2119
|
-
const mode2 = req.mode ?? "animated";
|
|
2120
|
-
const jump = mode2 === "instant";
|
|
2121
|
-
scrollToIndex(req.index, { jump });
|
|
2122
|
-
}
|
|
2123
|
-
break;
|
|
2124
|
-
}
|
|
2125
|
-
case "requestPrev":
|
|
2126
|
-
previous();
|
|
2127
|
-
break;
|
|
2128
|
-
case "requestNext":
|
|
2129
|
-
next();
|
|
2130
|
-
break;
|
|
2131
|
-
case "center":
|
|
2132
|
-
recenterWithAnchor();
|
|
2133
|
-
break;
|
|
2134
|
-
}
|
|
2135
|
-
});
|
|
2136
|
-
const offEvt = sub.onEvent(() => {
|
|
2137
|
-
});
|
|
2138
|
-
return () => {
|
|
2139
|
-
offReq();
|
|
2140
|
-
offEvt();
|
|
2141
|
-
};
|
|
2142
|
-
}, [sub]);
|
|
2143
|
-
function centerSlider() {
|
|
2144
|
-
scrollToIndex(selectedIndex.current, { jump: false });
|
|
2145
|
-
}
|
|
2146
|
-
useImperativeHandle(ref, () => ({ centerSlider }), [centerSlider]);
|
|
2147
|
-
function isVideoItem(item) {
|
|
2148
|
-
if (!item) return false;
|
|
2149
|
-
const any = item;
|
|
2150
|
-
if (any.type === "video") return true;
|
|
2151
|
-
if (any.kind === "video") return true;
|
|
2152
|
-
if (any.mediaType === "video") return true;
|
|
2153
|
-
if (any.videoSrc) return true;
|
|
2154
|
-
if (any.src && typeof any.src === "string" && any.src.match(/\.(mp4|webm|mov)(\?|#|$)/i)) return true;
|
|
2155
|
-
if (any.plyrSource) return true;
|
|
2156
|
-
if (any.sources?.video) return true;
|
|
2157
|
-
return false;
|
|
2158
|
-
}
|
|
2159
|
-
const len = normalizedItems?.length || imageCount || 1;
|
|
2160
|
-
const openingIndex = ((slideIndex ?? 0) % len + len) % len;
|
|
2161
|
-
const isVideoSlide = isVideoItem(normalizedItems?.[openingIndex]);
|
|
2162
|
-
return /* @__PURE__ */ jsx(
|
|
2163
|
-
"div",
|
|
2164
|
-
{
|
|
2165
|
-
ref: viewportRef,
|
|
2166
|
-
className: `fs_viewport ${rtlCls}`,
|
|
2167
|
-
dir: isRtl ? "rtl" : void 0,
|
|
2168
|
-
style: {
|
|
2169
|
-
position: "absolute",
|
|
2170
|
-
inset: 0,
|
|
2171
|
-
overflow: "hidden"
|
|
2172
|
-
},
|
|
2173
|
-
children: /* @__PURE__ */ jsx(
|
|
2174
|
-
"div",
|
|
2175
|
-
{
|
|
2176
|
-
ref: slider,
|
|
2177
|
-
className: `fullscreen_slider ${rtlCls}`,
|
|
2178
|
-
style: {
|
|
2179
|
-
position: "absolute",
|
|
2180
|
-
inset: 0,
|
|
2181
|
-
overflow: "visible",
|
|
2182
|
-
cursor: "grab",
|
|
2183
|
-
userSelect: "none",
|
|
2184
|
-
willChange: "opacity, transform",
|
|
2185
|
-
backfaceVisibility: "hidden",
|
|
2186
|
-
transition: introFade || isVideoSlide ? `opacity ${introDuration}ms ${introEasing}` : void 0,
|
|
2187
|
-
opacity: showFullscreenSlider ? introFade || isVideoSlide ? fadeOpening ? 0 : 1 : 1 : 0
|
|
2188
|
-
},
|
|
2189
|
-
children
|
|
2190
|
-
}
|
|
2191
|
-
)
|
|
2192
|
-
}
|
|
2193
|
-
);
|
|
2194
|
-
}
|
|
2195
|
-
);
|
|
2196
|
-
FullscreenSlider.displayName = "FullscreenSlider";
|
|
2197
|
-
function FullscreenThumbnailSlider({
|
|
2198
|
-
items,
|
|
2199
|
-
position,
|
|
2200
|
-
fsSub,
|
|
2201
|
-
className,
|
|
2202
|
-
style,
|
|
2203
|
-
thumbnailWidth,
|
|
2204
|
-
thumbnailHeight,
|
|
2205
|
-
thumbnailsCenter,
|
|
2206
|
-
thumbnailsContainerWidth,
|
|
2207
|
-
thumbnailsContainerHeight,
|
|
2208
|
-
visible = true,
|
|
2209
|
-
invisible = false,
|
|
2210
|
-
fadeDurationMs = 300,
|
|
2211
|
-
thumbnailItemClassName,
|
|
2212
|
-
thumbnailItemStyle,
|
|
2213
|
-
gap,
|
|
2214
|
-
freeScroll,
|
|
2215
|
-
groupCells,
|
|
2216
|
-
loop,
|
|
2217
|
-
direction,
|
|
2218
|
-
skipSnaps,
|
|
2219
|
-
centerActiveThumb,
|
|
2220
|
-
selectDuration,
|
|
2221
|
-
freeScrollDuration,
|
|
2222
|
-
sliderFriction,
|
|
2223
|
-
breakpointMap = { xs: 0, sm: 640, md: 768, lg: 1024, xl: 1280 },
|
|
2224
|
-
rippleEnabled,
|
|
2225
|
-
rippleClassName,
|
|
2226
|
-
showArrows = false,
|
|
2227
|
-
arrowStyles,
|
|
2228
|
-
arrowClassName,
|
|
2229
|
-
prevArrowStyles,
|
|
2230
|
-
prevArrowClassName,
|
|
2231
|
-
nextArrowStyles,
|
|
2232
|
-
nextArrowClassName,
|
|
2233
|
-
renderArrows,
|
|
2234
|
-
renderPrevArrow,
|
|
2235
|
-
renderNextArrow
|
|
2236
|
-
}) {
|
|
2237
|
-
const channelRef = useRef(createIndexChannel(fsSub.get(), "animated"));
|
|
2238
|
-
useEffect(() => {
|
|
2239
|
-
const off = fsSub.onEvent((e) => {
|
|
2240
|
-
if (e.type === "internalIndex") {
|
|
2241
|
-
channelRef.current.set(e.index, "animated", { silent: false });
|
|
2242
|
-
}
|
|
2243
|
-
});
|
|
2244
|
-
return off;
|
|
2245
|
-
}, [fsSub]);
|
|
2246
|
-
useEffect(() => {
|
|
2247
|
-
channelRef.current.set(fsSub.get(), "animated", { silent: true });
|
|
2248
|
-
}, [fsSub]);
|
|
2249
|
-
const children = useMemo(
|
|
2250
|
-
() => items.map((item, i) => /* @__PURE__ */ jsx(
|
|
2251
|
-
"button",
|
|
2252
|
-
{
|
|
2253
|
-
type: "button",
|
|
2254
|
-
style: {
|
|
2255
|
-
border: "none",
|
|
2256
|
-
padding: 0,
|
|
2257
|
-
background: "transparent",
|
|
2258
|
-
cursor: "pointer"
|
|
2259
|
-
},
|
|
2260
|
-
children: /* @__PURE__ */ jsx(
|
|
2261
|
-
"img",
|
|
2262
|
-
{
|
|
2263
|
-
src: item.thumbSrc,
|
|
2264
|
-
alt: item.alt ?? `thumb-${i}`,
|
|
2265
|
-
style: {
|
|
2266
|
-
width: "100%",
|
|
2267
|
-
height: "100%",
|
|
2268
|
-
objectFit: "cover",
|
|
2269
|
-
display: "block"
|
|
2270
|
-
},
|
|
2271
|
-
draggable: false
|
|
2272
|
-
}
|
|
2273
|
-
)
|
|
2274
|
-
},
|
|
2275
|
-
`fs-thumb-${i}`
|
|
2276
|
-
)),
|
|
2277
|
-
[items]
|
|
2278
|
-
);
|
|
2279
|
-
const isOpen = visible && !invisible;
|
|
2280
|
-
const opacity = isOpen ? 1 : 0;
|
|
2281
|
-
const transform = isOpen ? "translateY(0)" : "translateY(8px)";
|
|
2282
|
-
const pointerEvents = isOpen ? "auto" : "none";
|
|
2283
|
-
const wrapperStyle = {
|
|
2284
|
-
opacity,
|
|
2285
|
-
transform,
|
|
2286
|
-
pointerEvents,
|
|
2287
|
-
transition: `
|
|
2288
|
-
opacity ${fadeDurationMs}ms cubic-bezier(.4,0,.22,1),
|
|
2289
|
-
transform ${fadeDurationMs}ms cubic-bezier(.4,0,.22,1)
|
|
2290
|
-
`
|
|
2291
|
-
};
|
|
2292
|
-
return /* @__PURE__ */ jsx("div", { style: wrapperStyle, className, children: /* @__PURE__ */ jsx(
|
|
2293
|
-
ThumbnailSlider,
|
|
2294
|
-
{
|
|
2295
|
-
position,
|
|
2296
|
-
thumbnailWidth,
|
|
2297
|
-
thumbnailHeight,
|
|
2298
|
-
indexChannel: channelRef.current,
|
|
2299
|
-
style,
|
|
2300
|
-
onSelectThumb: (idx) => fsSub.requestSet(idx, "animated"),
|
|
2301
|
-
thumbnailsCenter,
|
|
2302
|
-
thumbnailsContainerWidth,
|
|
2303
|
-
thumbnailsContainerHeight,
|
|
2304
|
-
thumbnailItemClassName,
|
|
2305
|
-
thumbnailItemStyle,
|
|
2306
|
-
gap,
|
|
2307
|
-
freeScroll,
|
|
2308
|
-
groupCells,
|
|
2309
|
-
loop,
|
|
2310
|
-
direction,
|
|
2311
|
-
skipSnaps,
|
|
2312
|
-
centerActiveThumb,
|
|
2313
|
-
selectDuration,
|
|
2314
|
-
freeScrollDuration,
|
|
2315
|
-
sliderFriction,
|
|
2316
|
-
breakpointMap,
|
|
2317
|
-
rippleEnabled,
|
|
2318
|
-
rippleClassName,
|
|
2319
|
-
showArrows,
|
|
2320
|
-
arrowStyles,
|
|
2321
|
-
arrowClassName,
|
|
2322
|
-
prevArrowStyles,
|
|
2323
|
-
prevArrowClassName,
|
|
2324
|
-
nextArrowStyles,
|
|
2325
|
-
nextArrowClassName,
|
|
2326
|
-
renderArrows,
|
|
2327
|
-
renderPrevArrow,
|
|
2328
|
-
renderNextArrow,
|
|
2329
|
-
children
|
|
2330
|
-
}
|
|
2331
|
-
) });
|
|
2332
|
-
}
|
|
2333
|
-
function FsEntryOverlayMount({ setMountEl, style, className }) {
|
|
2334
|
-
return /* @__PURE__ */ jsx(
|
|
2335
|
-
"div",
|
|
2336
|
-
{
|
|
2337
|
-
ref: setMountEl,
|
|
2338
|
-
className,
|
|
2339
|
-
style: {
|
|
2340
|
-
position: "absolute",
|
|
2341
|
-
inset: 0,
|
|
2342
|
-
pointerEvents: "none",
|
|
2343
|
-
zIndex: 9999,
|
|
2344
|
-
...style
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
|
-
);
|
|
2348
|
-
}
|
|
2349
|
-
function FullscreenRuntime(props) {
|
|
2350
|
-
const {
|
|
2351
|
-
fsEnabled,
|
|
2352
|
-
fsSub,
|
|
2353
|
-
showFullscreenModal,
|
|
2354
|
-
setShowFullscreenModal,
|
|
2355
|
-
isClick,
|
|
2356
|
-
isAnimatingRef,
|
|
2357
|
-
overlayDivRef,
|
|
2358
|
-
cells,
|
|
2359
|
-
setShowFullscreenSlider,
|
|
2360
|
-
cellsStateLength,
|
|
2361
|
-
slidesForFullscreen,
|
|
2362
|
-
sliderForFullscreen,
|
|
2363
|
-
visibleImagesForFullscreen,
|
|
2364
|
-
selectedIndexForFullscreen,
|
|
2365
|
-
sliderXForFullscreen,
|
|
2366
|
-
sliderVelocityForFullscreen,
|
|
2367
|
-
isWrappingForFullscreen,
|
|
2368
|
-
wrappedItems,
|
|
2369
|
-
setClosingModal,
|
|
2370
|
-
closeButtonRef,
|
|
2371
|
-
counterRef,
|
|
2372
|
-
leftChevronRef,
|
|
2373
|
-
rightChevronRef,
|
|
2374
|
-
centerAlign,
|
|
2375
|
-
centerSliderForFullscreen,
|
|
2376
|
-
setSliderIndexForFullscreen,
|
|
2377
|
-
onForceResetZoom,
|
|
2378
|
-
layout,
|
|
2379
|
-
expandableImgRefs,
|
|
2380
|
-
entryMapRef,
|
|
2381
|
-
entryMediaLayout,
|
|
2382
|
-
introFade,
|
|
2383
|
-
introDuration,
|
|
2384
|
-
introEasing,
|
|
2385
|
-
epoch,
|
|
2386
|
-
fullscreenSliderApi,
|
|
2387
|
-
slideIndex,
|
|
2388
|
-
isZoomClick,
|
|
2389
|
-
isZoomed,
|
|
2390
|
-
windowSize,
|
|
2391
|
-
handleZoomToggle,
|
|
2392
|
-
zoomCtx,
|
|
2393
|
-
imageRefsCurrent,
|
|
2394
|
-
isPinching,
|
|
2395
|
-
scale,
|
|
2396
|
-
isTouchPinching,
|
|
2397
|
-
showFullscreenSlider,
|
|
2398
|
-
isZooming,
|
|
2399
|
-
wrappedModePlyrRefs,
|
|
2400
|
-
singleModePlyrRefs,
|
|
2401
|
-
closingModal,
|
|
2402
|
-
duplicateImgRef,
|
|
2403
|
-
direction,
|
|
2404
|
-
sliderDuration,
|
|
2405
|
-
sliderFriction,
|
|
2406
|
-
suppressLoopRef,
|
|
2407
|
-
fsFadeOpening,
|
|
2408
|
-
slideFade,
|
|
2409
|
-
slideFadeDuration,
|
|
2410
|
-
slideFadeEasing,
|
|
2411
|
-
normalizedItems,
|
|
2412
|
-
resetZoomForSlideChange,
|
|
2413
|
-
wrappedFullscreenImages,
|
|
2414
|
-
oneFullscreenImage,
|
|
2415
|
-
flexDirection,
|
|
2416
|
-
fsThumbContainerRef,
|
|
2417
|
-
fsThumbFadeDuration,
|
|
2418
|
-
fsThumbFadeEasing,
|
|
2419
|
-
fsThumbsOpen,
|
|
2420
|
-
fsResolvedThumbPos,
|
|
2421
|
-
fsThumbnailsPositionDefined,
|
|
2422
|
-
fsThumbnailsContainerClassName,
|
|
2423
|
-
fsThumbnailsContainerStyle,
|
|
2424
|
-
fsThumbThumbnailWidth,
|
|
2425
|
-
fsThumbThumbnailHeight,
|
|
2426
|
-
fsThumbCenter,
|
|
2427
|
-
fsThumbContainerWidth,
|
|
2428
|
-
fsThumbContainerHeight,
|
|
2429
|
-
fsThumbGap,
|
|
2430
|
-
fsThumbFreeScroll,
|
|
2431
|
-
fsThumbGroupCells,
|
|
2432
|
-
fsThumbLoop,
|
|
2433
|
-
fsThumbSkipSnaps,
|
|
2434
|
-
fsThumbCenterActiveThumb,
|
|
2435
|
-
fsThumbSelectDuration,
|
|
2436
|
-
fsThumbFreeScrollDuration,
|
|
2437
|
-
fsThumbFriction,
|
|
2438
|
-
fsThumbBreakpointMap,
|
|
2439
|
-
fsThumbRippleEnabled,
|
|
2440
|
-
fsThumbRippleClassName,
|
|
2441
|
-
fsThumbControlsEnabled,
|
|
2442
|
-
sliderThumbArrowStyles,
|
|
2443
|
-
sliderThumbArrowClassName,
|
|
2444
|
-
fsThumbPrevArrowStyles,
|
|
2445
|
-
fsThumbPrevArrowClassName,
|
|
2446
|
-
fsThumbNextArrowStyles,
|
|
2447
|
-
fsThumbNextArrowClassName,
|
|
2448
|
-
sliderThumbRenderArrows,
|
|
2449
|
-
fsThumbRenderPrevArrow,
|
|
2450
|
-
fsThumbRenderNextArrow,
|
|
2451
|
-
showFsEntryOverlayMount,
|
|
2452
|
-
setFsEntryOverlayMountEl,
|
|
2453
|
-
fsIntroReq,
|
|
2454
|
-
clearFsIntroReq,
|
|
2455
|
-
styles,
|
|
2456
|
-
fs,
|
|
2457
|
-
overlayCaptionRef,
|
|
2458
|
-
overlayCaptionRootRef,
|
|
2459
|
-
setFsFadeOpening,
|
|
2460
|
-
addShield,
|
|
2461
|
-
resolveFsCaptionPlacement,
|
|
2462
|
-
requestFsCloseRef
|
|
2463
|
-
} = props;
|
|
2464
|
-
React.useEffect(() => {
|
|
2465
|
-
if (!fsIntroReq) return;
|
|
2466
|
-
const { origImg, index, closestSelector } = fsIntroReq;
|
|
2467
|
-
runFullscreenIntro({
|
|
2468
|
-
origImg,
|
|
2469
|
-
index,
|
|
2470
|
-
normalizedItems,
|
|
2471
|
-
isRtl: direction === "rtl",
|
|
2472
|
-
styles,
|
|
2473
|
-
fs,
|
|
2474
|
-
overlayDivRef,
|
|
2475
|
-
duplicateImgRef,
|
|
2476
|
-
overlayCaptionRef,
|
|
2477
|
-
overlayCaptionRootRef,
|
|
2478
|
-
fsThumbContainerRef,
|
|
2479
|
-
setShowFullscreenSlider,
|
|
2480
|
-
setFsFadeOpening,
|
|
2481
|
-
addShield,
|
|
2482
|
-
resolveFsCaptionPlacement,
|
|
2483
|
-
closestSelector
|
|
2484
|
-
});
|
|
2485
|
-
clearFsIntroReq();
|
|
2486
|
-
}, [fsIntroReq]);
|
|
2487
|
-
return /* @__PURE__ */ jsx(Fragment, { children: fsEnabled && /* @__PURE__ */ jsxs(
|
|
2488
|
-
FullscreenModal,
|
|
2489
|
-
{
|
|
2490
|
-
fsSub,
|
|
2491
|
-
open: showFullscreenModal,
|
|
2492
|
-
onClose: () => setShowFullscreenModal(false),
|
|
2493
|
-
isClick,
|
|
2494
|
-
isAnimating: isAnimatingRef,
|
|
2495
|
-
overlayDivRef,
|
|
2496
|
-
cells,
|
|
2497
|
-
setShowFullscreenSlider,
|
|
2498
|
-
imageCount: cellsStateLength,
|
|
2499
|
-
slides: slidesForFullscreen,
|
|
2500
|
-
slider: sliderForFullscreen,
|
|
2501
|
-
visibleImagesRef: visibleImagesForFullscreen,
|
|
2502
|
-
selectedIndex: selectedIndexForFullscreen,
|
|
2503
|
-
sliderX: sliderXForFullscreen,
|
|
2504
|
-
sliderVelocity: sliderVelocityForFullscreen,
|
|
2505
|
-
isWrapping: isWrappingForFullscreen,
|
|
2506
|
-
wrappedItems,
|
|
2507
|
-
setClosingModal,
|
|
2508
|
-
closeButtonRef,
|
|
2509
|
-
counterRef,
|
|
2510
|
-
leftChevronRef,
|
|
2511
|
-
rightChevronRef,
|
|
2512
|
-
centerAlign,
|
|
2513
|
-
centerSlider: centerSliderForFullscreen,
|
|
2514
|
-
setSliderIndex: setSliderIndexForFullscreen,
|
|
2515
|
-
onForceResetZoom: () => onForceResetZoom(),
|
|
2516
|
-
layout,
|
|
2517
|
-
expandableImgRefs,
|
|
2518
|
-
entryMapRef,
|
|
2519
|
-
entryMediaLayout,
|
|
2520
|
-
introFade,
|
|
2521
|
-
introDuration,
|
|
2522
|
-
introEasing,
|
|
2523
|
-
requestFsCloseRef,
|
|
2524
|
-
fs,
|
|
2525
|
-
styles,
|
|
2526
|
-
direction,
|
|
2527
|
-
children: [
|
|
2528
|
-
/* @__PURE__ */ jsxs(
|
|
2529
|
-
"div",
|
|
2530
|
-
{
|
|
2531
|
-
style: {
|
|
2532
|
-
position: "absolute",
|
|
2533
|
-
inset: 0,
|
|
2534
|
-
display: "flex",
|
|
2535
|
-
flexDirection
|
|
2536
|
-
},
|
|
2537
|
-
children: [
|
|
2538
|
-
/* @__PURE__ */ jsx(
|
|
2539
|
-
"div",
|
|
2540
|
-
{
|
|
2541
|
-
style: {
|
|
2542
|
-
flex: "1 1 auto",
|
|
2543
|
-
position: "relative",
|
|
2544
|
-
minHeight: 0
|
|
2545
|
-
},
|
|
2546
|
-
children: /* @__PURE__ */ jsx(
|
|
2547
|
-
FullscreenSlider,
|
|
2548
|
-
{
|
|
2549
|
-
sub: fsSub,
|
|
2550
|
-
ref: fullscreenSliderApi,
|
|
2551
|
-
imageCount: cellsStateLength,
|
|
2552
|
-
slideIndex,
|
|
2553
|
-
isClick: isZoomClick,
|
|
2554
|
-
isZoomed,
|
|
2555
|
-
windowSize,
|
|
2556
|
-
show: showFullscreenModal,
|
|
2557
|
-
handleZoomToggle: (e, imageRef) => handleZoomToggle(zoomCtx, e, imageRef),
|
|
2558
|
-
imageRefs: imageRefsCurrent,
|
|
2559
|
-
cells,
|
|
2560
|
-
isPinching,
|
|
2561
|
-
scale,
|
|
2562
|
-
isTouchPinching,
|
|
2563
|
-
showFullscreenSlider,
|
|
2564
|
-
isZooming,
|
|
2565
|
-
plyrRefs: wrappedModePlyrRefs,
|
|
2566
|
-
plyrRef: singleModePlyrRefs,
|
|
2567
|
-
closingModal,
|
|
2568
|
-
closeButtonRef,
|
|
2569
|
-
counterRef,
|
|
2570
|
-
leftChevronRef,
|
|
2571
|
-
rightChevronRef,
|
|
2572
|
-
overlayDivRef,
|
|
2573
|
-
direction,
|
|
2574
|
-
isWrapping: isWrappingForFullscreen,
|
|
2575
|
-
sliderDuration,
|
|
2576
|
-
sliderFriction,
|
|
2577
|
-
suppressLoopRef,
|
|
2578
|
-
fadeOpening: fsFadeOpening,
|
|
2579
|
-
introFade,
|
|
2580
|
-
slideFade,
|
|
2581
|
-
slideFadeDuration,
|
|
2582
|
-
slideFadeEasing,
|
|
2583
|
-
normalizedItems,
|
|
2584
|
-
introDuration,
|
|
2585
|
-
introEasing,
|
|
2586
|
-
resetAllZoomDom: () => resetZoomForSlideChange(),
|
|
2587
|
-
requestFsCloseRef,
|
|
2588
|
-
children: normalizedItems.length > 1 ? wrappedFullscreenImages : oneFullscreenImage
|
|
2589
|
-
},
|
|
2590
|
-
epoch
|
|
2591
|
-
)
|
|
2592
|
-
}
|
|
2593
|
-
),
|
|
2594
|
-
fsThumbnailsPositionDefined && /* @__PURE__ */ jsx(
|
|
2595
|
-
"div",
|
|
2596
|
-
{
|
|
2597
|
-
ref: fsThumbContainerRef,
|
|
2598
|
-
className: fsThumbnailsContainerClassName,
|
|
2599
|
-
style: {
|
|
2600
|
-
flex: fsResolvedThumbPos === "left" || fsResolvedThumbPos === "right" ? "0 0 auto" : "0 0 auto",
|
|
2601
|
-
display: "flex",
|
|
2602
|
-
alignItems: "center",
|
|
2603
|
-
justifyContent: "center",
|
|
2604
|
-
padding: fsResolvedThumbPos === "top" || fsResolvedThumbPos === "bottom" ? "0.75rem 1rem" : "0.75rem 0.5rem",
|
|
2605
|
-
transition: `background-color ${fsThumbFadeDuration}ms ${fsThumbFadeEasing}`,
|
|
2606
|
-
backgroundColor: fsThumbsOpen ? "rgba(255,255,255,1)" : "rgba(255,255,255,0)",
|
|
2607
|
-
...fsThumbnailsContainerStyle || {}
|
|
2608
|
-
},
|
|
2609
|
-
children: normalizedItems.length > 1 && /* @__PURE__ */ jsx(
|
|
2610
|
-
FullscreenThumbnailSlider,
|
|
2611
|
-
{
|
|
2612
|
-
items: normalizedItems.map((item) => ({
|
|
2613
|
-
thumbSrc: item.thumbSrc ?? item.src,
|
|
2614
|
-
alt: item.alt
|
|
2615
|
-
})),
|
|
2616
|
-
position: fsResolvedThumbPos,
|
|
2617
|
-
fsSub,
|
|
2618
|
-
thumbnailWidth: fsThumbThumbnailWidth,
|
|
2619
|
-
thumbnailHeight: fsThumbThumbnailHeight,
|
|
2620
|
-
thumbnailsCenter: fsThumbCenter,
|
|
2621
|
-
thumbnailsContainerWidth: fsThumbContainerWidth,
|
|
2622
|
-
thumbnailsContainerHeight: fsThumbContainerHeight,
|
|
2623
|
-
visible: showFullscreenModal,
|
|
2624
|
-
invisible: closingModal,
|
|
2625
|
-
thumbnailItemClassName: void 0,
|
|
2626
|
-
thumbnailItemStyle: void 0,
|
|
2627
|
-
gap: fsThumbGap,
|
|
2628
|
-
freeScroll: fsThumbFreeScroll,
|
|
2629
|
-
groupCells: fsThumbGroupCells,
|
|
2630
|
-
loop: fsThumbLoop,
|
|
2631
|
-
direction,
|
|
2632
|
-
skipSnaps: fsThumbSkipSnaps,
|
|
2633
|
-
centerActiveThumb: fsThumbCenterActiveThumb,
|
|
2634
|
-
selectDuration: fsThumbSelectDuration,
|
|
2635
|
-
freeScrollDuration: fsThumbFreeScrollDuration,
|
|
2636
|
-
sliderFriction: fsThumbFriction,
|
|
2637
|
-
breakpointMap: fsThumbBreakpointMap,
|
|
2638
|
-
rippleEnabled: fsThumbRippleEnabled,
|
|
2639
|
-
rippleClassName: fsThumbRippleClassName,
|
|
2640
|
-
showArrows: fsThumbControlsEnabled,
|
|
2641
|
-
arrowStyles: sliderThumbArrowStyles,
|
|
2642
|
-
arrowClassName: sliderThumbArrowClassName,
|
|
2643
|
-
prevArrowStyles: fsThumbPrevArrowStyles,
|
|
2644
|
-
prevArrowClassName: fsThumbPrevArrowClassName,
|
|
2645
|
-
nextArrowStyles: fsThumbNextArrowStyles,
|
|
2646
|
-
nextArrowClassName: fsThumbNextArrowClassName,
|
|
2647
|
-
renderArrows: sliderThumbRenderArrows,
|
|
2648
|
-
renderPrevArrow: fsThumbRenderPrevArrow,
|
|
2649
|
-
renderNextArrow: fsThumbRenderNextArrow
|
|
2650
|
-
}
|
|
2651
|
-
)
|
|
2652
|
-
}
|
|
2653
|
-
)
|
|
2654
|
-
]
|
|
2655
|
-
}
|
|
2656
|
-
),
|
|
2657
|
-
showFsEntryOverlayMount ? /* @__PURE__ */ jsx(FsEntryOverlayMount, { setMountEl: setFsEntryOverlayMountEl }) : null
|
|
2658
|
-
]
|
|
2659
|
-
}
|
|
2660
|
-
) });
|
|
2661
|
-
}
|
|
2662
|
-
var FullscreenRuntime_default = FullscreenRuntime;
|
|
2663
|
-
|
|
2664
|
-
export { FullscreenRuntime, FullscreenRuntime_default as default };
|
|
2665
|
-
//# sourceMappingURL=FullscreenRuntime-CEYIXWZZ.mjs.map
|
|
2666
|
-
//# sourceMappingURL=FullscreenRuntime-CEYIXWZZ.mjs.map
|