react-motion-gallery 2.0.4 → 2.0.5
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 +274 -307
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +625 -190
- package/dist/index.mjs +12273 -6763
- package/dist/index.mjs.map +1 -1
- 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/chunk-HOCUKMYX.mjs
DELETED
|
@@ -1,2634 +0,0 @@
|
|
|
1
|
-
import { flushSync } from 'react-dom';
|
|
2
|
-
import { createRoot } from 'react-dom/client';
|
|
3
|
-
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
|
-
import { useRef, useId, useState, Children, isValidElement, useMemo, useEffect, cloneElement, useCallback } from 'react';
|
|
5
|
-
|
|
6
|
-
// src/Gallery/fullscreen/fullscreenIntro.tsx
|
|
7
|
-
|
|
8
|
-
// src/Gallery/shared/transitions/objectPosition.ts
|
|
9
|
-
function parseObjectPosition(op) {
|
|
10
|
-
if (!op) return { x: 0.5, y: 0.5 };
|
|
11
|
-
const mapKW = (kw, isX) => {
|
|
12
|
-
const lower = kw.toLowerCase();
|
|
13
|
-
if (isX) {
|
|
14
|
-
if (lower === "left") return 0;
|
|
15
|
-
if (lower === "center") return 0.5;
|
|
16
|
-
if (lower === "right") return 1;
|
|
17
|
-
} else {
|
|
18
|
-
if (lower === "top") return 0;
|
|
19
|
-
if (lower === "center") return 0.5;
|
|
20
|
-
if (lower === "bottom") return 1;
|
|
21
|
-
}
|
|
22
|
-
return NaN;
|
|
23
|
-
};
|
|
24
|
-
const parts = op.trim().split(/\s+/);
|
|
25
|
-
let xf = 0.5, yf = 0.5;
|
|
26
|
-
if (parts.length >= 1) {
|
|
27
|
-
const p0 = parts[0];
|
|
28
|
-
if (p0.endsWith("%")) xf = Math.min(1, Math.max(0, parseFloat(p0) / 100));
|
|
29
|
-
else {
|
|
30
|
-
const m0 = mapKW(p0, true);
|
|
31
|
-
if (!Number.isNaN(m0)) xf = m0;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (parts.length >= 2) {
|
|
35
|
-
const p1 = parts[1];
|
|
36
|
-
if (p1.endsWith("%")) yf = Math.min(1, Math.max(0, parseFloat(p1) / 100));
|
|
37
|
-
else {
|
|
38
|
-
const m1 = mapKW(p1, false);
|
|
39
|
-
if (!Number.isNaN(m1)) yf = m1;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return { x: xf, y: yf };
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// src/Gallery/shared/transitions/objectFitTransform.ts
|
|
46
|
-
function coverTransformForRect(natW, natH, cropRect, objPos) {
|
|
47
|
-
const cropW = Math.max(1, cropRect.width);
|
|
48
|
-
const cropH = Math.max(1, cropRect.height);
|
|
49
|
-
const s = Math.max(cropW / Math.max(1, natW), cropH / Math.max(1, natH));
|
|
50
|
-
const scaledW = natW * s;
|
|
51
|
-
const scaledH = natH * s;
|
|
52
|
-
const ox = objPos?.x ?? 0.5;
|
|
53
|
-
const oy = objPos?.y ?? 0.5;
|
|
54
|
-
const overflowX = Math.max(0, scaledW - cropW);
|
|
55
|
-
const overflowY = Math.max(0, scaledH - cropH);
|
|
56
|
-
const dx = (0.5 - ox) * overflowX;
|
|
57
|
-
const dy = (0.5 - oy) * overflowY;
|
|
58
|
-
const cx = cropRect.left + cropW / 2 + dx;
|
|
59
|
-
const cy = cropRect.top + cropH / 2 + dy;
|
|
60
|
-
return { cx, cy, scale: s };
|
|
61
|
-
}
|
|
62
|
-
function containTransformForRect(natW, natH, cropRect, objPos) {
|
|
63
|
-
const cropW = Math.max(1, cropRect.width);
|
|
64
|
-
const cropH = Math.max(1, cropRect.height);
|
|
65
|
-
const s = Math.min(cropW / Math.max(1, natW), cropH / Math.max(1, natH));
|
|
66
|
-
const scaledW = natW * s;
|
|
67
|
-
const scaledH = natH * s;
|
|
68
|
-
const ox = objPos?.x ?? 0.5;
|
|
69
|
-
const oy = objPos?.y ?? 0.5;
|
|
70
|
-
const extraX = Math.max(0, cropW - scaledW);
|
|
71
|
-
const extraY = Math.max(0, cropH - scaledH);
|
|
72
|
-
const left = cropRect.left + extraX * ox;
|
|
73
|
-
const top = cropRect.top + extraY * oy;
|
|
74
|
-
const cx = left + scaledW / 2;
|
|
75
|
-
const cy = top + scaledH / 2;
|
|
76
|
-
return { cx, cy, scale: s };
|
|
77
|
-
}
|
|
78
|
-
function objectFitContentRect(natW, natH, box, fit, objPos) {
|
|
79
|
-
const scale = fit === "contain" ? Math.min(box.width / natW, box.height / natH) : Math.max(box.width / natW, box.height / natH);
|
|
80
|
-
const w = natW * scale;
|
|
81
|
-
const h = natH * scale;
|
|
82
|
-
const left = box.left + (box.width - w) * objPos.x;
|
|
83
|
-
const top = box.top + (box.height - h) * objPos.y;
|
|
84
|
-
return new DOMRect(left, top, w, h);
|
|
85
|
-
}
|
|
86
|
-
function detectVideoSlide(item, slideEl) {
|
|
87
|
-
return item?.type === "video" || item?.kind === "video" || item?.mediaType === "video" || !!item?.videoSrc || !!item?.sources?.video || !!item?.plyrSource || !!slideEl?.dataset?.rmgVideo;
|
|
88
|
-
}
|
|
89
|
-
function runFullscreenIntro(args) {
|
|
90
|
-
const {
|
|
91
|
-
origImg,
|
|
92
|
-
index,
|
|
93
|
-
normalizedItems,
|
|
94
|
-
isRtl,
|
|
95
|
-
styles,
|
|
96
|
-
fs,
|
|
97
|
-
overlayDivRef,
|
|
98
|
-
duplicateImgRef,
|
|
99
|
-
overlayCaptionRef,
|
|
100
|
-
overlayCaptionRootRef,
|
|
101
|
-
fsThumbContainerRef,
|
|
102
|
-
setShowFullscreenSlider,
|
|
103
|
-
setFsFadeOpening,
|
|
104
|
-
addShield,
|
|
105
|
-
resolveFsCaptionPlacement,
|
|
106
|
-
closestSelector
|
|
107
|
-
} = args;
|
|
108
|
-
if (!origImg) return;
|
|
109
|
-
const DURATION_MS = fs.effects?.introDuration ?? 300;
|
|
110
|
-
const EASING = fs.effects?.introEasing ?? "cubic-bezier(.4,0,.22,1)";
|
|
111
|
-
addShield?.(400);
|
|
112
|
-
const vw = document.documentElement.clientWidth;
|
|
113
|
-
const vh = window.innerHeight;
|
|
114
|
-
const slideEl = origImg.closest(
|
|
115
|
-
closestSelector ?? // sensible default:
|
|
116
|
-
(closestSelector === void 0 ? ".rmg__grid-item, .rmg__slide" : "")
|
|
117
|
-
) || origImg.parentElement || origImg;
|
|
118
|
-
const slideRect = slideEl.getBoundingClientRect();
|
|
119
|
-
const imgRect = origImg.getBoundingClientRect();
|
|
120
|
-
const natW = Math.max(1, origImg.naturalWidth || 0);
|
|
121
|
-
const natH = Math.max(1, origImg.naturalHeight || 0);
|
|
122
|
-
const insetForRect = (r) => {
|
|
123
|
-
const top = r.top;
|
|
124
|
-
const left = r.left;
|
|
125
|
-
const right = vw - (r.left + r.width);
|
|
126
|
-
const bottom = vh - (r.top + r.height);
|
|
127
|
-
return `inset(${top}px ${right}px ${bottom}px ${left}px)`;
|
|
128
|
-
};
|
|
129
|
-
const fit = getComputedStyle(origImg).objectFit || "cover";
|
|
130
|
-
const cs0 = getComputedStyle(origImg);
|
|
131
|
-
const startObjPos = parseObjectPosition(cs0?.objectPosition ?? null);
|
|
132
|
-
const visibleImgRect = fit === "contain" ? objectFitContentRect(natW, natH, imgRect, "contain", startObjPos) : imgRect;
|
|
133
|
-
const startInset = insetForRect(visibleImgRect);
|
|
134
|
-
const overlay = document.createElement("div");
|
|
135
|
-
overlay.className = styles.fullscreenOverlay;
|
|
136
|
-
overlayDivRef.current = overlay;
|
|
137
|
-
overlay.style.opacity = "0";
|
|
138
|
-
overlay.style.pointerEvents = "none";
|
|
139
|
-
overlay.style.transition = "none";
|
|
140
|
-
document.body.appendChild(overlay);
|
|
141
|
-
void overlay.offsetWidth;
|
|
142
|
-
overlay.style.transition = `opacity ${DURATION_MS}ms ${EASING}`;
|
|
143
|
-
const effectivePlacement = resolveFsCaptionPlacement(
|
|
144
|
-
fs.caption?.placement,
|
|
145
|
-
fs.caption?.breakpoint,
|
|
146
|
-
vw
|
|
147
|
-
);
|
|
148
|
-
const DEFAULT_SIDE = 280;
|
|
149
|
-
const DEFAULT_TOP_BOTTOM = 200;
|
|
150
|
-
const sideWidth = fs.caption?.width ?? DEFAULT_SIDE;
|
|
151
|
-
const topBottomHeight = fs.caption?.height ?? DEFAULT_TOP_BOTTOM;
|
|
152
|
-
let contentLeft = 0;
|
|
153
|
-
let contentRight = vw;
|
|
154
|
-
let contentTop = 0;
|
|
155
|
-
let contentBottom = vh;
|
|
156
|
-
if (effectivePlacement === "right") {
|
|
157
|
-
contentRight = Math.max(0, vw - sideWidth);
|
|
158
|
-
} else if (effectivePlacement === "left") {
|
|
159
|
-
contentLeft = Math.min(vw, sideWidth);
|
|
160
|
-
} else if (effectivePlacement === "top") {
|
|
161
|
-
contentTop = Math.min(vh, topBottomHeight);
|
|
162
|
-
} else if (effectivePlacement === "bottom") {
|
|
163
|
-
contentBottom = Math.max(0, vh - topBottomHeight);
|
|
164
|
-
}
|
|
165
|
-
const thumbPos = fs.thumbnails?.layout?.position;
|
|
166
|
-
if (fsThumbContainerRef?.current && thumbPos) {
|
|
167
|
-
const H = fsThumbContainerRef.current.offsetHeight;
|
|
168
|
-
const W = fsThumbContainerRef.current.offsetWidth;
|
|
169
|
-
if (thumbPos === "top") contentTop += H;
|
|
170
|
-
else if (thumbPos === "bottom") contentBottom -= H;
|
|
171
|
-
else if (thumbPos === "left") contentLeft += W;
|
|
172
|
-
else if (thumbPos === "right") contentRight -= W;
|
|
173
|
-
}
|
|
174
|
-
const contentRect = new DOMRect(
|
|
175
|
-
contentLeft,
|
|
176
|
-
contentTop,
|
|
177
|
-
Math.max(1, contentRight - contentLeft),
|
|
178
|
-
Math.max(1, contentBottom - contentTop)
|
|
179
|
-
);
|
|
180
|
-
if (typeof fs.caption?.render === "function") {
|
|
181
|
-
try {
|
|
182
|
-
const overlayCaption = document.createElement("div");
|
|
183
|
-
overlayCaption.className = styles.fsOverlayCaption;
|
|
184
|
-
overlayCaptionRef.current = overlayCaption;
|
|
185
|
-
const base = {
|
|
186
|
-
position: "fixed",
|
|
187
|
-
display: "flex",
|
|
188
|
-
alignItems: "center",
|
|
189
|
-
justifyContent: "center",
|
|
190
|
-
textAlign: "left",
|
|
191
|
-
padding: "0.75rem 1rem",
|
|
192
|
-
color: "#fff",
|
|
193
|
-
fontSize: "0.875rem",
|
|
194
|
-
boxSizing: "border-box",
|
|
195
|
-
pointerEvents: "none",
|
|
196
|
-
transition: "opacity 220ms cubic-bezier(.4,0,.22,1), transform 220ms cubic-bezier(.4,0,.22,1)",
|
|
197
|
-
zIndex: "9999"
|
|
198
|
-
};
|
|
199
|
-
if (effectivePlacement === "right") {
|
|
200
|
-
base.top = thumbPos === "top" ? `${contentTop}px` : "0";
|
|
201
|
-
base.bottom = "0";
|
|
202
|
-
base.left = `${contentRight}px`;
|
|
203
|
-
base.width = `${sideWidth}px`;
|
|
204
|
-
base.height = thumbPos === "bottom" ? `${contentBottom}px` : "auto";
|
|
205
|
-
} else if (effectivePlacement === "left") {
|
|
206
|
-
base.top = thumbPos === "top" ? `${contentTop}px` : "0";
|
|
207
|
-
base.bottom = "0";
|
|
208
|
-
base.left = "0";
|
|
209
|
-
base.width = `${sideWidth}px`;
|
|
210
|
-
base.height = thumbPos === "bottom" ? `${contentBottom}px` : "auto";
|
|
211
|
-
} else if (effectivePlacement === "top") {
|
|
212
|
-
base.top = `${Math.max(0, contentTop - topBottomHeight)}px`;
|
|
213
|
-
base.left = `${contentLeft}px`;
|
|
214
|
-
base.right = `${Math.max(0, vw - contentRight)}px`;
|
|
215
|
-
base.height = `${topBottomHeight}px`;
|
|
216
|
-
} else if (effectivePlacement === "bottom") {
|
|
217
|
-
const bottomOffset = Math.max(
|
|
218
|
-
0,
|
|
219
|
-
vh - contentBottom - topBottomHeight
|
|
220
|
-
);
|
|
221
|
-
base.bottom = `${bottomOffset}px`;
|
|
222
|
-
base.left = `${contentLeft}px`;
|
|
223
|
-
base.right = `${Math.max(0, vw - contentRight)}px`;
|
|
224
|
-
base.height = `${topBottomHeight}px`;
|
|
225
|
-
} else {
|
|
226
|
-
base.bottom = "0";
|
|
227
|
-
base.left = "0";
|
|
228
|
-
base.right = "0";
|
|
229
|
-
base.height = "auto";
|
|
230
|
-
}
|
|
231
|
-
Object.assign(overlayCaption.style, base);
|
|
232
|
-
if (fs.caption?.className) {
|
|
233
|
-
fs.caption.className.split(" ").map((s) => s.trim()).filter(Boolean).forEach((c) => overlayCaption.classList.add(c));
|
|
234
|
-
}
|
|
235
|
-
if (fs.caption?.style) {
|
|
236
|
-
Object.assign(overlayCaption.style, fs.caption.style);
|
|
237
|
-
}
|
|
238
|
-
overlay.appendChild(overlayCaption);
|
|
239
|
-
const root = createRoot(overlayCaption);
|
|
240
|
-
overlayCaptionRootRef.current = root;
|
|
241
|
-
const item2 = normalizedItems[index];
|
|
242
|
-
const captionNode = fs.caption.render({
|
|
243
|
-
item: item2,
|
|
244
|
-
index,
|
|
245
|
-
isZoomed: false
|
|
246
|
-
});
|
|
247
|
-
root.render(/* @__PURE__ */ jsx(Fragment, { children: captionNode }));
|
|
248
|
-
} catch (err) {
|
|
249
|
-
console.error("[RMG] Failed to render overlay caption", err);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
normalizedItems.length;
|
|
253
|
-
const item = normalizedItems[index];
|
|
254
|
-
const isVideoSlide = detectVideoSlide(item, slideEl);
|
|
255
|
-
const forceFadeIntro = !!fs.effects?.introFade || isVideoSlide;
|
|
256
|
-
let clipper = null;
|
|
257
|
-
let dup = null;
|
|
258
|
-
if (!forceFadeIntro) {
|
|
259
|
-
let startAnimation2 = function() {
|
|
260
|
-
dup.style.transform = `translate3d(${startT.cx}px, ${startT.cy}px, 0) translate3d(${-natW / 2}px, ${-natH / 2}px, 0) scale(${startT.scale})`;
|
|
261
|
-
void dup.offsetWidth;
|
|
262
|
-
void clipper.offsetWidth;
|
|
263
|
-
void overlay.offsetWidth;
|
|
264
|
-
clipper.style.transition = `clip-path ${DURATION_MS}ms ${EASING}`;
|
|
265
|
-
dup.style.transition = `transform ${DURATION_MS}ms ${EASING}`;
|
|
266
|
-
overlay.style.transition = `opacity ${DURATION_MS}ms ${EASING}`;
|
|
267
|
-
requestAnimationFrame(() => {
|
|
268
|
-
clipper.style.clipPath = "inset(0px 0px 0px 0px)";
|
|
269
|
-
dup.style.transform = finalTransform;
|
|
270
|
-
dup.style.opacity = "1";
|
|
271
|
-
overlay.style.opacity = "1";
|
|
272
|
-
overlay.style.pointerEvents = "auto";
|
|
273
|
-
if (overlayCaptionRef.current) {
|
|
274
|
-
overlayCaptionRef.current.classList.add(styles.open);
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
};
|
|
278
|
-
clipper = document.createElement("div");
|
|
279
|
-
Object.assign(clipper.style, {
|
|
280
|
-
position: "fixed",
|
|
281
|
-
inset: "0",
|
|
282
|
-
clipPath: startInset,
|
|
283
|
-
willChange: "clip-path",
|
|
284
|
-
transition: "none",
|
|
285
|
-
zIndex: "9998"
|
|
286
|
-
});
|
|
287
|
-
dup = document.createElement("img");
|
|
288
|
-
dup.src = origImg.currentSrc || origImg.src;
|
|
289
|
-
Object.assign(dup.style, {
|
|
290
|
-
position: "fixed",
|
|
291
|
-
left: "0",
|
|
292
|
-
top: "0",
|
|
293
|
-
width: `${natW}px`,
|
|
294
|
-
height: `${natH}px`,
|
|
295
|
-
maxWidth: "none",
|
|
296
|
-
maxHeight: "none",
|
|
297
|
-
transformOrigin: "50% 50%",
|
|
298
|
-
willChange: "transform",
|
|
299
|
-
transition: "none",
|
|
300
|
-
opacity: "0",
|
|
301
|
-
display: "block",
|
|
302
|
-
zIndex: "9998"
|
|
303
|
-
});
|
|
304
|
-
duplicateImgRef.current = dup;
|
|
305
|
-
clipper.appendChild(dup);
|
|
306
|
-
const frag = document.createDocumentFragment();
|
|
307
|
-
frag.append(overlay, clipper);
|
|
308
|
-
document.body.appendChild(frag);
|
|
309
|
-
const startT = fit === "contain" ? containTransformForRect(natW, natH, visibleImgRect, startObjPos) : coverTransformForRect(natW, natH, slideRect, startObjPos);
|
|
310
|
-
dup.style.transform = `translate3d(${startT.cx}px, ${startT.cy}px, 0) translate3d(${-natW / 2}px, ${-natH / 2}px, 0) scale(${startT.scale})`;
|
|
311
|
-
void dup.offsetWidth;
|
|
312
|
-
void clipper.offsetWidth;
|
|
313
|
-
const fitsIntrinsic = natW <= contentRect.width && natH <= contentRect.height;
|
|
314
|
-
const endObjPos = { x: 0.5, y: 0.5 };
|
|
315
|
-
const endT = fitsIntrinsic ? {
|
|
316
|
-
cx: contentRect.x + contentRect.width / 2,
|
|
317
|
-
cy: contentRect.y + contentRect.height / 2,
|
|
318
|
-
scale: 1
|
|
319
|
-
} : containTransformForRect(natW, natH, contentRect, endObjPos);
|
|
320
|
-
const finalTransform = `translate3d(${endT.cx}px, ${endT.cy}px, 0) translate3d(${-natW / 2}px, ${-natH / 2}px, 0) scale(${endT.scale})`;
|
|
321
|
-
const ready = dup.decode ? dup.decode().catch(() => {
|
|
322
|
-
}) : new Promise((resolve) => {
|
|
323
|
-
if (dup.complete) return resolve();
|
|
324
|
-
dup.addEventListener("load", () => resolve(), { once: true });
|
|
325
|
-
dup.addEventListener("error", () => resolve(), { once: true });
|
|
326
|
-
});
|
|
327
|
-
ready.then(() => startAnimation2());
|
|
328
|
-
requestAnimationFrame(() => {
|
|
329
|
-
overlay.style.opacity = "1";
|
|
330
|
-
overlay.style.pointerEvents = "auto";
|
|
331
|
-
});
|
|
332
|
-
const onEnd = async (ev) => {
|
|
333
|
-
if (ev.propertyName !== "transform") return;
|
|
334
|
-
dup.removeEventListener("transitionend", onEnd);
|
|
335
|
-
await new Promise(
|
|
336
|
-
(r) => requestAnimationFrame(() => requestAnimationFrame(r))
|
|
337
|
-
);
|
|
338
|
-
setShowFullscreenSlider(true);
|
|
339
|
-
requestAnimationFrame(() => {
|
|
340
|
-
if (overlayCaptionRootRef.current) {
|
|
341
|
-
overlayCaptionRootRef.current.unmount();
|
|
342
|
-
overlayCaptionRootRef.current = null;
|
|
343
|
-
}
|
|
344
|
-
if (overlayCaptionRef.current) {
|
|
345
|
-
overlayCaptionRef.current.remove();
|
|
346
|
-
overlayCaptionRef.current = null;
|
|
347
|
-
}
|
|
348
|
-
clipper.remove();
|
|
349
|
-
dup.remove();
|
|
350
|
-
duplicateImgRef.current = null;
|
|
351
|
-
});
|
|
352
|
-
};
|
|
353
|
-
dup.addEventListener("transitionend", onEnd, { once: true });
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
requestAnimationFrame(() => {
|
|
357
|
-
overlay.style.opacity = "1";
|
|
358
|
-
overlay.style.pointerEvents = "auto";
|
|
359
|
-
if (overlayCaptionRef.current) {
|
|
360
|
-
overlayCaptionRef.current.classList.add(styles.open);
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
flushSync(() => {
|
|
364
|
-
setShowFullscreenSlider(true);
|
|
365
|
-
setFsFadeOpening(true);
|
|
366
|
-
});
|
|
367
|
-
requestAnimationFrame(() => {
|
|
368
|
-
setFsFadeOpening(false);
|
|
369
|
-
});
|
|
370
|
-
window.setTimeout(() => {
|
|
371
|
-
if (overlayCaptionRootRef.current) {
|
|
372
|
-
overlayCaptionRootRef.current.unmount();
|
|
373
|
-
overlayCaptionRootRef.current = null;
|
|
374
|
-
}
|
|
375
|
-
if (overlayCaptionRef.current) {
|
|
376
|
-
overlayCaptionRef.current.remove();
|
|
377
|
-
overlayCaptionRef.current = null;
|
|
378
|
-
}
|
|
379
|
-
}, DURATION_MS + 30);
|
|
380
|
-
}
|
|
381
|
-
function createSliderFullscreenIntroRunner(deps) {
|
|
382
|
-
return function runFromSliderEvent(_e, imgRef, index) {
|
|
383
|
-
const origImg = imgRef.current;
|
|
384
|
-
if (!origImg) return;
|
|
385
|
-
runFullscreenIntro({
|
|
386
|
-
...deps,
|
|
387
|
-
origImg,
|
|
388
|
-
index,
|
|
389
|
-
closestSelector: deps.closestSelector ?? ".rmg__slide"
|
|
390
|
-
});
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// src/Gallery/slider/sliderSub.tsx
|
|
395
|
-
function createIndexChannel(initialIndex = 0, initialMode = "animated") {
|
|
396
|
-
let index = initialIndex;
|
|
397
|
-
let mode = initialMode;
|
|
398
|
-
let lastEvent = { type: "set", index: initialIndex, mode: initialMode };
|
|
399
|
-
const subs = /* @__PURE__ */ new Set();
|
|
400
|
-
const evtSubs = /* @__PURE__ */ new Set();
|
|
401
|
-
let raf = 0;
|
|
402
|
-
const schedule = () => {
|
|
403
|
-
if (raf) return;
|
|
404
|
-
raf = requestAnimationFrame(() => {
|
|
405
|
-
raf = 0;
|
|
406
|
-
const ev = lastEvent;
|
|
407
|
-
evtSubs.forEach((fn) => fn(ev));
|
|
408
|
-
subs.forEach((fn) => fn());
|
|
409
|
-
});
|
|
410
|
-
};
|
|
411
|
-
return {
|
|
412
|
-
get() {
|
|
413
|
-
return { index, mode };
|
|
414
|
-
},
|
|
415
|
-
set(next, m = "animated", opts) {
|
|
416
|
-
index = next;
|
|
417
|
-
mode = m;
|
|
418
|
-
lastEvent = { type: "set", index, mode: m };
|
|
419
|
-
if (!opts?.silent) schedule();
|
|
420
|
-
},
|
|
421
|
-
bump(delta, m = "animated", opts) {
|
|
422
|
-
lastEvent = { type: "bump", delta: delta | 0, mode: m };
|
|
423
|
-
if (!opts?.silent) schedule();
|
|
424
|
-
},
|
|
425
|
-
subscribe(fn) {
|
|
426
|
-
subs.add(fn);
|
|
427
|
-
return () => {
|
|
428
|
-
subs.delete(fn);
|
|
429
|
-
};
|
|
430
|
-
},
|
|
431
|
-
onEvent(fn) {
|
|
432
|
-
evtSubs.add(fn);
|
|
433
|
-
return () => {
|
|
434
|
-
evtSubs.delete(fn);
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
// src/Gallery/shared/input/pointerTypes.ts
|
|
441
|
-
function isMouseEvent(evt, ownerWindow) {
|
|
442
|
-
return typeof ownerWindow.MouseEvent !== "undefined" && evt instanceof ownerWindow.MouseEvent;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
// src/Gallery/shared/input/dragTracker.ts
|
|
446
|
-
function createDragTracker(opts) {
|
|
447
|
-
const {
|
|
448
|
-
axis,
|
|
449
|
-
ownerWindow,
|
|
450
|
-
windowMs = 120,
|
|
451
|
-
recentMs = 90,
|
|
452
|
-
releaseFreshMs = 180,
|
|
453
|
-
stillMs = 140,
|
|
454
|
-
moveEps = 0.5,
|
|
455
|
-
flickVel = 0.1,
|
|
456
|
-
flickDist = 1,
|
|
457
|
-
minVel = 0.06
|
|
458
|
-
} = opts;
|
|
459
|
-
const EPS = 1e-6;
|
|
460
|
-
let samples = [];
|
|
461
|
-
let startX = 0, startY = 0;
|
|
462
|
-
let lastX = 0, lastY = 0, lastT = 0;
|
|
463
|
-
let lastActiveT = 0;
|
|
464
|
-
function now(evt) {
|
|
465
|
-
const ts = evt.timeStamp;
|
|
466
|
-
const perf = ownerWindow?.performance?.now ? ownerWindow.performance.now() : Date.now();
|
|
467
|
-
return typeof ts === "number" && ts > 0 ? ts : perf;
|
|
468
|
-
}
|
|
469
|
-
function isMouse(evt) {
|
|
470
|
-
return ownerWindow.MouseEvent ? evt instanceof ownerWindow.MouseEvent : "clientX" in evt && !("touches" in evt);
|
|
471
|
-
}
|
|
472
|
-
function readPoint(evt, axisKey = axis.scroll) {
|
|
473
|
-
const coord = axisKey === "x" ? "clientX" : "clientY";
|
|
474
|
-
if (isMouse(evt)) return evt[coord];
|
|
475
|
-
const te = evt;
|
|
476
|
-
const touch = te.touches && te.touches[0] || te.changedTouches && te.changedTouches[0];
|
|
477
|
-
return touch ? touch[coord] : axisKey === "x" ? lastX : lastY;
|
|
478
|
-
}
|
|
479
|
-
function trimTo(t) {
|
|
480
|
-
const earliest = t - windowMs * 1.5;
|
|
481
|
-
while (samples.length && samples[0].t < earliest) samples.shift();
|
|
482
|
-
}
|
|
483
|
-
function velocityInWindow(endT, spanMs) {
|
|
484
|
-
const startT = endT - spanMs;
|
|
485
|
-
let sumDx = 0, sumDy = 0;
|
|
486
|
-
let firstT = Number.POSITIVE_INFINITY, lastT2 = Number.NEGATIVE_INFINITY;
|
|
487
|
-
for (let i = samples.length - 1; i >= 0; i--) {
|
|
488
|
-
const s = samples[i];
|
|
489
|
-
if (s.t < startT) break;
|
|
490
|
-
firstT = Math.min(firstT, s.t);
|
|
491
|
-
lastT2 = Math.max(lastT2, s.t);
|
|
492
|
-
const age = s.t - startT;
|
|
493
|
-
const w = 0.5 + 0.5 * (age / Math.max(spanMs, 1));
|
|
494
|
-
sumDx += s.dx * w;
|
|
495
|
-
sumDy += s.dy * w;
|
|
496
|
-
}
|
|
497
|
-
const dt = Math.max(lastT2 - firstT, EPS);
|
|
498
|
-
return { vx: sumDx / dt, vy: sumDy / dt };
|
|
499
|
-
}
|
|
500
|
-
function displacementInWindow(endT, spanMs) {
|
|
501
|
-
const startT = endT - spanMs;
|
|
502
|
-
let dx = 0, dy = 0;
|
|
503
|
-
for (let i = samples.length - 1; i >= 0; i--) {
|
|
504
|
-
const s = samples[i];
|
|
505
|
-
if (s.t < startT) break;
|
|
506
|
-
dx += s.dx;
|
|
507
|
-
dy += s.dy;
|
|
508
|
-
}
|
|
509
|
-
return { dx, dy };
|
|
510
|
-
}
|
|
511
|
-
return {
|
|
512
|
-
axis,
|
|
513
|
-
pointerDown(evt) {
|
|
514
|
-
samples = [];
|
|
515
|
-
startX = lastX = readPoint(evt, "x");
|
|
516
|
-
startY = lastY = readPoint(evt, "y");
|
|
517
|
-
return { x: startX, y: startY };
|
|
518
|
-
},
|
|
519
|
-
pointerMove(evt) {
|
|
520
|
-
const t = now(evt);
|
|
521
|
-
const x = readPoint(evt, "x");
|
|
522
|
-
const y = readPoint(evt, "y");
|
|
523
|
-
const dx = x - lastX;
|
|
524
|
-
const dy = y - lastY;
|
|
525
|
-
samples.push({ t, dx, dy });
|
|
526
|
-
trimTo(t);
|
|
527
|
-
if (Math.abs(dx) >= moveEps || Math.abs(dy) >= moveEps) lastActiveT = t;
|
|
528
|
-
lastX = x;
|
|
529
|
-
lastY = y;
|
|
530
|
-
lastT = t;
|
|
531
|
-
return { dx, dy };
|
|
532
|
-
},
|
|
533
|
-
pointerUp(evt) {
|
|
534
|
-
const t = now(evt);
|
|
535
|
-
samples.push({ t, dx: 0, dy: 0 });
|
|
536
|
-
trimTo(t);
|
|
537
|
-
const sinceLastMove = t - lastT;
|
|
538
|
-
const idleMs = t - lastActiveT;
|
|
539
|
-
const releasedFresh = sinceLastMove <= releaseFreshMs;
|
|
540
|
-
const wasStill = idleMs > stillMs;
|
|
541
|
-
if (wasStill) return { fx: 0, fy: 0 };
|
|
542
|
-
const { vx: vxRecent, vy: vyRecent } = velocityInWindow(t, recentMs);
|
|
543
|
-
const { dx: dxRecent, dy: dyRecent } = displacementInWindow(t, recentMs);
|
|
544
|
-
const intentX = releasedFresh && (Math.abs(vxRecent) >= flickVel || Math.abs(dxRecent) >= flickDist);
|
|
545
|
-
const intentY = releasedFresh && (Math.abs(vyRecent) >= flickVel || Math.abs(dyRecent) >= flickDist);
|
|
546
|
-
const { vx, vy } = velocityInWindow(t, windowMs);
|
|
547
|
-
let fx = intentX ? vx : 0;
|
|
548
|
-
let fy = intentY ? vy : 0;
|
|
549
|
-
if (intentX && Math.abs(fx) < minVel) fx = (dxRecent >= 0 ? 1 : -1) * minVel;
|
|
550
|
-
if (intentY && Math.abs(fy) < minVel) fy = (dyRecent >= 0 ? 1 : -1) * minVel;
|
|
551
|
-
return { fx, fy };
|
|
552
|
-
},
|
|
553
|
-
readPoint
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
// src/Gallery/shared/motion/vector1d.ts
|
|
558
|
-
function Vector1D(initial) {
|
|
559
|
-
let v = initial;
|
|
560
|
-
return {
|
|
561
|
-
get: () => v,
|
|
562
|
-
set: (n) => {
|
|
563
|
-
v = n;
|
|
564
|
-
},
|
|
565
|
-
add: (n) => {
|
|
566
|
-
v += n;
|
|
567
|
-
}
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
// src/Gallery/shared/motion/scrollBody.ts
|
|
572
|
-
function ScrollBody(location, offsetLocation, previousLocation, target, baseDuration, baseFriction) {
|
|
573
|
-
let vel = 0;
|
|
574
|
-
let dir = 0;
|
|
575
|
-
let duration = baseDuration;
|
|
576
|
-
let friction = baseFriction;
|
|
577
|
-
let raw = location.get();
|
|
578
|
-
let rawPrev = 0;
|
|
579
|
-
const mathAbs3 = Math.abs;
|
|
580
|
-
return {
|
|
581
|
-
sync() {
|
|
582
|
-
raw = location.get();
|
|
583
|
-
rawPrev = raw;
|
|
584
|
-
return this;
|
|
585
|
-
},
|
|
586
|
-
resetVelocity() {
|
|
587
|
-
vel = 0;
|
|
588
|
-
return this;
|
|
589
|
-
},
|
|
590
|
-
useDuration(n) {
|
|
591
|
-
duration = n;
|
|
592
|
-
return this;
|
|
593
|
-
},
|
|
594
|
-
useFriction(n) {
|
|
595
|
-
friction = n;
|
|
596
|
-
return this;
|
|
597
|
-
},
|
|
598
|
-
useBaseDuration() {
|
|
599
|
-
return this.useDuration(baseDuration);
|
|
600
|
-
},
|
|
601
|
-
useBaseFriction() {
|
|
602
|
-
return this.useFriction(baseFriction);
|
|
603
|
-
},
|
|
604
|
-
duration() {
|
|
605
|
-
return duration;
|
|
606
|
-
},
|
|
607
|
-
frictionFactor() {
|
|
608
|
-
return friction;
|
|
609
|
-
},
|
|
610
|
-
direction() {
|
|
611
|
-
return dir;
|
|
612
|
-
},
|
|
613
|
-
velocity() {
|
|
614
|
-
return vel;
|
|
615
|
-
},
|
|
616
|
-
seek() {
|
|
617
|
-
const curLoc = location.get();
|
|
618
|
-
const curTgt = target.get();
|
|
619
|
-
const disp = curTgt - curLoc;
|
|
620
|
-
const instant = !duration;
|
|
621
|
-
let d = 0;
|
|
622
|
-
if (instant) {
|
|
623
|
-
vel = 0;
|
|
624
|
-
previousLocation.set(curTgt);
|
|
625
|
-
location.set(curTgt);
|
|
626
|
-
d = disp;
|
|
627
|
-
} else {
|
|
628
|
-
previousLocation.set(curLoc);
|
|
629
|
-
vel += disp / duration;
|
|
630
|
-
vel *= friction;
|
|
631
|
-
raw += vel;
|
|
632
|
-
location.add(vel);
|
|
633
|
-
d = raw - rawPrev;
|
|
634
|
-
}
|
|
635
|
-
dir = Math.sign(d);
|
|
636
|
-
rawPrev = raw;
|
|
637
|
-
return this;
|
|
638
|
-
},
|
|
639
|
-
settled() {
|
|
640
|
-
const diff = target.get() - offsetLocation.get();
|
|
641
|
-
return mathAbs3(diff) < 1e-3;
|
|
642
|
-
}
|
|
643
|
-
};
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
// src/Gallery/shared/motion/limit.ts
|
|
647
|
-
function Limit(min, max) {
|
|
648
|
-
const span = max - min || 1;
|
|
649
|
-
return {
|
|
650
|
-
min,
|
|
651
|
-
max,
|
|
652
|
-
reachedMin(n) {
|
|
653
|
-
return n < min;
|
|
654
|
-
},
|
|
655
|
-
reachedMax(n) {
|
|
656
|
-
return n > max;
|
|
657
|
-
},
|
|
658
|
-
constrain(n) {
|
|
659
|
-
return Math.max(min, Math.min(max, n));
|
|
660
|
-
},
|
|
661
|
-
reachedAny(n) {
|
|
662
|
-
return n < min || n > max;
|
|
663
|
-
},
|
|
664
|
-
removeOffset(n) {
|
|
665
|
-
let x = n;
|
|
666
|
-
while (x < min) x += span;
|
|
667
|
-
while (x > max) x -= span;
|
|
668
|
-
return x;
|
|
669
|
-
}
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
// src/Gallery/shared/motion/scrollLooper.ts
|
|
674
|
-
function ScrollLooper(contentSize, limit, location, vectors) {
|
|
675
|
-
const jointSafety = 0.1;
|
|
676
|
-
const min = limit.min + jointSafety;
|
|
677
|
-
const max = limit.max + jointSafety;
|
|
678
|
-
const l = Limit(min, max);
|
|
679
|
-
function shouldLoop(direction) {
|
|
680
|
-
if (direction === 1) return l.reachedMax(location.get());
|
|
681
|
-
if (direction === -1) return l.reachedMin(location.get());
|
|
682
|
-
return false;
|
|
683
|
-
}
|
|
684
|
-
return {
|
|
685
|
-
loop(direction) {
|
|
686
|
-
if (!shouldLoop(direction)) return;
|
|
687
|
-
const shift = contentSize * (direction * -1);
|
|
688
|
-
vectors.forEach((v) => v.add(shift));
|
|
689
|
-
}
|
|
690
|
-
};
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
// src/Gallery/shared/motion/scrollBounds.ts
|
|
694
|
-
function ScrollBounds(limit, location, target, body, pov, selectDuration) {
|
|
695
|
-
const pullBack = pov.measure(10);
|
|
696
|
-
const edgeTol = pov.measure(50);
|
|
697
|
-
const fricLim = Limit(0.1, 0.99);
|
|
698
|
-
function reached() {
|
|
699
|
-
return limit.reachedAny(target.get()) && limit.reachedAny(location.get());
|
|
700
|
-
}
|
|
701
|
-
return {
|
|
702
|
-
reached,
|
|
703
|
-
constrain(pointerDown) {
|
|
704
|
-
if (!reached()) return;
|
|
705
|
-
const edge = limit.reachedMin(location.get()) ? "min" : "max";
|
|
706
|
-
const distToEdge = Math.abs(limit[edge] - location.get());
|
|
707
|
-
const distToTarget = target.get() - location.get();
|
|
708
|
-
const f = fricLim.constrain(distToEdge / edgeTol);
|
|
709
|
-
target.set(target.get() - distToTarget * f);
|
|
710
|
-
if (!pointerDown && Math.abs(distToTarget) < pullBack) {
|
|
711
|
-
target.set(limit.constrain(target.get()));
|
|
712
|
-
body.useDuration(selectDuration).useBaseFriction();
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
};
|
|
716
|
-
}
|
|
717
|
-
function PercentOfView(viewSize) {
|
|
718
|
-
return {
|
|
719
|
-
measure(n) {
|
|
720
|
-
return viewSize * n / 100;
|
|
721
|
-
}
|
|
722
|
-
};
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
// src/Gallery/shared/motion/scrollTarget.ts
|
|
726
|
-
function ScrollTarget(loop, scrollSnaps, contentSize, limit, targetVector) {
|
|
727
|
-
const { reachedAny, removeOffset, constrain } = limit;
|
|
728
|
-
function minDistance(distances) {
|
|
729
|
-
return distances.concat().sort((a, b) => Math.abs(a) - Math.abs(b))[0];
|
|
730
|
-
}
|
|
731
|
-
function shortcut(target, direction) {
|
|
732
|
-
const targets = [target, target + contentSize, target - contentSize];
|
|
733
|
-
if (!loop) return target;
|
|
734
|
-
if (!direction) return minDistance(targets);
|
|
735
|
-
const dir = Math.sign(direction);
|
|
736
|
-
const matchingTargets = targets.filter((t) => Math.sign(t) === dir);
|
|
737
|
-
if (matchingTargets.length) return minDistance(matchingTargets);
|
|
738
|
-
return arrayLast(targets) - contentSize;
|
|
739
|
-
}
|
|
740
|
-
function findTargetSnap(target) {
|
|
741
|
-
const distance = loop ? removeOffset(target) : constrain(target);
|
|
742
|
-
const ascDiffsToSnaps = scrollSnaps.map((snap, index2) => ({
|
|
743
|
-
diff: shortcut(snap - distance, 0),
|
|
744
|
-
index: index2
|
|
745
|
-
})).sort((d1, d2) => Math.abs(d1.diff) - Math.abs(d2.diff));
|
|
746
|
-
const { index } = ascDiffsToSnaps[0];
|
|
747
|
-
return { index, distance };
|
|
748
|
-
}
|
|
749
|
-
function byIndex(index, direction) {
|
|
750
|
-
const diffToSnap = scrollSnaps[index] - targetVector.get();
|
|
751
|
-
const distance = shortcut(diffToSnap, direction);
|
|
752
|
-
return { index, distance };
|
|
753
|
-
}
|
|
754
|
-
function byDistance(distance, snap) {
|
|
755
|
-
const target = targetVector.get() + distance;
|
|
756
|
-
const { index, distance: targetSnapDistance } = findTargetSnap(target);
|
|
757
|
-
const reachedBound = !loop && reachedAny(target);
|
|
758
|
-
if (!snap || reachedBound) return { index, distance };
|
|
759
|
-
const diffToSnap = scrollSnaps[index] - targetSnapDistance;
|
|
760
|
-
const snapDistance = distance + shortcut(diffToSnap, 0);
|
|
761
|
-
return { index, distance: snapDistance };
|
|
762
|
-
}
|
|
763
|
-
return { byDistance, byIndex, shortcut };
|
|
764
|
-
}
|
|
765
|
-
var mathAbs = Math.abs;
|
|
766
|
-
var mathSign = (n) => n === 0 ? 0 : n > 0 ? 1 : -1;
|
|
767
|
-
function deltaAbs(valueB, valueA) {
|
|
768
|
-
return mathAbs(valueB - valueA);
|
|
769
|
-
}
|
|
770
|
-
function factorAbs(valueB, valueA) {
|
|
771
|
-
if (valueB === 0 || valueA === 0) return 0;
|
|
772
|
-
if (mathAbs(valueB) <= mathAbs(valueA)) return 0;
|
|
773
|
-
const diff = deltaAbs(mathAbs(valueB), mathAbs(valueA));
|
|
774
|
-
return mathAbs(diff / valueB);
|
|
775
|
-
}
|
|
776
|
-
function arrayLast(array) {
|
|
777
|
-
return array[arrayLastIndex(array)];
|
|
778
|
-
}
|
|
779
|
-
function arrayLastIndex(array) {
|
|
780
|
-
return Math.max(0, array.length - 1);
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
// src/Gallery/shared/motion/eventStore.ts
|
|
784
|
-
function EventStore() {
|
|
785
|
-
const listeners = [];
|
|
786
|
-
return {
|
|
787
|
-
add(t, type, fn, opts) {
|
|
788
|
-
t.addEventListener(type, fn, opts);
|
|
789
|
-
listeners.push(() => t.removeEventListener(type, fn, opts));
|
|
790
|
-
return this;
|
|
791
|
-
},
|
|
792
|
-
clear() {
|
|
793
|
-
while (listeners.length) listeners.pop()?.();
|
|
794
|
-
}
|
|
795
|
-
};
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
// src/Gallery/shared/motion/animations.ts
|
|
799
|
-
function Animations(doc, win, update, render) {
|
|
800
|
-
const fixed = 1e3 / 60;
|
|
801
|
-
const visible = EventStore();
|
|
802
|
-
let last = null;
|
|
803
|
-
let acc = 0;
|
|
804
|
-
let animId = 0;
|
|
805
|
-
function reset() {
|
|
806
|
-
last = null;
|
|
807
|
-
acc = 0;
|
|
808
|
-
}
|
|
809
|
-
function animate(ts) {
|
|
810
|
-
if (!animId) return;
|
|
811
|
-
if (last == null) {
|
|
812
|
-
last = ts;
|
|
813
|
-
update();
|
|
814
|
-
update();
|
|
815
|
-
}
|
|
816
|
-
const dt = ts - last;
|
|
817
|
-
last = ts;
|
|
818
|
-
acc += dt;
|
|
819
|
-
while (acc >= fixed) {
|
|
820
|
-
update();
|
|
821
|
-
acc -= fixed;
|
|
822
|
-
}
|
|
823
|
-
const alpha = acc / fixed;
|
|
824
|
-
render(alpha);
|
|
825
|
-
if (animId) animId = win.requestAnimationFrame(animate);
|
|
826
|
-
}
|
|
827
|
-
return {
|
|
828
|
-
init() {
|
|
829
|
-
visible.add(doc, "visibilitychange", () => {
|
|
830
|
-
if (doc.hidden) reset();
|
|
831
|
-
});
|
|
832
|
-
},
|
|
833
|
-
destroy() {
|
|
834
|
-
this.stop();
|
|
835
|
-
visible.clear();
|
|
836
|
-
},
|
|
837
|
-
start() {
|
|
838
|
-
if (animId) return;
|
|
839
|
-
animId = win.requestAnimationFrame(animate);
|
|
840
|
-
},
|
|
841
|
-
stop() {
|
|
842
|
-
win.cancelAnimationFrame(animId);
|
|
843
|
-
animId = 0;
|
|
844
|
-
reset();
|
|
845
|
-
},
|
|
846
|
-
resetBlend() {
|
|
847
|
-
reset();
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
// src/Gallery/shared/motion/counter.ts
|
|
853
|
-
var mathAbs2 = Math.abs;
|
|
854
|
-
function Counter(max, start, loop) {
|
|
855
|
-
const { constrain } = Limit(0, max);
|
|
856
|
-
const loopEnd = max + 1;
|
|
857
|
-
let counter = withinLimit(start);
|
|
858
|
-
function withinLimit(n) {
|
|
859
|
-
return !loop ? constrain(n) : mathAbs2((loopEnd + n) % loopEnd);
|
|
860
|
-
}
|
|
861
|
-
function get() {
|
|
862
|
-
return counter;
|
|
863
|
-
}
|
|
864
|
-
function set(n) {
|
|
865
|
-
counter = withinLimit(n);
|
|
866
|
-
return self;
|
|
867
|
-
}
|
|
868
|
-
function add(n) {
|
|
869
|
-
return clone().set(get() + n);
|
|
870
|
-
}
|
|
871
|
-
function clone() {
|
|
872
|
-
return Counter(max, get(), loop);
|
|
873
|
-
}
|
|
874
|
-
const self = {
|
|
875
|
-
get,
|
|
876
|
-
set,
|
|
877
|
-
add,
|
|
878
|
-
clone
|
|
879
|
-
};
|
|
880
|
-
return self;
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
// src/Gallery/shared/responsive.ts
|
|
884
|
-
var BREAKPOINT_MAP = {
|
|
885
|
-
xs: 0,
|
|
886
|
-
sm: 600,
|
|
887
|
-
md: 900,
|
|
888
|
-
lg: 1200,
|
|
889
|
-
xl: 1536
|
|
890
|
-
};
|
|
891
|
-
function parseNumberLike(v, fallback) {
|
|
892
|
-
if (v == null) return fallback;
|
|
893
|
-
if (typeof v === "number") return v;
|
|
894
|
-
const n = parseFloat(v);
|
|
895
|
-
return Number.isNaN(n) ? fallback : n;
|
|
896
|
-
}
|
|
897
|
-
function effectiveViewportWidth(raw) {
|
|
898
|
-
if (raw > 0) return raw;
|
|
899
|
-
if (typeof window !== "undefined" && window.innerWidth > 0) return window.innerWidth;
|
|
900
|
-
return 1024;
|
|
901
|
-
}
|
|
902
|
-
function resolveNumberFromResponsive(value, fallback, viewportWidth, breakpointMap = BREAKPOINT_MAP) {
|
|
903
|
-
const vw = effectiveViewportWidth(viewportWidth);
|
|
904
|
-
if (value == null) return fallback;
|
|
905
|
-
if (typeof value === "number" || typeof value === "string") {
|
|
906
|
-
return parseNumberLike(value, fallback);
|
|
907
|
-
}
|
|
908
|
-
if (Array.isArray(value)) {
|
|
909
|
-
return resolveNumberFromResponsive(value[0], fallback, vw, breakpointMap);
|
|
910
|
-
}
|
|
911
|
-
const entries = Object.entries(value).map(([key, v]) => {
|
|
912
|
-
const bp = breakpointMap[key] ?? (Number.isNaN(parseFloat(key)) ? 0 : parseFloat(key));
|
|
913
|
-
return { minWidth: bp, value: v };
|
|
914
|
-
}).sort((a, b) => a.minWidth - b.minWidth);
|
|
915
|
-
let result = fallback;
|
|
916
|
-
for (const bp of entries) {
|
|
917
|
-
if (vw >= bp.minWidth) {
|
|
918
|
-
result = resolveNumberFromResponsive(bp.value, result, vw, breakpointMap);
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
return result;
|
|
922
|
-
}
|
|
923
|
-
function resolvePositionFromResponsive(value, fallback, viewportWidth, breakpointMap = BREAKPOINT_MAP) {
|
|
924
|
-
const vw = effectiveViewportWidth(viewportWidth);
|
|
925
|
-
if (value == null) return fallback;
|
|
926
|
-
if (typeof value === "string") return value;
|
|
927
|
-
if (Array.isArray(value)) {
|
|
928
|
-
return value[0] ?? fallback;
|
|
929
|
-
}
|
|
930
|
-
const entries = Object.entries(value).map(([key, v]) => {
|
|
931
|
-
const bp = breakpointMap[key] ?? (Number.isNaN(parseFloat(key)) ? 0 : parseFloat(key));
|
|
932
|
-
return { minWidth: bp, value: v };
|
|
933
|
-
}).sort((a, b) => a.minWidth - b.minWidth);
|
|
934
|
-
let result = fallback;
|
|
935
|
-
for (const bp of entries) {
|
|
936
|
-
if (vw >= bp.minWidth) {
|
|
937
|
-
result = resolvePositionFromResponsive(bp.value, result, vw, breakpointMap);
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
return result;
|
|
941
|
-
}
|
|
942
|
-
function normalizeResponsiveToMinWidthRules(value, fallback, breakpointMap) {
|
|
943
|
-
if (value == null) return [{ minWidth: 0, count: fallback }];
|
|
944
|
-
if (typeof value === "number" || typeof value === "string") {
|
|
945
|
-
const n = Math.floor(parseNumberLike(value, fallback));
|
|
946
|
-
return [{ minWidth: 0, count: Math.max(0, n) }];
|
|
947
|
-
}
|
|
948
|
-
if (Array.isArray(value)) {
|
|
949
|
-
return normalizeResponsiveToMinWidthRules(value[0], fallback, breakpointMap);
|
|
950
|
-
}
|
|
951
|
-
const entries = Object.entries(value).map(([key, v]) => {
|
|
952
|
-
const bp = breakpointMap[key] ?? (Number.isNaN(parseFloat(key)) ? 0 : parseFloat(key));
|
|
953
|
-
const n = Math.floor(parseNumberLike(v, fallback));
|
|
954
|
-
return { minWidth: bp, count: Math.max(0, n) };
|
|
955
|
-
}).sort((a, b) => a.minWidth - b.minWidth);
|
|
956
|
-
if (entries.length === 0) return [{ minWidth: 0, count: fallback }];
|
|
957
|
-
if (entries[0].minWidth > 0) {
|
|
958
|
-
entries.unshift({ minWidth: 0, count: fallback });
|
|
959
|
-
} else if (entries[0].minWidth < 0) {
|
|
960
|
-
entries[0] = { ...entries[0], minWidth: 0 };
|
|
961
|
-
}
|
|
962
|
-
return entries;
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
// src/Gallery/shared/motion/baseLimit.ts
|
|
966
|
-
function createBaseLimit(min, max) {
|
|
967
|
-
const range = max - min || 1;
|
|
968
|
-
function constrain(n) {
|
|
969
|
-
return Math.max(min, Math.min(max, n));
|
|
970
|
-
}
|
|
971
|
-
function reachedAny(n) {
|
|
972
|
-
return n < min || n > max;
|
|
973
|
-
}
|
|
974
|
-
function removeOffset(n) {
|
|
975
|
-
let x = n;
|
|
976
|
-
while (x < min) x += range;
|
|
977
|
-
while (x > max) x -= range;
|
|
978
|
-
return x;
|
|
979
|
-
}
|
|
980
|
-
return { min, max, constrain, reachedAny, removeOffset };
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
// src/Gallery/shared/motion/translate.ts
|
|
984
|
-
function Translate(container, AX) {
|
|
985
|
-
let prev = NaN;
|
|
986
|
-
function write(n) {
|
|
987
|
-
if (n === prev) return;
|
|
988
|
-
container.style.transform = AX.translate(n);
|
|
989
|
-
prev = n;
|
|
990
|
-
}
|
|
991
|
-
return {
|
|
992
|
-
to(target) {
|
|
993
|
-
write(target);
|
|
994
|
-
},
|
|
995
|
-
get() {
|
|
996
|
-
return prev;
|
|
997
|
-
},
|
|
998
|
-
resetCache() {
|
|
999
|
-
prev = NaN;
|
|
1000
|
-
}
|
|
1001
|
-
};
|
|
1002
|
-
}
|
|
1003
|
-
function TranslateFullscreen(container) {
|
|
1004
|
-
let prevX = NaN;
|
|
1005
|
-
let prevY = NaN;
|
|
1006
|
-
let lockY = false;
|
|
1007
|
-
let lockedY = 0;
|
|
1008
|
-
let suspended = false;
|
|
1009
|
-
const round2 = (n) => Math.round(n * 100) / 100;
|
|
1010
|
-
function write(nx, ny) {
|
|
1011
|
-
if (nx === prevX && ny === prevY) return;
|
|
1012
|
-
container.style.transform = `translate3d(${nx}px, ${ny}px, 0)`;
|
|
1013
|
-
prevX = nx;
|
|
1014
|
-
prevY = ny;
|
|
1015
|
-
}
|
|
1016
|
-
return {
|
|
1017
|
-
to(targetX, targetY = 0) {
|
|
1018
|
-
if (suspended) return;
|
|
1019
|
-
const nx = round2(targetX);
|
|
1020
|
-
const ny = lockY ? lockedY : targetY;
|
|
1021
|
-
write(nx, ny);
|
|
1022
|
-
},
|
|
1023
|
-
lockY(value) {
|
|
1024
|
-
lockY = true;
|
|
1025
|
-
lockedY = Math.round((value ?? prevY) || 0);
|
|
1026
|
-
write(prevX || 0, lockedY);
|
|
1027
|
-
},
|
|
1028
|
-
unlockY() {
|
|
1029
|
-
lockY = false;
|
|
1030
|
-
},
|
|
1031
|
-
suspend(on = true) {
|
|
1032
|
-
suspended = on;
|
|
1033
|
-
},
|
|
1034
|
-
get() {
|
|
1035
|
-
return { x: prevX, y: prevY };
|
|
1036
|
-
},
|
|
1037
|
-
resetCache() {
|
|
1038
|
-
prevX = NaN;
|
|
1039
|
-
prevY = NaN;
|
|
1040
|
-
}
|
|
1041
|
-
};
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
// src/Gallery/shared/types/axis.ts
|
|
1045
|
-
function Axis(isHorizontal) {
|
|
1046
|
-
const scroll = isHorizontal ? "x" : "y";
|
|
1047
|
-
const cross = isHorizontal ? "y" : "x";
|
|
1048
|
-
return {
|
|
1049
|
-
scroll,
|
|
1050
|
-
cross,
|
|
1051
|
-
measureSize(rect) {
|
|
1052
|
-
return isHorizontal ? rect.width : rect.height;
|
|
1053
|
-
}
|
|
1054
|
-
};
|
|
1055
|
-
}
|
|
1056
|
-
function FullscreenAxis() {
|
|
1057
|
-
return {
|
|
1058
|
-
scroll: "x",
|
|
1059
|
-
cross: "y",
|
|
1060
|
-
direction(n) {
|
|
1061
|
-
return n;
|
|
1062
|
-
},
|
|
1063
|
-
measureSize(rect) {
|
|
1064
|
-
return rect.width;
|
|
1065
|
-
}
|
|
1066
|
-
};
|
|
1067
|
-
}
|
|
1068
|
-
function PanAxis() {
|
|
1069
|
-
return {
|
|
1070
|
-
scroll: "x",
|
|
1071
|
-
cross: "y",
|
|
1072
|
-
direction(n) {
|
|
1073
|
-
return n;
|
|
1074
|
-
}
|
|
1075
|
-
};
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
// src/Gallery/slider/thumbnails/ThumbnailSlider.module.css
|
|
1079
|
-
var ThumbnailSlider_default = {};
|
|
1080
|
-
|
|
1081
|
-
// src/Gallery/shared/skeleton/buildScopedSkeletonCountCss.ts
|
|
1082
|
-
function buildScopedSkeletonCountCss(args) {
|
|
1083
|
-
const { scopeId, responsiveCount, fallbackCount, breakpointMap, maxSlots } = args;
|
|
1084
|
-
const rules = normalizeResponsiveToMinWidthRules(responsiveCount, fallbackCount, breakpointMap);
|
|
1085
|
-
const clamp2 = (n) => Math.max(0, Math.min(maxSlots, Math.floor(n)));
|
|
1086
|
-
const baseCount = clamp2(rules[0]?.count ?? fallbackCount);
|
|
1087
|
-
const rootSel = `[data-rmg-scope="${scopeId}"]`;
|
|
1088
|
-
const slotSel = `${rootSel} [data-rmg-skel-slot]`;
|
|
1089
|
-
const lines = [];
|
|
1090
|
-
lines.push(`${slotSel}{ display:none; }`);
|
|
1091
|
-
const showFirstN = (count) => {
|
|
1092
|
-
const c = clamp2(count);
|
|
1093
|
-
if (c <= 0) return "";
|
|
1094
|
-
return Array.from({ length: c }).map((_, i) => `${rootSel} [data-rmg-skel-slot="${i + 1}"]{ display:block; }`).join("\n");
|
|
1095
|
-
};
|
|
1096
|
-
lines.push(showFirstN(baseCount));
|
|
1097
|
-
for (const r of rules.slice(1)) {
|
|
1098
|
-
const c = clamp2(r.count);
|
|
1099
|
-
lines.push(`@media (min-width:${r.minWidth}px){
|
|
1100
|
-
${showFirstN(c)}
|
|
1101
|
-
}`);
|
|
1102
|
-
}
|
|
1103
|
-
return { cssText: lines.join("\n"), ssrBaseCount: baseCount };
|
|
1104
|
-
}
|
|
1105
|
-
function DefaultChevron({
|
|
1106
|
-
axisMain,
|
|
1107
|
-
direction,
|
|
1108
|
-
size = 32
|
|
1109
|
-
}) {
|
|
1110
|
-
const pathPrev = /* @__PURE__ */ jsx("path", { d: "M15.41 16.59L10.83 12l4.58-4.59L14 6l-6 6 6 6z" });
|
|
1111
|
-
const pathNext = /* @__PURE__ */ jsx("path", { d: "M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6z" });
|
|
1112
|
-
if (axisMain === "y") {
|
|
1113
|
-
return /* @__PURE__ */ jsx(
|
|
1114
|
-
"svg",
|
|
1115
|
-
{
|
|
1116
|
-
viewBox: "0 0 24 24",
|
|
1117
|
-
width: size,
|
|
1118
|
-
height: size,
|
|
1119
|
-
fill: "#000",
|
|
1120
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1121
|
-
"aria-hidden": true,
|
|
1122
|
-
style: { transform: "rotate(90deg)", transformOrigin: "50% 50%" },
|
|
1123
|
-
children: direction === "prev" ? pathPrev : pathNext
|
|
1124
|
-
}
|
|
1125
|
-
);
|
|
1126
|
-
}
|
|
1127
|
-
return /* @__PURE__ */ jsx(
|
|
1128
|
-
"svg",
|
|
1129
|
-
{
|
|
1130
|
-
viewBox: "0 0 24 24",
|
|
1131
|
-
width: size,
|
|
1132
|
-
height: size,
|
|
1133
|
-
fill: "#000",
|
|
1134
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1135
|
-
"aria-hidden": true,
|
|
1136
|
-
children: direction === "prev" ? pathPrev : pathNext
|
|
1137
|
-
}
|
|
1138
|
-
);
|
|
1139
|
-
}
|
|
1140
|
-
var baseArrowStyle = {
|
|
1141
|
-
position: "absolute",
|
|
1142
|
-
overflow: "hidden",
|
|
1143
|
-
backgroundColor: "rgba(255, 255, 255, 0.75)",
|
|
1144
|
-
boxShadow: "0 0 5px rgba(0, 0, 0, 0.5)",
|
|
1145
|
-
borderRadius: "100%",
|
|
1146
|
-
zIndex: 2,
|
|
1147
|
-
width: 36,
|
|
1148
|
-
height: 36,
|
|
1149
|
-
display: "flex",
|
|
1150
|
-
justifyContent: "center",
|
|
1151
|
-
alignItems: "center",
|
|
1152
|
-
transition: "opacity 120ms"
|
|
1153
|
-
};
|
|
1154
|
-
function prevPlacement(axisMain) {
|
|
1155
|
-
return axisMain === "y" ? { left: "50%", top: 10, transform: "translateX(-50%)" } : { left: 10, top: "50%", transform: "translateY(-50%)" };
|
|
1156
|
-
}
|
|
1157
|
-
function nextPlacement(axisMain) {
|
|
1158
|
-
return axisMain === "y" ? { left: "50%", bottom: 10, transform: "translateX(-50%)" } : { right: 10, top: "50%", transform: "translateY(-50%)" };
|
|
1159
|
-
}
|
|
1160
|
-
function RmgArrows(props) {
|
|
1161
|
-
const {
|
|
1162
|
-
axisMain,
|
|
1163
|
-
clientKey,
|
|
1164
|
-
wrap,
|
|
1165
|
-
isRtl,
|
|
1166
|
-
showArrows,
|
|
1167
|
-
selectedIndex,
|
|
1168
|
-
slideCount,
|
|
1169
|
-
measureRef,
|
|
1170
|
-
viewportMainSizeRef,
|
|
1171
|
-
previous,
|
|
1172
|
-
next,
|
|
1173
|
-
prevButtonRef,
|
|
1174
|
-
nextButtonRef,
|
|
1175
|
-
createRipple,
|
|
1176
|
-
arrowStyles,
|
|
1177
|
-
prevArrowStyles,
|
|
1178
|
-
nextArrowStyles,
|
|
1179
|
-
arrowClassName,
|
|
1180
|
-
prevArrowClassName,
|
|
1181
|
-
nextArrowClassName,
|
|
1182
|
-
renderPrevArrow,
|
|
1183
|
-
renderNextArrow,
|
|
1184
|
-
renderArrows
|
|
1185
|
-
} = props;
|
|
1186
|
-
const atFirst = !wrap && selectedIndex <= 0;
|
|
1187
|
-
const atLast = !wrap && selectedIndex >= Math.max(0, slideCount - 1);
|
|
1188
|
-
const clientMain = measureRef.current ? measureRef.current[clientKey] : 0;
|
|
1189
|
-
const arrowsAutoHidden = !(slideCount > 1 && measureRef.current && viewportMainSizeRef.current > clientMain);
|
|
1190
|
-
const arrowsHidden = !showArrows || arrowsAutoHidden;
|
|
1191
|
-
const prevDisabled = arrowsHidden || !wrap && (isRtl ? atLast : atFirst);
|
|
1192
|
-
const nextDisabled = arrowsHidden || !wrap && (isRtl ? atFirst : atLast);
|
|
1193
|
-
const prevArrowStylesEffective = {
|
|
1194
|
-
...arrowStyles ?? {},
|
|
1195
|
-
...prevArrowStyles ?? {}
|
|
1196
|
-
};
|
|
1197
|
-
const nextArrowStylesEffective = {
|
|
1198
|
-
...arrowStyles ?? {},
|
|
1199
|
-
...nextArrowStyles ?? {}
|
|
1200
|
-
};
|
|
1201
|
-
const prevArrowClassNameEffective = [arrowClassName, prevArrowClassName].filter(Boolean).join(" ");
|
|
1202
|
-
const nextArrowClassNameEffective = [arrowClassName, nextArrowClassName].filter(Boolean).join(" ");
|
|
1203
|
-
function makeArrowOnClick(dir, hidden) {
|
|
1204
|
-
return () => {
|
|
1205
|
-
if (hidden) return;
|
|
1206
|
-
requestAnimationFrame(() => {
|
|
1207
|
-
if (dir === "prev") previous();
|
|
1208
|
-
else next();
|
|
1209
|
-
});
|
|
1210
|
-
};
|
|
1211
|
-
}
|
|
1212
|
-
const DefaultArrow = ({
|
|
1213
|
-
dir,
|
|
1214
|
-
ref,
|
|
1215
|
-
onClick,
|
|
1216
|
-
hidden,
|
|
1217
|
-
disabled,
|
|
1218
|
-
className
|
|
1219
|
-
}) => {
|
|
1220
|
-
const dim = disabled ? 0.35 : 1;
|
|
1221
|
-
const placement = dir === "prev" ? prevPlacement(axisMain) : nextPlacement(axisMain);
|
|
1222
|
-
const perDirStyles = dir === "prev" ? prevArrowStylesEffective : nextArrowStylesEffective;
|
|
1223
|
-
return /* @__PURE__ */ jsx(
|
|
1224
|
-
"div",
|
|
1225
|
-
{
|
|
1226
|
-
ref,
|
|
1227
|
-
className: `rmgArrow rmgArrow--${dir} ${className ?? ""}`,
|
|
1228
|
-
onClick: (evt) => {
|
|
1229
|
-
if (hidden) return;
|
|
1230
|
-
createRipple(evt.currentTarget);
|
|
1231
|
-
requestAnimationFrame(() => onClick());
|
|
1232
|
-
},
|
|
1233
|
-
style: {
|
|
1234
|
-
...baseArrowStyle,
|
|
1235
|
-
...placement,
|
|
1236
|
-
...perDirStyles,
|
|
1237
|
-
cursor: disabled ? "default" : "pointer",
|
|
1238
|
-
opacity: hidden ? 0 : dim,
|
|
1239
|
-
pointerEvents: hidden ? "none" : "auto",
|
|
1240
|
-
visibility: hidden ? "hidden" : "visible"
|
|
1241
|
-
},
|
|
1242
|
-
"aria-label": dir === "prev" ? "Previous slide" : "Next slide",
|
|
1243
|
-
role: "button",
|
|
1244
|
-
title: disabled ? dir === "prev" ? "At first slide" : "At last slide" : dir === "prev" ? "Previous" : "Next",
|
|
1245
|
-
children: /* @__PURE__ */ jsx(DefaultChevron, { axisMain, direction: dir, size: 32 })
|
|
1246
|
-
}
|
|
1247
|
-
);
|
|
1248
|
-
};
|
|
1249
|
-
const renderArrow = (dir, args) => {
|
|
1250
|
-
if (dir === "prev" && renderPrevArrow) return renderPrevArrow(args);
|
|
1251
|
-
if (dir === "next" && renderNextArrow) return renderNextArrow(args);
|
|
1252
|
-
if (renderArrows) return renderArrows({ ...args, dir });
|
|
1253
|
-
return DefaultArrow({ ...args, dir });
|
|
1254
|
-
};
|
|
1255
|
-
const prevArrowNode = renderArrow("prev", {
|
|
1256
|
-
ref: prevButtonRef,
|
|
1257
|
-
hidden: arrowsHidden,
|
|
1258
|
-
disabled: prevDisabled,
|
|
1259
|
-
onClick: makeArrowOnClick("prev", arrowsHidden),
|
|
1260
|
-
createRipple,
|
|
1261
|
-
className: prevArrowClassNameEffective
|
|
1262
|
-
});
|
|
1263
|
-
const nextArrowNode = renderArrow("next", {
|
|
1264
|
-
ref: nextButtonRef,
|
|
1265
|
-
hidden: arrowsHidden,
|
|
1266
|
-
disabled: nextDisabled,
|
|
1267
|
-
onClick: makeArrowOnClick("next", arrowsHidden),
|
|
1268
|
-
createRipple,
|
|
1269
|
-
className: nextArrowClassNameEffective
|
|
1270
|
-
});
|
|
1271
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1272
|
-
prevArrowNode,
|
|
1273
|
-
nextArrowNode
|
|
1274
|
-
] });
|
|
1275
|
-
}
|
|
1276
|
-
var clamp = (n, lo, hi) => Math.max(lo, Math.min(hi, n));
|
|
1277
|
-
function DragTracker(axis, ownerWindow) {
|
|
1278
|
-
return createDragTracker({
|
|
1279
|
-
ownerWindow,
|
|
1280
|
-
axis
|
|
1281
|
-
});
|
|
1282
|
-
}
|
|
1283
|
-
function ThumbnailSlider({
|
|
1284
|
-
children,
|
|
1285
|
-
position,
|
|
1286
|
-
thumbSize,
|
|
1287
|
-
className,
|
|
1288
|
-
style,
|
|
1289
|
-
thumbnailWidth,
|
|
1290
|
-
thumbnailHeight,
|
|
1291
|
-
indexChannel,
|
|
1292
|
-
onSelectThumb,
|
|
1293
|
-
thumbnailsCenter,
|
|
1294
|
-
thumbnailsContainerWidth,
|
|
1295
|
-
thumbnailsContainerHeight,
|
|
1296
|
-
thumbnailsContainerClassName,
|
|
1297
|
-
thumbnailsContainerStyle,
|
|
1298
|
-
thumbnailItemClassName,
|
|
1299
|
-
thumbnailItemStyle,
|
|
1300
|
-
gap = 8,
|
|
1301
|
-
freeScroll = true,
|
|
1302
|
-
groupCells = false,
|
|
1303
|
-
loop = false,
|
|
1304
|
-
direction = "ltr",
|
|
1305
|
-
skipSnaps = false,
|
|
1306
|
-
centerActiveThumb = false,
|
|
1307
|
-
selectDuration = 25,
|
|
1308
|
-
freeScrollDuration = 43,
|
|
1309
|
-
sliderFriction = 0.68,
|
|
1310
|
-
loadingOptions,
|
|
1311
|
-
introOptions,
|
|
1312
|
-
breakpointMap = { xs: 0, sm: 640, md: 768, lg: 1024, xl: 1280 },
|
|
1313
|
-
rippleEnabled,
|
|
1314
|
-
rippleClassName,
|
|
1315
|
-
showArrows = false,
|
|
1316
|
-
arrowStyles,
|
|
1317
|
-
arrowClassName,
|
|
1318
|
-
prevArrowStyles,
|
|
1319
|
-
prevArrowClassName,
|
|
1320
|
-
nextArrowStyles,
|
|
1321
|
-
nextArrowClassName,
|
|
1322
|
-
renderArrows,
|
|
1323
|
-
renderPrevArrow,
|
|
1324
|
-
renderNextArrow
|
|
1325
|
-
}) {
|
|
1326
|
-
const isHorizontal = position === "top" || position === "bottom";
|
|
1327
|
-
const axis = Axis(isHorizontal);
|
|
1328
|
-
const isRtl = direction === "rtl" ? true : false;
|
|
1329
|
-
const sign = isHorizontal && isRtl ? -1 : 1;
|
|
1330
|
-
const containerRef = useRef(null);
|
|
1331
|
-
const trackRef = useRef(null);
|
|
1332
|
-
const scopeId = useId().replace(/:/g, "-");
|
|
1333
|
-
const channelRef = useRef(indexChannel ?? createIndexChannel());
|
|
1334
|
-
const [thumbLong, setThumbLong] = useState(thumbSize ?? 0);
|
|
1335
|
-
const [thumbCross, setThumbCross] = useState(0);
|
|
1336
|
-
const [contentLength, setContentLength] = useState(0);
|
|
1337
|
-
const [containerLength, setContainerLength] = useState(0);
|
|
1338
|
-
const locationRef = useRef(null);
|
|
1339
|
-
const previousLocationRef = useRef(null);
|
|
1340
|
-
const offsetLocationRef = useRef(null);
|
|
1341
|
-
const targetRef = useRef(null);
|
|
1342
|
-
const bodyRef = useRef(null);
|
|
1343
|
-
const translateRef = useRef(null);
|
|
1344
|
-
const animRef = useRef(null);
|
|
1345
|
-
const limitRef = useRef(null);
|
|
1346
|
-
const boundsRef = useRef(null);
|
|
1347
|
-
const povRef = useRef(null);
|
|
1348
|
-
const isAnimatingRef = useRef(false);
|
|
1349
|
-
const prevButtonRef = useRef(null);
|
|
1350
|
-
const nextButtonRef = useRef(null);
|
|
1351
|
-
const pagesRef = useRef([]);
|
|
1352
|
-
const snapModeRef = useRef("base");
|
|
1353
|
-
const pointerDownRef = useRef(false);
|
|
1354
|
-
const isPointerDown = useRef(false);
|
|
1355
|
-
const isClickRef = useRef(true);
|
|
1356
|
-
const xRef = useRef(0);
|
|
1357
|
-
const dragX = useRef(0);
|
|
1358
|
-
const previousDragX = useRef(0);
|
|
1359
|
-
const dragMoveTime = useRef(null);
|
|
1360
|
-
const sliderVelocity = useRef(0);
|
|
1361
|
-
const selectedIndexRef = useRef(channelRef.current.get().index ?? 0);
|
|
1362
|
-
const rawKids = Children.toArray(children).filter(isValidElement);
|
|
1363
|
-
const count = rawKids.length;
|
|
1364
|
-
const baseOffsetRef = useRef(0);
|
|
1365
|
-
const downTargetRef = useRef(null);
|
|
1366
|
-
const [inView, setInView] = useState(false);
|
|
1367
|
-
const [isReady, setIsReady] = useState(false);
|
|
1368
|
-
const readyRafRef = useRef(null);
|
|
1369
|
-
const readyPaintedRef = useRef(false);
|
|
1370
|
-
const contentSizeRef = useRef(0);
|
|
1371
|
-
const loopLimitRef = useRef(null);
|
|
1372
|
-
const scrollSnapsRef = useRef([]);
|
|
1373
|
-
const scrollContentSizeRef = useRef(0);
|
|
1374
|
-
const scrollLimitRef = useRef(null);
|
|
1375
|
-
const scrollTargetRef = useRef(null);
|
|
1376
|
-
const scrollToRef = useRef(null);
|
|
1377
|
-
const indexCurrentRef = useRef(null);
|
|
1378
|
-
const indexPreviousRef = useRef(null);
|
|
1379
|
-
const [buildKey, setBuildKey] = useState(0);
|
|
1380
|
-
const loopStableRef = useRef(null);
|
|
1381
|
-
const [geomKey, setGeomKey] = useState(0);
|
|
1382
|
-
const lastGeomSigRef = useRef("");
|
|
1383
|
-
const [wrap, setWrap] = useState(false);
|
|
1384
|
-
const isWrapping = useRef(false);
|
|
1385
|
-
const clonesCountRef = useRef(0);
|
|
1386
|
-
const visibleThumbsRef = useRef(1);
|
|
1387
|
-
const layoutRef = useRef(null);
|
|
1388
|
-
const thumbCells = useRef([]);
|
|
1389
|
-
const [clonedChildren, setClonedChildren] = useState([]);
|
|
1390
|
-
const lastCloneSigRef = useRef("");
|
|
1391
|
-
const slidesRef = useRef([]);
|
|
1392
|
-
const [slidesState, setSlidesState] = useState([]);
|
|
1393
|
-
const [isMeasured, setIsMeasured] = useState(false);
|
|
1394
|
-
const cellToSlideRef = useRef([]);
|
|
1395
|
-
const sliderWidth = useRef(0);
|
|
1396
|
-
const [layoutReady, setLayoutReady] = useState(false);
|
|
1397
|
-
const prevActiveRef = useRef(-1);
|
|
1398
|
-
const draggingAttr = "data-rmg-drag";
|
|
1399
|
-
const activePointerIdRef = useRef(null);
|
|
1400
|
-
const guardsStoreRef = useRef(null);
|
|
1401
|
-
const AX = useMemo(() => {
|
|
1402
|
-
const main = isHorizontal ? "x" : "y";
|
|
1403
|
-
const cross = isHorizontal ? "y" : "x";
|
|
1404
|
-
const sizeKey = isHorizontal ? "width" : "height";
|
|
1405
|
-
const clientKey = isHorizontal ? "clientWidth" : "clientHeight";
|
|
1406
|
-
const startKey = isHorizontal ? "left" : "top";
|
|
1407
|
-
const endKey = isHorizontal ? "right" : "bottom";
|
|
1408
|
-
const translate = (n) => isHorizontal ? `translate3d(${n}px,0,0)` : `translate3d(0,${n}px,0)`;
|
|
1409
|
-
const place = (n) => isHorizontal ? `translateX(${n}px) scale(var(--rmg-scale, 1))` : `translateY(${n}px) scale(var(--rmg-scale, 1))`;
|
|
1410
|
-
const wheelDelta = (e) => isHorizontal ? e.deltaX : e.deltaY;
|
|
1411
|
-
return { main, cross, sizeKey, clientKey, startKey, endKey, translate, place, wheelDelta };
|
|
1412
|
-
}, [position]);
|
|
1413
|
-
useEffect(() => {
|
|
1414
|
-
const root2 = containerRef.current;
|
|
1415
|
-
if (!root2) return;
|
|
1416
|
-
let canceled = false;
|
|
1417
|
-
if (typeof IntersectionObserver === "undefined") {
|
|
1418
|
-
setInView(true);
|
|
1419
|
-
return;
|
|
1420
|
-
}
|
|
1421
|
-
const io = new IntersectionObserver(
|
|
1422
|
-
(entries) => {
|
|
1423
|
-
if (canceled) return;
|
|
1424
|
-
const ent = entries[0];
|
|
1425
|
-
setInView(!!ent?.isIntersecting);
|
|
1426
|
-
},
|
|
1427
|
-
{
|
|
1428
|
-
root: null,
|
|
1429
|
-
rootMargin: "200px 0px 200px 0px",
|
|
1430
|
-
threshold: 0.01
|
|
1431
|
-
}
|
|
1432
|
-
);
|
|
1433
|
-
io.observe(root2);
|
|
1434
|
-
return () => {
|
|
1435
|
-
canceled = true;
|
|
1436
|
-
io.disconnect();
|
|
1437
|
-
};
|
|
1438
|
-
}, []);
|
|
1439
|
-
function setWrapSafe(next2) {
|
|
1440
|
-
if (loopStableRef.current === next2) return;
|
|
1441
|
-
loopStableRef.current = next2;
|
|
1442
|
-
setWrap(next2);
|
|
1443
|
-
isWrapping.current = next2;
|
|
1444
|
-
setLayoutReady(false);
|
|
1445
|
-
setIsReady(false);
|
|
1446
|
-
readyPaintedRef.current = false;
|
|
1447
|
-
setBuildKey((k) => k + 1);
|
|
1448
|
-
}
|
|
1449
|
-
function mod(n, m) {
|
|
1450
|
-
return (n % m + m) % m;
|
|
1451
|
-
}
|
|
1452
|
-
function getCenterScroll(i) {
|
|
1453
|
-
const lay = layoutRef.current;
|
|
1454
|
-
if (!lay?.originals?.length) return 0;
|
|
1455
|
-
const o = lay.originals[i];
|
|
1456
|
-
if (!o) return 0;
|
|
1457
|
-
const view = lay.cw || containerLength || 0;
|
|
1458
|
-
const size = o.size;
|
|
1459
|
-
const raw = o.start - (view - size) / 2;
|
|
1460
|
-
if (!wrap) {
|
|
1461
|
-
const maxScroll = Math.max(0, contentLength - view);
|
|
1462
|
-
return clamp(raw, 0, maxScroll);
|
|
1463
|
-
}
|
|
1464
|
-
const W = contentLength || sliderWidth.current || 0;
|
|
1465
|
-
if (!W) return 0;
|
|
1466
|
-
return mod(raw, W);
|
|
1467
|
-
}
|
|
1468
|
-
function setTargetToScroll(scroll) {
|
|
1469
|
-
const tgt = targetRef.current;
|
|
1470
|
-
if (!tgt) return;
|
|
1471
|
-
const desired = -scroll;
|
|
1472
|
-
if (!wrap) {
|
|
1473
|
-
tgt.set(desired);
|
|
1474
|
-
return;
|
|
1475
|
-
}
|
|
1476
|
-
const W = contentLength || sliderWidth.current || 0;
|
|
1477
|
-
if (!W) {
|
|
1478
|
-
tgt.set(desired);
|
|
1479
|
-
return;
|
|
1480
|
-
}
|
|
1481
|
-
const cur = tgt.get();
|
|
1482
|
-
const c0 = desired;
|
|
1483
|
-
const c1 = desired + W;
|
|
1484
|
-
const c2 = desired - W;
|
|
1485
|
-
const best = Math.abs(c0 - cur) <= Math.abs(c1 - cur) && Math.abs(c0 - cur) <= Math.abs(c2 - cur) ? c0 : Math.abs(c1 - cur) <= Math.abs(c2 - cur) ? c1 : c2;
|
|
1486
|
-
tgt.set(best);
|
|
1487
|
-
}
|
|
1488
|
-
function cloneThumb(child, key, canonicalIndex, elementIndex) {
|
|
1489
|
-
return cloneElement(child, {
|
|
1490
|
-
key,
|
|
1491
|
-
["data-rmg-thumb-index"]: String(canonicalIndex),
|
|
1492
|
-
ref: (el) => {
|
|
1493
|
-
if (!el) return;
|
|
1494
|
-
if (!thumbCells.current.some((c) => c.element === el)) {
|
|
1495
|
-
thumbCells.current.push({ element: el, index: elementIndex });
|
|
1496
|
-
}
|
|
1497
|
-
},
|
|
1498
|
-
style: {
|
|
1499
|
-
position: "absolute",
|
|
1500
|
-
top: 0,
|
|
1501
|
-
left: 0,
|
|
1502
|
-
width: thumbnailWidth,
|
|
1503
|
-
height: thumbnailHeight,
|
|
1504
|
-
cursor: "pointer",
|
|
1505
|
-
userSelect: "none",
|
|
1506
|
-
...thumbnailItemStyle || {},
|
|
1507
|
-
...child.props?.style || {}
|
|
1508
|
-
},
|
|
1509
|
-
className: [ThumbnailSlider_default.thumb, thumbnailItemClassName, child.props?.className].filter(Boolean).join(" "),
|
|
1510
|
-
draggable: false
|
|
1511
|
-
});
|
|
1512
|
-
}
|
|
1513
|
-
function computeCloneSig(originals, per) {
|
|
1514
|
-
return `${originals}|per=${per}|wrap=${wrap ? 1 : 0}`;
|
|
1515
|
-
}
|
|
1516
|
-
useEffect(() => {
|
|
1517
|
-
const el = trackRef.current;
|
|
1518
|
-
if (!el) return;
|
|
1519
|
-
const ro = new ResizeObserver(() => {
|
|
1520
|
-
const rawKids2 = Children.toArray(children).filter(isValidElement);
|
|
1521
|
-
const originals = rawKids2.length;
|
|
1522
|
-
if (originals < 1) {
|
|
1523
|
-
clonesCountRef.current = 0;
|
|
1524
|
-
thumbCells.current = [];
|
|
1525
|
-
setClonedChildren([]);
|
|
1526
|
-
sliderWidth.current = 0;
|
|
1527
|
-
layoutRef.current = null;
|
|
1528
|
-
setWrapSafe(false);
|
|
1529
|
-
slidesRef.current = [];
|
|
1530
|
-
setSlidesState([]);
|
|
1531
|
-
cellToSlideRef.current = [];
|
|
1532
|
-
return;
|
|
1533
|
-
}
|
|
1534
|
-
const allEls = Array.from(el.children);
|
|
1535
|
-
const clonesBefore = clonesCountRef.current;
|
|
1536
|
-
const clonesAfter = clonesBefore;
|
|
1537
|
-
const originalEls = allEls.slice(clonesBefore, allEls.length - clonesAfter);
|
|
1538
|
-
const cw = el[AX.clientKey];
|
|
1539
|
-
let sum = 0;
|
|
1540
|
-
let count2 = 0;
|
|
1541
|
-
for (const slot of originalEls) {
|
|
1542
|
-
const w = slot.getBoundingClientRect()[AX.sizeKey];
|
|
1543
|
-
if (w === 0) {
|
|
1544
|
-
requestAnimationFrame(() => ro.observe(el));
|
|
1545
|
-
return;
|
|
1546
|
-
}
|
|
1547
|
-
if (sum + w <= cw) {
|
|
1548
|
-
sum += w;
|
|
1549
|
-
count2++;
|
|
1550
|
-
} else {
|
|
1551
|
-
count2++;
|
|
1552
|
-
break;
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1555
|
-
const per = Math.max(2, Math.min(originals, count2));
|
|
1556
|
-
const shouldLoop = wrap;
|
|
1557
|
-
clonesCountRef.current = shouldLoop ? per : 0;
|
|
1558
|
-
if (visibleThumbsRef.current !== per) visibleThumbsRef.current = per;
|
|
1559
|
-
const sig = computeCloneSig(originals, per);
|
|
1560
|
-
if (sig === lastCloneSigRef.current) return;
|
|
1561
|
-
lastCloneSigRef.current = sig;
|
|
1562
|
-
const slides = [];
|
|
1563
|
-
thumbCells.current = [];
|
|
1564
|
-
if (shouldLoop) {
|
|
1565
|
-
slides.push(
|
|
1566
|
-
...rawKids2.slice(-per).map((c, i) => {
|
|
1567
|
-
const canonicalIndex = originals - per + i;
|
|
1568
|
-
const elementIndex = -per + i;
|
|
1569
|
-
return cloneThumb(c, `before-${i}`, canonicalIndex, elementIndex);
|
|
1570
|
-
})
|
|
1571
|
-
);
|
|
1572
|
-
}
|
|
1573
|
-
slides.push(
|
|
1574
|
-
...rawKids2.map((c, i) => {
|
|
1575
|
-
const canonicalIndex = i;
|
|
1576
|
-
const elementIndex = i;
|
|
1577
|
-
return cloneThumb(c, `original-${i}`, canonicalIndex, elementIndex);
|
|
1578
|
-
})
|
|
1579
|
-
);
|
|
1580
|
-
if (shouldLoop) {
|
|
1581
|
-
slides.push(
|
|
1582
|
-
...rawKids2.slice(0, per).map((c, i) => {
|
|
1583
|
-
const canonicalIndex = i;
|
|
1584
|
-
const elementIndex = i;
|
|
1585
|
-
return cloneThumb(c, `after-${i}`, canonicalIndex, elementIndex);
|
|
1586
|
-
})
|
|
1587
|
-
);
|
|
1588
|
-
}
|
|
1589
|
-
setClonedChildren(slides);
|
|
1590
|
-
});
|
|
1591
|
-
ro.observe(el);
|
|
1592
|
-
return () => ro.disconnect();
|
|
1593
|
-
}, [
|
|
1594
|
-
children,
|
|
1595
|
-
buildKey,
|
|
1596
|
-
wrap,
|
|
1597
|
-
gap,
|
|
1598
|
-
thumbSize,
|
|
1599
|
-
thumbLong,
|
|
1600
|
-
thumbnailWidth,
|
|
1601
|
-
thumbnailHeight,
|
|
1602
|
-
thumbnailItemClassName,
|
|
1603
|
-
thumbnailItemStyle,
|
|
1604
|
-
position
|
|
1605
|
-
]);
|
|
1606
|
-
function getThumbIndexFromEventTarget(t) {
|
|
1607
|
-
const track = trackRef.current;
|
|
1608
|
-
if (!track) return -1;
|
|
1609
|
-
const el = t;
|
|
1610
|
-
if (!el) return -1;
|
|
1611
|
-
const thumbEl = el.closest?.("[data-rmg-thumb-index]");
|
|
1612
|
-
if (!thumbEl) return -1;
|
|
1613
|
-
if (!track.contains(thumbEl)) return -1;
|
|
1614
|
-
const raw = thumbEl.getAttribute("data-rmg-thumb-index");
|
|
1615
|
-
const idx = raw != null ? parseInt(raw, 10) : -1;
|
|
1616
|
-
return Number.isFinite(idx) ? idx : -1;
|
|
1617
|
-
}
|
|
1618
|
-
function commitThumbSelect(i) {
|
|
1619
|
-
if (i < 0 || i >= count) return;
|
|
1620
|
-
snapModeRef.current = "thumb";
|
|
1621
|
-
setActiveThumb(i);
|
|
1622
|
-
channelRef.current.set(i, "animated");
|
|
1623
|
-
onSelectThumb?.(i);
|
|
1624
|
-
}
|
|
1625
|
-
useEffect(() => {
|
|
1626
|
-
if (!thumbnailsCenter) {
|
|
1627
|
-
baseOffsetRef.current = 0;
|
|
1628
|
-
return;
|
|
1629
|
-
}
|
|
1630
|
-
if (!contentLength || !containerLength) return;
|
|
1631
|
-
if (contentLength <= containerLength) {
|
|
1632
|
-
baseOffsetRef.current = (containerLength - contentLength) / 2;
|
|
1633
|
-
} else {
|
|
1634
|
-
baseOffsetRef.current = 0;
|
|
1635
|
-
}
|
|
1636
|
-
}, [thumbnailsCenter, contentLength, containerLength]);
|
|
1637
|
-
useEffect(() => {
|
|
1638
|
-
const track = trackRef.current;
|
|
1639
|
-
const container = containerRef.current;
|
|
1640
|
-
if (!track || !container) return;
|
|
1641
|
-
const schedule = () => {
|
|
1642
|
-
measureAndPosition();
|
|
1643
|
-
};
|
|
1644
|
-
function measureAndPosition() {
|
|
1645
|
-
const trackEl = trackRef.current;
|
|
1646
|
-
const container2 = containerRef.current;
|
|
1647
|
-
if (!trackEl || !container2) return;
|
|
1648
|
-
const slideEls = Array.from(trackEl.children);
|
|
1649
|
-
if (slideEls.length === 0) return;
|
|
1650
|
-
const sizes = slideEls.map((sl) => sl.getBoundingClientRect()[AX.sizeKey]);
|
|
1651
|
-
if (sizes.some((s) => s === 0)) {
|
|
1652
|
-
setTimeout(measureAndPosition, 0);
|
|
1653
|
-
return;
|
|
1654
|
-
}
|
|
1655
|
-
const contentSize = AX.main === "x" ? trackEl.scrollWidth : trackEl.scrollHeight;
|
|
1656
|
-
const clonesBefore = clonesCountRef.current;
|
|
1657
|
-
const beforeSizes = sizes.slice(0, clonesBefore);
|
|
1658
|
-
let running = -(beforeSizes.reduce((s, w) => s + w, 0) + gap * clonesBefore);
|
|
1659
|
-
slideEls.forEach((sl, i) => {
|
|
1660
|
-
sl.style.transformOrigin = "center";
|
|
1661
|
-
sl.style.transform = AX.place(running * sign);
|
|
1662
|
-
running += sizes[i] + gap;
|
|
1663
|
-
});
|
|
1664
|
-
const origSizes = sizes.slice(clonesBefore, sizes.length - clonesBefore);
|
|
1665
|
-
let m0 = 0;
|
|
1666
|
-
const originalsForLayout = slideEls.slice(clonesBefore, slideEls.length - clonesBefore).map((sl, i) => {
|
|
1667
|
-
const s = origSizes[i];
|
|
1668
|
-
const start = m0;
|
|
1669
|
-
const end = m0 + s;
|
|
1670
|
-
m0 += s + gap;
|
|
1671
|
-
return { el: sl, start, end, size: s };
|
|
1672
|
-
});
|
|
1673
|
-
layoutRef.current = {
|
|
1674
|
-
originals: originalsForLayout,
|
|
1675
|
-
cw: trackEl[AX.clientKey]
|
|
1676
|
-
};
|
|
1677
|
-
const originalsCount = layoutRef.current?.originals?.length ?? 0;
|
|
1678
|
-
const innerGaps = Math.max(0, originalsCount - 1);
|
|
1679
|
-
const baseWidth = origSizes.reduce((sum, s) => sum + s, 0) + gap * innerGaps;
|
|
1680
|
-
sliderWidth.current = wrap ? baseWidth + (originalsCount > 0 ? gap : 0) : baseWidth;
|
|
1681
|
-
const cw = trackEl[AX.clientKey];
|
|
1682
|
-
setContentLength(sliderWidth.current);
|
|
1683
|
-
setContainerLength(cw);
|
|
1684
|
-
const first = originalsForLayout[0]?.el;
|
|
1685
|
-
if (first) {
|
|
1686
|
-
const r = first.getBoundingClientRect();
|
|
1687
|
-
const long = r[AX.sizeKey];
|
|
1688
|
-
const cross = AX.main === "x" ? r.height : r.width;
|
|
1689
|
-
setThumbLong(long || thumbSize || 0);
|
|
1690
|
-
setThumbCross(cross || 0);
|
|
1691
|
-
}
|
|
1692
|
-
const wantLoop = !!loop && originalsCount > 1 && contentSize > cw;
|
|
1693
|
-
const origSizesCsv = originalsForLayout.map((o) => o.size).join(",");
|
|
1694
|
-
const sig = `${origSizesCsv}|gap=${gap}|cw=${cw}|W=${contentSize}`;
|
|
1695
|
-
if (sig !== lastGeomSigRef.current) {
|
|
1696
|
-
lastGeomSigRef.current = sig;
|
|
1697
|
-
setGeomKey((k) => k + 1);
|
|
1698
|
-
}
|
|
1699
|
-
setWrapSafe(wantLoop);
|
|
1700
|
-
setIsMeasured(true);
|
|
1701
|
-
}
|
|
1702
|
-
const ro = new ResizeObserver(schedule);
|
|
1703
|
-
ro.observe(track);
|
|
1704
|
-
ro.observe(container);
|
|
1705
|
-
const vv = typeof window !== "undefined" ? window.visualViewport : null;
|
|
1706
|
-
vv?.addEventListener("resize", schedule);
|
|
1707
|
-
window.addEventListener("resize", schedule, { passive: true });
|
|
1708
|
-
schedule();
|
|
1709
|
-
return () => {
|
|
1710
|
-
ro.disconnect();
|
|
1711
|
-
vv?.removeEventListener("resize", schedule);
|
|
1712
|
-
window.removeEventListener("resize", schedule);
|
|
1713
|
-
};
|
|
1714
|
-
}, [clonedChildren, gap, wrap, loop, AX, sign, position]);
|
|
1715
|
-
useEffect(() => {
|
|
1716
|
-
readyPaintedRef.current = false;
|
|
1717
|
-
setIsReady(false);
|
|
1718
|
-
if (readyRafRef.current != null) {
|
|
1719
|
-
cancelAnimationFrame(readyRafRef.current);
|
|
1720
|
-
readyRafRef.current = null;
|
|
1721
|
-
}
|
|
1722
|
-
const root2 = containerRef.current;
|
|
1723
|
-
const track = trackRef.current;
|
|
1724
|
-
const canBeReady = !!root2 && !!track && isMeasured && layoutReady && sliderWidth.current > 0 && slidesRef.current.length > 0 && !!(thumbSize || thumbLong);
|
|
1725
|
-
if (!canBeReady) return;
|
|
1726
|
-
readyRafRef.current = requestAnimationFrame(() => {
|
|
1727
|
-
readyRafRef.current = requestAnimationFrame(() => {
|
|
1728
|
-
readyPaintedRef.current = true;
|
|
1729
|
-
setIsReady(true);
|
|
1730
|
-
readyRafRef.current = null;
|
|
1731
|
-
});
|
|
1732
|
-
});
|
|
1733
|
-
return () => {
|
|
1734
|
-
if (readyRafRef.current != null) {
|
|
1735
|
-
cancelAnimationFrame(readyRafRef.current);
|
|
1736
|
-
readyRafRef.current = null;
|
|
1737
|
-
}
|
|
1738
|
-
};
|
|
1739
|
-
}, [
|
|
1740
|
-
isMeasured,
|
|
1741
|
-
layoutReady,
|
|
1742
|
-
geomKey,
|
|
1743
|
-
buildKey,
|
|
1744
|
-
wrap,
|
|
1745
|
-
count,
|
|
1746
|
-
contentLength,
|
|
1747
|
-
containerLength,
|
|
1748
|
-
thumbLong,
|
|
1749
|
-
thumbSize,
|
|
1750
|
-
position
|
|
1751
|
-
]);
|
|
1752
|
-
const getSnapTargets = () => (slidesRef.current || []).map((s) => s.target);
|
|
1753
|
-
const totalWidth = () => sliderWidth.current || 0;
|
|
1754
|
-
useEffect(() => {
|
|
1755
|
-
const containerEl = trackRef.current;
|
|
1756
|
-
if (!containerEl) return;
|
|
1757
|
-
let canceled = false;
|
|
1758
|
-
let retryTimer = null;
|
|
1759
|
-
let tries = 0;
|
|
1760
|
-
const MAX_TRIES = 5;
|
|
1761
|
-
function retry() {
|
|
1762
|
-
if (canceled) return;
|
|
1763
|
-
if (tries++ >= MAX_TRIES) return;
|
|
1764
|
-
if (retryTimer != null) window.clearTimeout(retryTimer);
|
|
1765
|
-
retryTimer = window.setTimeout(() => {
|
|
1766
|
-
buildPages();
|
|
1767
|
-
}, 0);
|
|
1768
|
-
}
|
|
1769
|
-
const rawKids2 = Children.toArray(children).filter(isValidElement);
|
|
1770
|
-
const childCount = rawKids2.length;
|
|
1771
|
-
const clonesBefore = wrap ? visibleThumbsRef.current : 0;
|
|
1772
|
-
const clonesAfter = clonesBefore;
|
|
1773
|
-
const cw = containerEl[AX.clientKey];
|
|
1774
|
-
function buildPages() {
|
|
1775
|
-
if (canceled || !containerEl) return;
|
|
1776
|
-
const allEls = Array.from(containerEl.children);
|
|
1777
|
-
const originals = allEls.slice(clonesBefore, allEls.length - clonesAfter);
|
|
1778
|
-
const idxMap = new Map(originals.map((el, i2) => [el, i2]));
|
|
1779
|
-
const start0 = containerEl.getBoundingClientRect()[AX.startKey];
|
|
1780
|
-
const data = originals.map((el) => {
|
|
1781
|
-
const r = el.getBoundingClientRect();
|
|
1782
|
-
return {
|
|
1783
|
-
el,
|
|
1784
|
-
start: r[AX.startKey] - start0,
|
|
1785
|
-
end: r[AX.endKey] - start0
|
|
1786
|
-
};
|
|
1787
|
-
});
|
|
1788
|
-
const pages = [];
|
|
1789
|
-
let i = 0;
|
|
1790
|
-
if (groupCells) {
|
|
1791
|
-
while (i < childCount) {
|
|
1792
|
-
const startLeft = data[i]?.start ?? 0;
|
|
1793
|
-
const viewRight = startLeft + cw;
|
|
1794
|
-
let j = i;
|
|
1795
|
-
while (j < childCount && (data[j]?.end ?? 0) <= viewRight) j++;
|
|
1796
|
-
if (j === i) j++;
|
|
1797
|
-
const slice = originals.slice(i, j);
|
|
1798
|
-
const isLast = j >= childCount;
|
|
1799
|
-
let target = startLeft;
|
|
1800
|
-
if (isLast && !wrap) {
|
|
1801
|
-
target = Math.max(0, (sliderWidth.current || 0) - cw);
|
|
1802
|
-
}
|
|
1803
|
-
if (i === 0) target = 0;
|
|
1804
|
-
pages.push({ els: slice, target });
|
|
1805
|
-
i = j;
|
|
1806
|
-
}
|
|
1807
|
-
} else {
|
|
1808
|
-
const L = layoutRef.current;
|
|
1809
|
-
if (!L || !L.originals?.length) {
|
|
1810
|
-
retry();
|
|
1811
|
-
return;
|
|
1812
|
-
}
|
|
1813
|
-
const data2 = L.originals;
|
|
1814
|
-
const cw2 = L.cw;
|
|
1815
|
-
const maxTarget = Math.max(0, (sliderWidth.current || 0) - cw2);
|
|
1816
|
-
const EPS = 0.5;
|
|
1817
|
-
if (wrap) {
|
|
1818
|
-
data2.forEach((d, idx) => {
|
|
1819
|
-
const t = idx === 0 ? 0 : d.start;
|
|
1820
|
-
pages.push({ els: [d.el], target: t });
|
|
1821
|
-
});
|
|
1822
|
-
} else {
|
|
1823
|
-
for (let idx = 0; idx < data2.length; idx++) {
|
|
1824
|
-
const d = data2[idx];
|
|
1825
|
-
let t = idx === 0 ? 0 : d.start;
|
|
1826
|
-
t = Math.min(t, maxTarget);
|
|
1827
|
-
if (!pages.length || Math.abs(t - pages[pages.length - 1].target) > EPS) {
|
|
1828
|
-
pages.push({ els: [d.el], target: t });
|
|
1829
|
-
}
|
|
1830
|
-
if (Math.abs(t - maxTarget) <= EPS) break;
|
|
1831
|
-
}
|
|
1832
|
-
const winStart = maxTarget - EPS;
|
|
1833
|
-
const winEnd = maxTarget + cw2 + EPS;
|
|
1834
|
-
const lastEls = data2.filter((d) => d.start < winEnd && d.end > winStart).map((d) => d.el);
|
|
1835
|
-
if (lastEls.length) {
|
|
1836
|
-
const lastT = pages[pages.length - 1]?.target ?? -1;
|
|
1837
|
-
if (Math.abs(lastT - maxTarget) > EPS) {
|
|
1838
|
-
pages.push({ els: lastEls, target: maxTarget });
|
|
1839
|
-
} else {
|
|
1840
|
-
const uniq = new Set(pages[pages.length - 1].els.concat(lastEls));
|
|
1841
|
-
pages[pages.length - 1].els = Array.from(uniq);
|
|
1842
|
-
}
|
|
1843
|
-
} else {
|
|
1844
|
-
let safeIdx = -1;
|
|
1845
|
-
for (let i2 = data2.length - 1; i2 >= 0; i2--) {
|
|
1846
|
-
if (data2[i2].start <= maxTarget + EPS) {
|
|
1847
|
-
safeIdx = i2;
|
|
1848
|
-
break;
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
const fallback = data2[Math.max(0, safeIdx)];
|
|
1852
|
-
if (fallback) {
|
|
1853
|
-
const lastT = pages[pages.length - 1]?.target ?? -1;
|
|
1854
|
-
if (Math.abs(lastT - maxTarget) > EPS) {
|
|
1855
|
-
pages.push({ els: [fallback.el], target: maxTarget });
|
|
1856
|
-
}
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
}
|
|
1861
|
-
const newSlides = pages.map((page) => ({
|
|
1862
|
-
target: page.target,
|
|
1863
|
-
cells: page.els.map((el) => ({
|
|
1864
|
-
element: el,
|
|
1865
|
-
index: idxMap.get(el)
|
|
1866
|
-
}))
|
|
1867
|
-
}));
|
|
1868
|
-
const hasNaN = newSlides.some((s) => Number.isNaN(s.target));
|
|
1869
|
-
const unstable = hasNaN || wrap && newSlides.length === 1;
|
|
1870
|
-
if (unstable) {
|
|
1871
|
-
retry();
|
|
1872
|
-
return;
|
|
1873
|
-
}
|
|
1874
|
-
const pagesAllowLoop = newSlides.length > 1;
|
|
1875
|
-
setWrap(!!loop && pagesAllowLoop && sliderWidth.current > cw);
|
|
1876
|
-
isWrapping.current = !!loop && pagesAllowLoop && sliderWidth.current > cw;
|
|
1877
|
-
slidesRef.current = newSlides;
|
|
1878
|
-
setSlidesState(newSlides);
|
|
1879
|
-
setLayoutReady(true);
|
|
1880
|
-
const map = [];
|
|
1881
|
-
newSlides.forEach((s, slideIdx) => {
|
|
1882
|
-
s.cells.forEach((c) => {
|
|
1883
|
-
map[c.index] = slideIdx;
|
|
1884
|
-
});
|
|
1885
|
-
});
|
|
1886
|
-
cellToSlideRef.current = map;
|
|
1887
|
-
}
|
|
1888
|
-
buildPages();
|
|
1889
|
-
return () => {
|
|
1890
|
-
canceled = true;
|
|
1891
|
-
if (retryTimer != null) window.clearTimeout(retryTimer);
|
|
1892
|
-
};
|
|
1893
|
-
}, [clonedChildren, geomKey, position]);
|
|
1894
|
-
function getPageForIndex(i) {
|
|
1895
|
-
const pages = pagesRef.current;
|
|
1896
|
-
if (!pages.length) return null;
|
|
1897
|
-
for (let p = 0; p < pages.length; p++) {
|
|
1898
|
-
const pg = pages[p];
|
|
1899
|
-
if (i >= pg.startIndex && i < pg.endIndex) return pg;
|
|
1900
|
-
}
|
|
1901
|
-
return pages[pages.length - 1] ?? null;
|
|
1902
|
-
}
|
|
1903
|
-
function getScrollForIndex(i) {
|
|
1904
|
-
if (centerActiveThumb) return getCenterScroll(i);
|
|
1905
|
-
if (groupCells && !freeScroll && snapModeRef.current === "thumb") {
|
|
1906
|
-
const pg = getPageForIndex(i);
|
|
1907
|
-
if (pg) return pg.targetScroll;
|
|
1908
|
-
}
|
|
1909
|
-
return snapModeRef.current === "thumb" ? getStartSnapScroll(i) : getCenteredScroll(i);
|
|
1910
|
-
}
|
|
1911
|
-
function setActiveThumb(i) {
|
|
1912
|
-
const track = trackRef.current;
|
|
1913
|
-
if (!track) return;
|
|
1914
|
-
const kids = Array.from(track.children);
|
|
1915
|
-
for (const el of kids) el.removeAttribute("data-active");
|
|
1916
|
-
const key = String(i);
|
|
1917
|
-
const matches = track.querySelectorAll(`[data-rmg-thumb-index="${CSS.escape(key)}"]`);
|
|
1918
|
-
matches.forEach((el) => el.setAttribute("data-active", "true"));
|
|
1919
|
-
prevActiveRef.current = i;
|
|
1920
|
-
}
|
|
1921
|
-
function ensureDragStyle(scopeId2) {
|
|
1922
|
-
const id = "rmg-drag-style-" + scopeId2;
|
|
1923
|
-
if (document.getElementById(id)) return;
|
|
1924
|
-
const style2 = document.createElement("style");
|
|
1925
|
-
style2.id = id;
|
|
1926
|
-
style2.textContent = `
|
|
1927
|
-
/* Only while data-rmg-drag is present on this slider root */
|
|
1928
|
-
#${scopeId2}[data-rmg-drag] { cursor: grabbing !important; }
|
|
1929
|
-
#${scopeId2}[data-rmg-drag] * { cursor: grabbing !important; }
|
|
1930
|
-
`;
|
|
1931
|
-
document.head.appendChild(style2);
|
|
1932
|
-
}
|
|
1933
|
-
useEffect(() => {
|
|
1934
|
-
if (containerRef.current) ensureDragStyle(scopeId);
|
|
1935
|
-
}, [containerRef.current, scopeId]);
|
|
1936
|
-
function setDragCursor(on) {
|
|
1937
|
-
const root2 = containerRef.current;
|
|
1938
|
-
if (!root2) return;
|
|
1939
|
-
if (on) {
|
|
1940
|
-
if (!root2.hasAttribute(draggingAttr)) root2.setAttribute(draggingAttr, "");
|
|
1941
|
-
return;
|
|
1942
|
-
}
|
|
1943
|
-
if (root2.hasAttribute(draggingAttr)) root2.removeAttribute(draggingAttr);
|
|
1944
|
-
activePointerIdRef.current = null;
|
|
1945
|
-
guardsStoreRef.current?.clear();
|
|
1946
|
-
guardsStoreRef.current = null;
|
|
1947
|
-
}
|
|
1948
|
-
useEffect(() => {
|
|
1949
|
-
const root2 = containerRef.current;
|
|
1950
|
-
if (!root2) return;
|
|
1951
|
-
const onLeave = () => {
|
|
1952
|
-
if (pointerDownRef.current) setDragCursor(false);
|
|
1953
|
-
};
|
|
1954
|
-
const onEnter = () => {
|
|
1955
|
-
if (pointerDownRef.current && activePointerIdRef.current != null) setDragCursor(true);
|
|
1956
|
-
};
|
|
1957
|
-
root2.addEventListener("mouseleave", onLeave, { passive: true });
|
|
1958
|
-
root2.addEventListener("mouseenter", onEnter, { passive: true });
|
|
1959
|
-
return () => {
|
|
1960
|
-
root2.removeEventListener("mouseleave", onLeave);
|
|
1961
|
-
root2.removeEventListener("mouseenter", onEnter);
|
|
1962
|
-
};
|
|
1963
|
-
}, []);
|
|
1964
|
-
useEffect(() => {
|
|
1965
|
-
const ch = channelRef.current;
|
|
1966
|
-
const unsub = ch.subscribe(() => {
|
|
1967
|
-
const { index, mode } = ch.get();
|
|
1968
|
-
selectedIndexRef.current = clamp(index, 0, Math.max(0, count - 1));
|
|
1969
|
-
setActiveThumb(selectedIndexRef.current);
|
|
1970
|
-
if (pointerDownRef.current) return;
|
|
1971
|
-
snapModeRef.current = "base";
|
|
1972
|
-
const scroll = getScrollForIndex(selectedIndexRef.current);
|
|
1973
|
-
if (mode === "instant") {
|
|
1974
|
-
bodyRef.current?.useDuration(0).useFriction(1);
|
|
1975
|
-
setTargetToScroll(scroll);
|
|
1976
|
-
animRef.current?.start();
|
|
1977
|
-
} else {
|
|
1978
|
-
animateToScroll(scroll);
|
|
1979
|
-
}
|
|
1980
|
-
});
|
|
1981
|
-
return unsub;
|
|
1982
|
-
}, [count, thumbnailsCenter, contentLength, containerLength]);
|
|
1983
|
-
useEffect(() => {
|
|
1984
|
-
const track = trackRef.current;
|
|
1985
|
-
if (!track) return;
|
|
1986
|
-
const ready = !!(contentLength && containerLength && (thumbSize || thumbLong));
|
|
1987
|
-
if (!ready) return;
|
|
1988
|
-
const maxIndex = Math.max(0, (track.children.length || count) - 1);
|
|
1989
|
-
const init = clamp(channelRef.current.get().index ?? 0, 0, maxIndex);
|
|
1990
|
-
setActiveThumb(init);
|
|
1991
|
-
animateToScroll(getScrollForIndex(init));
|
|
1992
|
-
}, [count, contentLength, containerLength, thumbLong, thumbSize]);
|
|
1993
|
-
function getCenteredScroll(i) {
|
|
1994
|
-
const lay = layoutRef.current;
|
|
1995
|
-
if (!lay?.originals?.length) return 0;
|
|
1996
|
-
const o = lay.originals[i];
|
|
1997
|
-
if (!o) return 0;
|
|
1998
|
-
const view = lay.cw || containerLength || 0;
|
|
1999
|
-
const size = o.size;
|
|
2000
|
-
const centerWanted = o.start - (view - size) / 2;
|
|
2001
|
-
const maxScroll = Math.max(0, contentLength - view);
|
|
2002
|
-
return clamp(centerWanted, 0, maxScroll);
|
|
2003
|
-
}
|
|
2004
|
-
function getStartSnapScroll(i) {
|
|
2005
|
-
const lay = layoutRef.current;
|
|
2006
|
-
if (!lay?.originals?.length) return 0;
|
|
2007
|
-
const o = lay.originals[i];
|
|
2008
|
-
if (!o) return 0;
|
|
2009
|
-
const view = lay.cw || containerLength || 0;
|
|
2010
|
-
const maxScroll = Math.max(0, contentLength - view);
|
|
2011
|
-
return clamp(o.start, 0, maxScroll);
|
|
2012
|
-
}
|
|
2013
|
-
function animateToScroll(scroll) {
|
|
2014
|
-
const isNarrow = thumbnailsCenter && contentLength <= containerLength;
|
|
2015
|
-
if (isNarrow) return;
|
|
2016
|
-
bodyRef.current?.useBaseDuration().useBaseFriction();
|
|
2017
|
-
setTargetToScroll(scroll);
|
|
2018
|
-
animRef.current?.start();
|
|
2019
|
-
}
|
|
2020
|
-
function indexFromX(loc) {
|
|
2021
|
-
const x = -loc;
|
|
2022
|
-
const targets = getSnapTargets();
|
|
2023
|
-
const W = totalWidth();
|
|
2024
|
-
if (!targets.length) return 0;
|
|
2025
|
-
let best = 0;
|
|
2026
|
-
let min = Infinity;
|
|
2027
|
-
for (let i = 0; i < targets.length; i++) {
|
|
2028
|
-
const base = targets[i];
|
|
2029
|
-
const candidates = !W || !wrap ? [base] : [base, base + W, base - W];
|
|
2030
|
-
for (const c of candidates) {
|
|
2031
|
-
const d = Math.abs(c - x);
|
|
2032
|
-
if (d < min) {
|
|
2033
|
-
min = d;
|
|
2034
|
-
best = i;
|
|
2035
|
-
}
|
|
2036
|
-
}
|
|
2037
|
-
}
|
|
2038
|
-
return best;
|
|
2039
|
-
}
|
|
2040
|
-
function positionSlider() {
|
|
2041
|
-
const base = baseOffsetRef.current || 0;
|
|
2042
|
-
const x = xRef.current || 0;
|
|
2043
|
-
translateRef.current?.to((x + base) * sign);
|
|
2044
|
-
}
|
|
2045
|
-
function updateActiveIndexFromX(loc) {
|
|
2046
|
-
const indexCurrent = indexCurrentRef.current;
|
|
2047
|
-
if (!indexCurrent) return;
|
|
2048
|
-
const idxFromLoc = indexFromX(loc);
|
|
2049
|
-
const canonical = indexCurrent.get();
|
|
2050
|
-
if (idxFromLoc === canonical) return;
|
|
2051
|
-
if (!pointerDownRef.current && isAnimatingRef.current) {
|
|
2052
|
-
return;
|
|
2053
|
-
}
|
|
2054
|
-
indexCurrent.set(idxFromLoc);
|
|
2055
|
-
selectedIndexRef.current = idxFromLoc;
|
|
2056
|
-
}
|
|
2057
|
-
function scrollToIndex(requested, opts = {}) {
|
|
2058
|
-
const { jump = false, direction: direction2 } = opts;
|
|
2059
|
-
const indexCurrent = indexCurrentRef.current;
|
|
2060
|
-
if (!scrollToRef.current || !bodyRef.current || !indexCurrent) return;
|
|
2061
|
-
const targetIndex = indexCurrent.clone().set(requested).get();
|
|
2062
|
-
if (jump) {
|
|
2063
|
-
bodyRef.current.useDuration(0);
|
|
2064
|
-
} else {
|
|
2065
|
-
bodyRef.current.useBaseDuration().useBaseFriction();
|
|
2066
|
-
}
|
|
2067
|
-
const dir = typeof direction2 === "number" ? direction2 : 0;
|
|
2068
|
-
scrollToRef.current.index(targetIndex, dir);
|
|
2069
|
-
}
|
|
2070
|
-
function clampIndex(i, len) {
|
|
2071
|
-
return Math.max(0, Math.min(len - 1, i));
|
|
2072
|
-
}
|
|
2073
|
-
function previous() {
|
|
2074
|
-
const scrollTo = scrollToRef.current;
|
|
2075
|
-
const body = bodyRef.current;
|
|
2076
|
-
const indexCur = indexCurrentRef.current;
|
|
2077
|
-
const len = slidesRef.current?.length ?? 0;
|
|
2078
|
-
if (!scrollTo || !body || !indexCur || !len) return;
|
|
2079
|
-
const cur = indexCur.get();
|
|
2080
|
-
const target = wrap ? ((cur - 1) % len + len) % len : clampIndex(cur - 1, len);
|
|
2081
|
-
body.useBaseDuration().useBaseFriction();
|
|
2082
|
-
scrollToIndex(target, { direction: 1 });
|
|
2083
|
-
}
|
|
2084
|
-
function next() {
|
|
2085
|
-
const scrollTo = scrollToRef.current;
|
|
2086
|
-
const body = bodyRef.current;
|
|
2087
|
-
const indexCur = indexCurrentRef.current;
|
|
2088
|
-
const len = slidesRef.current?.length ?? 0;
|
|
2089
|
-
if (!scrollTo || !body || !indexCur || !len) return;
|
|
2090
|
-
const cur = indexCur.get();
|
|
2091
|
-
const target = wrap ? ((cur + 1) % len + len) % len : clampIndex(cur + 1, len);
|
|
2092
|
-
body.useBaseDuration().useBaseFriction();
|
|
2093
|
-
scrollToIndex(target, { direction: -1 });
|
|
2094
|
-
}
|
|
2095
|
-
useEffect(() => {
|
|
2096
|
-
const root2 = containerRef.current;
|
|
2097
|
-
const track = trackRef.current;
|
|
2098
|
-
if (!root2 || !track || !slidesRef.current?.length || !layoutReady || !isMeasured || sliderWidth.current === 0) {
|
|
2099
|
-
return;
|
|
2100
|
-
}
|
|
2101
|
-
const isNarrow = !wrap && thumbnailsCenter && contentLength <= containerLength;
|
|
2102
|
-
const base = isNarrow ? (containerLength - contentLength) / 2 : 0;
|
|
2103
|
-
baseOffsetRef.current = base;
|
|
2104
|
-
const startIdx = selectedIndexRef.current || 0;
|
|
2105
|
-
const location = Vector1D(0);
|
|
2106
|
-
const previousLocation = Vector1D(0);
|
|
2107
|
-
const offsetLocation = Vector1D(0);
|
|
2108
|
-
const target = Vector1D(0);
|
|
2109
|
-
locationRef.current = location;
|
|
2110
|
-
previousLocationRef.current = previousLocation;
|
|
2111
|
-
offsetLocationRef.current = offsetLocation;
|
|
2112
|
-
targetRef.current = target;
|
|
2113
|
-
const W = sliderWidth.current || 0;
|
|
2114
|
-
const len = slidesRef.current.length || 1;
|
|
2115
|
-
const counterMax = len - 1;
|
|
2116
|
-
const startIndex = selectedIndexRef.current || 0;
|
|
2117
|
-
const indexCurrent = Counter(counterMax, startIndex, true);
|
|
2118
|
-
const indexPrevious = Counter(counterMax, startIndex, true);
|
|
2119
|
-
indexCurrentRef.current = indexCurrent;
|
|
2120
|
-
indexPreviousRef.current = indexPrevious;
|
|
2121
|
-
contentSizeRef.current = W;
|
|
2122
|
-
scrollContentSizeRef.current = W;
|
|
2123
|
-
const scrollSnaps = slidesRef.current.map((slide) => {
|
|
2124
|
-
return -slide.target;
|
|
2125
|
-
});
|
|
2126
|
-
scrollSnapsRef.current = scrollSnaps;
|
|
2127
|
-
const initialSnap = scrollSnaps[startIdx] ?? 0;
|
|
2128
|
-
location.set(initialSnap);
|
|
2129
|
-
previousLocation.set(initialSnap);
|
|
2130
|
-
offsetLocation.set(initialSnap);
|
|
2131
|
-
target.set(initialSnap);
|
|
2132
|
-
xRef.current = initialSnap;
|
|
2133
|
-
translateRef.current = Translate(track, AX);
|
|
2134
|
-
translateRef.current?.to((initialSnap + base) * sign);
|
|
2135
|
-
selectedIndexRef.current = startIdx;
|
|
2136
|
-
const minSnap = Math.min(...scrollSnaps);
|
|
2137
|
-
const maxSnap = Math.max(...scrollSnaps);
|
|
2138
|
-
loopLimitRef.current = wrap ? Limit(-W, 0) : Limit(minSnap, maxSnap);
|
|
2139
|
-
const baseLimit = wrap ? createBaseLimit(-W, 0) : createBaseLimit(minSnap, maxSnap);
|
|
2140
|
-
scrollLimitRef.current = baseLimit;
|
|
2141
|
-
if (loopLimitRef.current) {
|
|
2142
|
-
scrollTargetRef.current = ScrollTarget(
|
|
2143
|
-
wrap,
|
|
2144
|
-
scrollSnaps,
|
|
2145
|
-
W,
|
|
2146
|
-
loopLimitRef.current,
|
|
2147
|
-
target
|
|
2148
|
-
);
|
|
2149
|
-
}
|
|
2150
|
-
function scrollTo(target2) {
|
|
2151
|
-
const indexCurrent2 = indexCurrentRef.current;
|
|
2152
|
-
const indexPrevious2 = indexPreviousRef.current;
|
|
2153
|
-
if (!indexCurrent2 || !indexPrevious2) return;
|
|
2154
|
-
const distanceDiff = target2.distance;
|
|
2155
|
-
const indexDiff = target2.index !== indexCurrent2.get();
|
|
2156
|
-
targetRef.current.add(distanceDiff);
|
|
2157
|
-
if (distanceDiff) {
|
|
2158
|
-
if (bodyRef.current.duration()) {
|
|
2159
|
-
isAnimatingRef.current = true;
|
|
2160
|
-
animRef.current.start();
|
|
2161
|
-
} else {
|
|
2162
|
-
bodyRef.current.seek();
|
|
2163
|
-
positionSlider();
|
|
2164
|
-
}
|
|
2165
|
-
}
|
|
2166
|
-
if (indexDiff) {
|
|
2167
|
-
indexPrevious2.set(indexCurrent2.get());
|
|
2168
|
-
indexCurrent2.set(target2.index);
|
|
2169
|
-
const idx = indexCurrent2.get();
|
|
2170
|
-
selectedIndexRef.current = idx;
|
|
2171
|
-
setActiveThumb(idx);
|
|
2172
|
-
}
|
|
2173
|
-
}
|
|
2174
|
-
const baseScrollTo = {
|
|
2175
|
-
distance(n, snap) {
|
|
2176
|
-
const st = scrollTargetRef.current;
|
|
2177
|
-
if (!st) return;
|
|
2178
|
-
const target2 = st.byDistance(n, snap);
|
|
2179
|
-
scrollTo(target2);
|
|
2180
|
-
},
|
|
2181
|
-
index(n, direction2) {
|
|
2182
|
-
const st = scrollTargetRef.current;
|
|
2183
|
-
const indexCurrent2 = indexCurrentRef.current;
|
|
2184
|
-
if (!st || !indexCurrent2) return;
|
|
2185
|
-
const targetIndex = indexCurrent2.clone().set(n);
|
|
2186
|
-
const target2 = st.byIndex(targetIndex.get(), direction2);
|
|
2187
|
-
scrollTo(target2);
|
|
2188
|
-
}
|
|
2189
|
-
};
|
|
2190
|
-
scrollToRef.current = baseScrollTo;
|
|
2191
|
-
const loLimit = Limit(-W, 0);
|
|
2192
|
-
const looper = wrap && W > 0 ? ScrollLooper(
|
|
2193
|
-
W,
|
|
2194
|
-
loLimit,
|
|
2195
|
-
locationRef.current,
|
|
2196
|
-
[locationRef.current, previousLocationRef.current, offsetLocationRef.current, targetRef.current]
|
|
2197
|
-
) : null;
|
|
2198
|
-
const body = ScrollBody(location, offsetLocation, previousLocation, target, selectDuration, sliderFriction);
|
|
2199
|
-
bodyRef.current = body;
|
|
2200
|
-
if (!wrap) {
|
|
2201
|
-
const cw = track[AX.clientKey];
|
|
2202
|
-
const min = -Math.max(0, sliderWidth.current - cw);
|
|
2203
|
-
const max = 0;
|
|
2204
|
-
limitRef.current = Limit(isNaN(min) ? 0 : min, max);
|
|
2205
|
-
povRef.current = PercentOfView(cw);
|
|
2206
|
-
boundsRef.current = ScrollBounds(
|
|
2207
|
-
limitRef.current,
|
|
2208
|
-
offsetLocationRef.current,
|
|
2209
|
-
targetRef.current,
|
|
2210
|
-
bodyRef.current,
|
|
2211
|
-
povRef.current,
|
|
2212
|
-
selectDuration
|
|
2213
|
-
);
|
|
2214
|
-
} else {
|
|
2215
|
-
limitRef.current = null;
|
|
2216
|
-
boundsRef.current = null;
|
|
2217
|
-
povRef.current = null;
|
|
2218
|
-
}
|
|
2219
|
-
const anim = Animations(
|
|
2220
|
-
document,
|
|
2221
|
-
window,
|
|
2222
|
-
() => {
|
|
2223
|
-
if (!wrap) {
|
|
2224
|
-
boundsRef.current?.constrain(pointerDownRef.current);
|
|
2225
|
-
}
|
|
2226
|
-
bodyRef.current?.seek();
|
|
2227
|
-
if (wrap && W > 0) {
|
|
2228
|
-
const body2 = bodyRef.current;
|
|
2229
|
-
const dir = body2.direction() || Math.sign(targetRef.current.get() - locationRef.current.get()) || 0;
|
|
2230
|
-
looper?.loop(dir);
|
|
2231
|
-
}
|
|
2232
|
-
xRef.current = locationRef.current.get();
|
|
2233
|
-
},
|
|
2234
|
-
(alpha) => {
|
|
2235
|
-
const body2 = bodyRef.current;
|
|
2236
|
-
const shouldSettle = body2 ? body2.settled() : true;
|
|
2237
|
-
const idle = shouldSettle && !pointerDownRef.current;
|
|
2238
|
-
if (idle) {
|
|
2239
|
-
animRef.current?.stop();
|
|
2240
|
-
isAnimatingRef.current = false;
|
|
2241
|
-
}
|
|
2242
|
-
const cur = locationRef.current.get();
|
|
2243
|
-
const prev = previousLocationRef.current.get();
|
|
2244
|
-
const loc = cur * alpha + prev * (1 - alpha);
|
|
2245
|
-
offsetLocationRef.current.set(loc);
|
|
2246
|
-
xRef.current = loc;
|
|
2247
|
-
positionSlider();
|
|
2248
|
-
updateActiveIndexFromX(loc);
|
|
2249
|
-
}
|
|
2250
|
-
);
|
|
2251
|
-
animRef.current = anim;
|
|
2252
|
-
anim.init();
|
|
2253
|
-
const dragStore = EventStore();
|
|
2254
|
-
const moveStore = EventStore();
|
|
2255
|
-
const tracker = DragTracker(axis, window);
|
|
2256
|
-
let isMouse = false;
|
|
2257
|
-
let startMain = 0;
|
|
2258
|
-
let startCross = 0;
|
|
2259
|
-
let preventScroll = false;
|
|
2260
|
-
function addDragEvents() {
|
|
2261
|
-
const node = isMouse ? document : root2;
|
|
2262
|
-
moveStore.add(node, "touchmove", onMove).add(node, "touchend", onUp).add(node, "mousemove", onMove, { passive: false }).add(node, "mouseup", onUp);
|
|
2263
|
-
}
|
|
2264
|
-
function onDown(evt) {
|
|
2265
|
-
const isMouseEvt = isMouseEvent(evt, window);
|
|
2266
|
-
isMouse = isMouseEvt;
|
|
2267
|
-
if (isMouseEvt && evt.button !== 0) return;
|
|
2268
|
-
downTargetRef.current = evt.target;
|
|
2269
|
-
setDragCursor(true);
|
|
2270
|
-
pointerDownRef.current = true;
|
|
2271
|
-
isPointerDown.current = true;
|
|
2272
|
-
isClickRef.current = true;
|
|
2273
|
-
tracker.pointerDown(evt);
|
|
2274
|
-
startMain = tracker.readPoint(evt, AX.main);
|
|
2275
|
-
startCross = tracker.readPoint(evt, AX.cross);
|
|
2276
|
-
bodyRef.current.useFriction(0).useDuration(0);
|
|
2277
|
-
targetRef.current.set(locationRef.current.get());
|
|
2278
|
-
addDragEvents();
|
|
2279
|
-
animRef.current?.start();
|
|
2280
|
-
}
|
|
2281
|
-
const freeBoost = { mouse: 500, touch: 600 };
|
|
2282
|
-
function forceBoost(rawForce) {
|
|
2283
|
-
const type = isMouse ? "mouse" : "touch";
|
|
2284
|
-
return rawForce * freeBoost[type];
|
|
2285
|
-
}
|
|
2286
|
-
function onMove(evt) {
|
|
2287
|
-
const isTouchEvt = !isMouseEvent(evt, window);
|
|
2288
|
-
if (isTouchEvt && evt.touches?.length >= 2) return onUp(evt);
|
|
2289
|
-
if (pointerDownRef.current && activePointerIdRef.current != null) setDragCursor(true);
|
|
2290
|
-
const lastMain = tracker.readPoint(evt, AX.main);
|
|
2291
|
-
const lastCross = tracker.readPoint(evt, AX.cross);
|
|
2292
|
-
const diffMain = Math.abs(lastMain - startMain);
|
|
2293
|
-
const diffCross = Math.abs(lastCross - startCross);
|
|
2294
|
-
if (diffMain > 5 || diffCross > 5) isClickRef.current = false;
|
|
2295
|
-
if (!preventScroll && !isMouse) {
|
|
2296
|
-
if (!("cancelable" in evt) || !evt.cancelable) return onUp(evt);
|
|
2297
|
-
preventScroll = diffMain > diffCross;
|
|
2298
|
-
if (!preventScroll) return onUp(evt);
|
|
2299
|
-
}
|
|
2300
|
-
const { dx, dy } = tracker.pointerMove(evt);
|
|
2301
|
-
const deltaMain = (AX.main === "x" ? dx : dy) * sign;
|
|
2302
|
-
previousDragX.current = dragX.current;
|
|
2303
|
-
dragX.current = lastMain * sign;
|
|
2304
|
-
sliderVelocity.current = deltaMain;
|
|
2305
|
-
dragMoveTime.current = /* @__PURE__ */ new Date();
|
|
2306
|
-
bodyRef.current.useFriction(0.3).useDuration(0.75);
|
|
2307
|
-
targetRef.current.add(deltaMain);
|
|
2308
|
-
animRef.current?.start();
|
|
2309
|
-
if (evt.cancelable) evt.preventDefault?.();
|
|
2310
|
-
}
|
|
2311
|
-
function onUp(evt) {
|
|
2312
|
-
isPointerDown.current = false;
|
|
2313
|
-
preventScroll = false;
|
|
2314
|
-
pointerDownRef.current = false;
|
|
2315
|
-
moveStore.clear();
|
|
2316
|
-
setDragCursor(false);
|
|
2317
|
-
if (isClickRef.current) {
|
|
2318
|
-
const idx = getThumbIndexFromEventTarget(evt.target);
|
|
2319
|
-
if (idx >= 0) {
|
|
2320
|
-
commitThumbSelect(idx);
|
|
2321
|
-
isMouse = false;
|
|
2322
|
-
return;
|
|
2323
|
-
}
|
|
2324
|
-
}
|
|
2325
|
-
if (freeScroll === false) {
|
|
2326
|
-
let allowedForce2 = function(force2) {
|
|
2327
|
-
const len2 = slidesRef.current.length || 1;
|
|
2328
|
-
if (!baseScrollTarget) return 0;
|
|
2329
|
-
const curIndex = selectedIndexRef.current || 0;
|
|
2330
|
-
const dir = mathSign(force2);
|
|
2331
|
-
if (dir === 0) return 0;
|
|
2332
|
-
if (!skipSnaps) {
|
|
2333
|
-
const dirIndex2 = dir * -1;
|
|
2334
|
-
let nextIndex2 = curIndex + dirIndex2;
|
|
2335
|
-
if (!wrap) {
|
|
2336
|
-
if (nextIndex2 < 0 || nextIndex2 > len2 - 1) {
|
|
2337
|
-
nextIndex2 = curIndex;
|
|
2338
|
-
}
|
|
2339
|
-
} else {
|
|
2340
|
-
nextIndex2 = (nextIndex2 % len2 + len2) % len2;
|
|
2341
|
-
}
|
|
2342
|
-
const dirBump2 = slidesRef.current.length === 2 ? dir : 0;
|
|
2343
|
-
const nextTarget = baseScrollTarget.byIndex(nextIndex2, dirBump2);
|
|
2344
|
-
return nextTarget.distance;
|
|
2345
|
-
}
|
|
2346
|
-
const baseTarget = baseScrollTarget.byDistance(force2, true);
|
|
2347
|
-
let { index: proposedIndex } = baseTarget;
|
|
2348
|
-
const { distance } = baseTarget;
|
|
2349
|
-
const currentIndex = curIndex;
|
|
2350
|
-
if (proposedIndex !== currentIndex) {
|
|
2351
|
-
if (!wrap) {
|
|
2352
|
-
proposedIndex = Math.max(0, Math.min(len2 - 1, proposedIndex));
|
|
2353
|
-
const clamped = baseScrollTarget.byIndex(proposedIndex, dir);
|
|
2354
|
-
return clamped.distance;
|
|
2355
|
-
}
|
|
2356
|
-
return distance;
|
|
2357
|
-
}
|
|
2358
|
-
const dirIndex = dir * -1;
|
|
2359
|
-
let nextIndex = currentIndex + dirIndex;
|
|
2360
|
-
if (wrap) {
|
|
2361
|
-
nextIndex = (nextIndex % len2 + len2) % len2;
|
|
2362
|
-
} else {
|
|
2363
|
-
nextIndex = Math.max(0, Math.min(len2 - 1, nextIndex));
|
|
2364
|
-
if (nextIndex === currentIndex) {
|
|
2365
|
-
return 0;
|
|
2366
|
-
}
|
|
2367
|
-
}
|
|
2368
|
-
const dirBump = slidesRef.current.length === 2 ? dir : 0;
|
|
2369
|
-
const forced = baseScrollTarget.byIndex(nextIndex, dirBump);
|
|
2370
|
-
return forced.distance;
|
|
2371
|
-
};
|
|
2372
|
-
const end = tracker.pointerUp(evt);
|
|
2373
|
-
let rawForce = AX.main === "x" ? end.fx : end.fy;
|
|
2374
|
-
if (isRtl) rawForce = -rawForce;
|
|
2375
|
-
const isMouseEvt = isMouseEvent(evt, window);
|
|
2376
|
-
const snapForceBoost = { mouse: 300, touch: 400 };
|
|
2377
|
-
const boost = snapForceBoost[isMouseEvt ? "mouse" : "touch"];
|
|
2378
|
-
const boostedForce = rawForce * boost;
|
|
2379
|
-
const baseScrollTarget = scrollTargetRef.current;
|
|
2380
|
-
const baseScrollTo2 = scrollToRef.current;
|
|
2381
|
-
const body2 = bodyRef.current;
|
|
2382
|
-
if (!baseScrollTarget || !baseScrollTo2 || !body2) {
|
|
2383
|
-
return;
|
|
2384
|
-
}
|
|
2385
|
-
const force = allowedForce2(boostedForce);
|
|
2386
|
-
const baseSpeed = selectDuration;
|
|
2387
|
-
const baseFriction = sliderFriction;
|
|
2388
|
-
const forceFactor = factorAbs(boostedForce, force);
|
|
2389
|
-
const speed = baseSpeed - 10 * forceFactor;
|
|
2390
|
-
const friction = baseFriction + forceFactor / 50;
|
|
2391
|
-
body2.useDuration(speed).useFriction(friction);
|
|
2392
|
-
baseScrollTo2.distance(force, true);
|
|
2393
|
-
} else {
|
|
2394
|
-
const end = tracker.pointerUp(evt);
|
|
2395
|
-
const raw = AX.main === "x" ? end.fx : end.fy;
|
|
2396
|
-
const boosted = forceBoost(raw);
|
|
2397
|
-
const force = boosted;
|
|
2398
|
-
const factor = Math.min(1, Math.abs(raw) > 0 ? Math.abs((Math.abs(boosted) - Math.abs(force)) / (raw || 1)) : 0);
|
|
2399
|
-
const speed = freeScrollDuration - 10 * factor;
|
|
2400
|
-
const friction = sliderFriction + factor / 50;
|
|
2401
|
-
bodyRef.current.useDuration(speed).useFriction(friction);
|
|
2402
|
-
targetRef.current.add(force);
|
|
2403
|
-
anim.start();
|
|
2404
|
-
isMouse = false;
|
|
2405
|
-
}
|
|
2406
|
-
}
|
|
2407
|
-
dragStore.add(root2, "dragstart", (evt) => evt.preventDefault(), { passive: false }).add(root2, "touchstart", onDown).add(root2, "mousedown", onDown, { passive: true }).add(root2, "touchcancel", onUp).add(root2, "contextmenu", onUp);
|
|
2408
|
-
function onWheel(e) {
|
|
2409
|
-
const primary = isHorizontal ? e.deltaX : e.deltaY;
|
|
2410
|
-
const primaryAbs = Math.abs(primary);
|
|
2411
|
-
const crossAbs = Math.abs(isHorizontal ? e.deltaY : e.deltaX);
|
|
2412
|
-
if (primaryAbs <= crossAbs) return;
|
|
2413
|
-
if (contentLength <= containerLength) return;
|
|
2414
|
-
const cur = (offsetLocationRef.current?.get() ?? 0) - AX.wheelDelta(e) * sign;
|
|
2415
|
-
let next2 = cur;
|
|
2416
|
-
if (!wrap && limitRef.current) next2 = limitRef.current.constrain(cur);
|
|
2417
|
-
targetRef.current?.set(next2);
|
|
2418
|
-
bodyRef.current?.useDuration(0).useFriction(1);
|
|
2419
|
-
animRef.current?.start();
|
|
2420
|
-
xRef.current = next2;
|
|
2421
|
-
positionSlider();
|
|
2422
|
-
if (e.cancelable) e.preventDefault?.();
|
|
2423
|
-
}
|
|
2424
|
-
root2.addEventListener("wheel", onWheel, { passive: false });
|
|
2425
|
-
return () => {
|
|
2426
|
-
dragStore.clear();
|
|
2427
|
-
moveStore.clear();
|
|
2428
|
-
root2.removeEventListener("wheel", onWheel);
|
|
2429
|
-
animRef.current?.destroy();
|
|
2430
|
-
animRef.current = null;
|
|
2431
|
-
};
|
|
2432
|
-
}, [count, contentLength, containerLength, position, slidesState.length, layoutReady, geomKey, isMeasured, wrap]);
|
|
2433
|
-
useEffect(() => {
|
|
2434
|
-
const isNarrow = !wrap && thumbnailsCenter && contentLength <= containerLength;
|
|
2435
|
-
const base = isNarrow ? baseOffsetRef.current : 0;
|
|
2436
|
-
const min = -Math.max(0, contentLength - containerLength);
|
|
2437
|
-
const max = 0;
|
|
2438
|
-
const nextLimit = Limit(isNaN(min) ? 0 : min, max);
|
|
2439
|
-
limitRef.current = nextLimit;
|
|
2440
|
-
if (pointerDownRef.current) return;
|
|
2441
|
-
if (isAnimatingRef.current) return;
|
|
2442
|
-
const cur = targetRef.current?.get() ?? 0;
|
|
2443
|
-
const clamped = nextLimit.constrain(cur);
|
|
2444
|
-
if (Math.abs(clamped - cur) < 1e-3) return;
|
|
2445
|
-
locationRef.current?.set(clamped);
|
|
2446
|
-
previousLocationRef.current?.set(clamped);
|
|
2447
|
-
offsetLocationRef.current?.set(clamped);
|
|
2448
|
-
targetRef.current?.set(clamped);
|
|
2449
|
-
xRef.current = clamped;
|
|
2450
|
-
translateRef.current?.to((clamped + base) * sign);
|
|
2451
|
-
}, [contentLength, containerLength, thumbnailsCenter, sign, wrap]);
|
|
2452
|
-
useEffect(() => {
|
|
2453
|
-
if (!contentLength || !containerLength || !(thumbSize || thumbLong)) return;
|
|
2454
|
-
const i = clamp(channelRef.current.get().index ?? 0, 0, Math.max(0, count - 1));
|
|
2455
|
-
animateToScroll(getScrollForIndex(i));
|
|
2456
|
-
}, [contentLength, containerLength, thumbLong, thumbSize, count]);
|
|
2457
|
-
const normalizedLoading = useMemo(() => {
|
|
2458
|
-
const src = loadingOptions ?? {};
|
|
2459
|
-
return {
|
|
2460
|
-
isLoading: src.isLoading,
|
|
2461
|
-
skeletonCount: src.skeletonCount,
|
|
2462
|
-
renderLoading: src.renderLoading
|
|
2463
|
-
};
|
|
2464
|
-
}, [loadingOptions]);
|
|
2465
|
-
const normalizedIntro = useMemo(() => {
|
|
2466
|
-
const src = introOptions ?? {};
|
|
2467
|
-
return {
|
|
2468
|
-
renderIntro: src.renderIntro,
|
|
2469
|
-
staggerMs: src.staggerMs ?? 40,
|
|
2470
|
-
transform: src.transform ?? 10,
|
|
2471
|
-
durationMs: src.durationMs ?? 300,
|
|
2472
|
-
easing: src.easing ?? "cubic-bezier(.2,.7,.2,1)"
|
|
2473
|
-
};
|
|
2474
|
-
}, [introOptions]);
|
|
2475
|
-
const renderedThumbs = clonedChildren.length ? clonedChildren : rawKids.map((c, i) => cloneThumb(c, `fallback-${i}`, i, i));
|
|
2476
|
-
const introChildren = useMemo(() => {
|
|
2477
|
-
return renderedThumbs.map((child, i) => {
|
|
2478
|
-
if (!isValidElement(child)) return child;
|
|
2479
|
-
const el = child;
|
|
2480
|
-
const prevStyle = el.props?.style || {};
|
|
2481
|
-
return cloneElement(el, {
|
|
2482
|
-
...el.props,
|
|
2483
|
-
"data-rmg-index": i,
|
|
2484
|
-
style: {
|
|
2485
|
-
...prevStyle,
|
|
2486
|
-
["--rmg-intro-index"]: i
|
|
2487
|
-
}
|
|
2488
|
-
});
|
|
2489
|
-
});
|
|
2490
|
-
}, [renderedThumbs]);
|
|
2491
|
-
const MAX_SKELETONS = 12;
|
|
2492
|
-
const fallbackCount = 6;
|
|
2493
|
-
const { cssText: skeletonCss, ssrBaseCount: skeletonCountBase } = useMemo(() => {
|
|
2494
|
-
return buildScopedSkeletonCountCss({
|
|
2495
|
-
scopeId,
|
|
2496
|
-
responsiveCount: normalizedLoading.skeletonCount,
|
|
2497
|
-
fallbackCount,
|
|
2498
|
-
breakpointMap,
|
|
2499
|
-
maxSlots: MAX_SKELETONS
|
|
2500
|
-
});
|
|
2501
|
-
}, [scopeId, normalizedLoading.skeletonCount, breakpointMap]);
|
|
2502
|
-
const defaultThumbSkeleton = /* @__PURE__ */ jsx("div", { className: ThumbnailSlider_default.thumbSkeletonOverlay, "data-rmg-skel-part": "overlay", children: /* @__PURE__ */ jsx(
|
|
2503
|
-
"div",
|
|
2504
|
-
{
|
|
2505
|
-
className: ThumbnailSlider_default.thumbSkeletonRow,
|
|
2506
|
-
"data-rmg-skel-part": "row",
|
|
2507
|
-
style: {
|
|
2508
|
-
gap,
|
|
2509
|
-
flexDirection: isHorizontal ? "row" : "column"
|
|
2510
|
-
},
|
|
2511
|
-
children: Array.from({ length: MAX_SKELETONS }).map((_, i) => /* @__PURE__ */ jsx(
|
|
2512
|
-
"div",
|
|
2513
|
-
{
|
|
2514
|
-
className: ThumbnailSlider_default.thumbSkeleton,
|
|
2515
|
-
"data-rmg-skel-slot": i + 1,
|
|
2516
|
-
style: {
|
|
2517
|
-
width: isHorizontal ? thumbnailWidth ?? thumbSize ?? 64 : "100%",
|
|
2518
|
-
height: isHorizontal ? "100%" : thumbnailHeight ?? thumbSize ?? 64
|
|
2519
|
-
}
|
|
2520
|
-
},
|
|
2521
|
-
`rmg-thumb-skel-${i}`
|
|
2522
|
-
))
|
|
2523
|
-
}
|
|
2524
|
-
) });
|
|
2525
|
-
const showLoading = normalizedLoading.isLoading != null ? !!normalizedLoading.isLoading : !isReady;
|
|
2526
|
-
const loadingNode = showLoading ? normalizedLoading.renderLoading ? normalizedLoading.renderLoading({ layout: "thumbnails", count: skeletonCountBase }) : defaultThumbSkeleton : null;
|
|
2527
|
-
const fadeClass = showLoading ? "" : isReady && inView ? ThumbnailSlider_default.fadeInActive : ThumbnailSlider_default.fadeInStart;
|
|
2528
|
-
const baseContainerProps = {
|
|
2529
|
-
className: [ThumbnailSlider_default.fade_container, fadeClass].filter(Boolean).join(" "),
|
|
2530
|
-
"aria-busy": showLoading ? true : void 0
|
|
2531
|
-
};
|
|
2532
|
-
const outerStyle = {
|
|
2533
|
-
overflow: "hidden",
|
|
2534
|
-
...isHorizontal ? { width: thumbnailsContainerWidth, height: thumbCross ? "100%" : "auto" } : { height: thumbnailsContainerHeight, width: thumbLong ? "100%" : "auto" },
|
|
2535
|
-
...style || {}
|
|
2536
|
-
};
|
|
2537
|
-
const trackStyle = {
|
|
2538
|
-
width: isHorizontal ? "100%" : thumbnailWidth ?? "100%",
|
|
2539
|
-
height: isHorizontal ? thumbnailHeight ?? "100%" : "100%",
|
|
2540
|
-
willChange: "transform",
|
|
2541
|
-
backfaceVisibility: "hidden",
|
|
2542
|
-
touchAction: "none",
|
|
2543
|
-
visibility: isReady ? "visible" : "hidden"
|
|
2544
|
-
};
|
|
2545
|
-
const effectiveRippleEnabled = rippleEnabled !== false;
|
|
2546
|
-
const effectiveRippleClass = rippleClassName && rippleClassName.trim().length > 0 ? rippleClassName : ThumbnailSlider_default.ripple;
|
|
2547
|
-
const createRipple = useCallback((container) => {
|
|
2548
|
-
if (!effectiveRippleEnabled || !container) return;
|
|
2549
|
-
const old = container.querySelector("[data-rmg-ripple]");
|
|
2550
|
-
if (old) old.remove();
|
|
2551
|
-
const rect = container.getBoundingClientRect();
|
|
2552
|
-
const diameter = Math.max(rect.width, rect.height);
|
|
2553
|
-
const radius = diameter / 2;
|
|
2554
|
-
const x = rect.width / 2 - radius;
|
|
2555
|
-
const y = rect.height / 2 - radius;
|
|
2556
|
-
const span = document.createElement("span");
|
|
2557
|
-
span.setAttribute("data-rmg-ripple", "");
|
|
2558
|
-
if (effectiveRippleClass) {
|
|
2559
|
-
span.className = effectiveRippleClass;
|
|
2560
|
-
}
|
|
2561
|
-
span.style.width = `${diameter}px`;
|
|
2562
|
-
span.style.height = `${diameter}px`;
|
|
2563
|
-
span.style.left = `${x}px`;
|
|
2564
|
-
span.style.top = `${y}px`;
|
|
2565
|
-
container.appendChild(span);
|
|
2566
|
-
span.addEventListener("animationend", () => span.remove(), { once: true });
|
|
2567
|
-
}, [effectiveRippleEnabled, effectiveRippleClass]);
|
|
2568
|
-
const arrowNodes = /* @__PURE__ */ jsx(
|
|
2569
|
-
RmgArrows,
|
|
2570
|
-
{
|
|
2571
|
-
axisMain: AX.main,
|
|
2572
|
-
clientKey: AX.clientKey,
|
|
2573
|
-
wrap,
|
|
2574
|
-
isRtl,
|
|
2575
|
-
showArrows,
|
|
2576
|
-
selectedIndex: selectedIndexRef.current,
|
|
2577
|
-
slideCount: slidesRef.current?.length ?? 0,
|
|
2578
|
-
measureRef: trackRef,
|
|
2579
|
-
viewportMainSizeRef: sliderWidth,
|
|
2580
|
-
previous,
|
|
2581
|
-
next,
|
|
2582
|
-
prevButtonRef,
|
|
2583
|
-
nextButtonRef,
|
|
2584
|
-
createRipple,
|
|
2585
|
-
arrowStyles,
|
|
2586
|
-
prevArrowStyles,
|
|
2587
|
-
nextArrowStyles,
|
|
2588
|
-
arrowClassName,
|
|
2589
|
-
prevArrowClassName,
|
|
2590
|
-
nextArrowClassName,
|
|
2591
|
-
renderPrevArrow,
|
|
2592
|
-
renderNextArrow,
|
|
2593
|
-
renderArrows
|
|
2594
|
-
}
|
|
2595
|
-
);
|
|
2596
|
-
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2597
|
-
arrowNodes,
|
|
2598
|
-
/* @__PURE__ */ jsx("div", { ref: trackRef, style: trackStyle, children: introChildren })
|
|
2599
|
-
] });
|
|
2600
|
-
const root = /* @__PURE__ */ jsxs(
|
|
2601
|
-
"div",
|
|
2602
|
-
{
|
|
2603
|
-
...baseContainerProps,
|
|
2604
|
-
ref: containerRef,
|
|
2605
|
-
id: scopeId,
|
|
2606
|
-
"data-rmg-scope": scopeId,
|
|
2607
|
-
className: [className, thumbnailsContainerClassName, baseContainerProps.className].filter(Boolean).join(" "),
|
|
2608
|
-
style: {
|
|
2609
|
-
...outerStyle,
|
|
2610
|
-
...thumbnailsContainerStyle || {},
|
|
2611
|
-
...baseContainerProps.style || {},
|
|
2612
|
-
["--rmg-intro-stagger"]: `${normalizedIntro.staggerMs}ms`,
|
|
2613
|
-
["--rmg-intro-transform"]: `${normalizedIntro.transform}px`,
|
|
2614
|
-
["--rmg-intro-duration"]: `${normalizedIntro.durationMs}ms`,
|
|
2615
|
-
["--rmg-intro-easing"]: normalizedIntro.easing
|
|
2616
|
-
},
|
|
2617
|
-
children: [
|
|
2618
|
-
loadingNode,
|
|
2619
|
-
normalizedIntro.renderIntro ? normalizedIntro.renderIntro(
|
|
2620
|
-
{ active: isReady && inView, containerProps: baseContainerProps },
|
|
2621
|
-
inner
|
|
2622
|
-
) : inner
|
|
2623
|
-
]
|
|
2624
|
-
}
|
|
2625
|
-
);
|
|
2626
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2627
|
-
skeletonCss && /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: skeletonCss } }),
|
|
2628
|
-
root
|
|
2629
|
-
] });
|
|
2630
|
-
}
|
|
2631
|
-
|
|
2632
|
-
export { Animations, BREAKPOINT_MAP, Counter, EventStore, FullscreenAxis, Limit, PanAxis, PercentOfView, RmgArrows, ScrollBody, ScrollBounds, ScrollLooper, ScrollTarget, ThumbnailSlider, Translate, TranslateFullscreen, Vector1D, buildScopedSkeletonCountCss, containTransformForRect, coverTransformForRect, createBaseLimit, createDragTracker, createIndexChannel, createSliderFullscreenIntroRunner, factorAbs, isMouseEvent, mathSign, objectFitContentRect, parseNumberLike, parseObjectPosition, resolveNumberFromResponsive, resolvePositionFromResponsive, runFullscreenIntro };
|
|
2633
|
-
//# sourceMappingURL=chunk-HOCUKMYX.mjs.map
|
|
2634
|
-
//# sourceMappingURL=chunk-HOCUKMYX.mjs.map
|