@reuse-sh/lightbox 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ICONS-LICENSE.md +73 -0
- package/LICENSE +1 -1
- package/README.md +1 -0
- package/dist/base.css +37 -0
- package/dist/browser/audio.js +1 -1
- package/dist/browser/carousel-link.js +1 -1
- package/dist/browser/embed.js +1 -1
- package/dist/browser/html.js +1 -1
- package/dist/browser/iframe.js +1 -1
- package/dist/browser/lightbox.js +2 -2
- package/dist/browser/lightbox.js.map +1 -1
- package/dist/browser/video.js +1 -1
- package/dist/icons.d.ts +42 -12
- package/dist/icons.js +42 -18
- package/dist/index.js +115 -14
- package/dist/theme.css +126 -36
- package/dist/themes/dark.css +3 -0
- package/dist/themes/page.css +11 -0
- package/dist/unlayered/base.css +37 -0
- package/dist/unlayered/theme.css +126 -36
- package/dist/unlayered/themes/dark.css +3 -0
- package/dist/unlayered/themes/page.css +11 -0
- package/package.json +3 -2
package/dist/browser/video.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @reuse-sh/lightbox 0.
|
|
1
|
+
/*! @reuse-sh/lightbox 0.3.0 | MIT License */
|
|
2
2
|
function e(e,t,n){let r=t;return e.addEventListener(`play`,()=>r=!1,{signal:n}),{interactive:!0,ready:new Promise(t=>{e.addEventListener(`loadedmetadata`,t,{once:!0,signal:n}),e.addEventListener(`error`,t,{once:!0,signal:n})}),pause:()=>e.pause(),resume(){r&&(r=!1,e.play().catch(t=>{if(t.name===`NotAllowedError`)return e.muted=!0,e.play()}).catch(()=>{}))},unmount(){e.pause(),e.removeAttribute(`src`),e.load(),e.remove()}}}function t(){return{type:`video`,mount(t,{item:n,signal:r,autoplay:i}){let a=t.ownerDocument.createElement(`video`);return a.className=`re-lightbox-video`,a.controls=!0,a.playsInline=!0,a.preload=`metadata`,n.previewSrc&&(a.poster=n.previewSrc),a.src=n.src??``,n.alt&&a.setAttribute(`aria-label`,n.alt),t.append(a),e(a,i,r)}}}export{e as playerOf,t as video};
|
|
3
3
|
//# sourceMappingURL=video.js.map
|
package/dist/icons.d.ts
CHANGED
|
@@ -1,15 +1,45 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
close:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
declare const icons: {
|
|
2
|
+
close: {
|
|
3
|
+
stroke: string;
|
|
4
|
+
paths: string[];
|
|
5
|
+
};
|
|
6
|
+
previous: {
|
|
7
|
+
stroke: string;
|
|
8
|
+
paths: string[];
|
|
9
|
+
};
|
|
10
|
+
next: {
|
|
11
|
+
stroke: string;
|
|
12
|
+
paths: string[];
|
|
13
|
+
};
|
|
14
|
+
zoomIn: {
|
|
15
|
+
stroke: string;
|
|
16
|
+
paths: string[];
|
|
17
|
+
};
|
|
18
|
+
zoomOut: {
|
|
19
|
+
stroke: string;
|
|
20
|
+
paths: string[];
|
|
21
|
+
};
|
|
22
|
+
fullscreenEnter: {
|
|
23
|
+
stroke: string;
|
|
24
|
+
paths: string[];
|
|
25
|
+
};
|
|
26
|
+
fullscreenExit: {
|
|
27
|
+
stroke: string;
|
|
28
|
+
paths: string[];
|
|
29
|
+
};
|
|
30
|
+
download: {
|
|
31
|
+
stroke: string;
|
|
32
|
+
paths: string[];
|
|
33
|
+
};
|
|
34
|
+
play: {
|
|
35
|
+
stroke: string;
|
|
36
|
+
paths: string[];
|
|
37
|
+
};
|
|
38
|
+
pause: {
|
|
39
|
+
stroke: string;
|
|
40
|
+
paths: string[];
|
|
41
|
+
};
|
|
12
42
|
};
|
|
13
|
-
export type BuiltInIcon = keyof typeof
|
|
43
|
+
export type BuiltInIcon = keyof typeof icons;
|
|
14
44
|
export declare function showIcon(button: Element, name: BuiltInIcon): void;
|
|
15
45
|
export {};
|
package/dist/icons.js
CHANGED
|
@@ -1,20 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
// Icon paths from Hugeicons (MIT) and Lucide (ISC); their notices ship in ICONS-LICENSE.md.
|
|
2
|
+
const lens = "M19 11a8 8 0 1 1-16 0 8 8 0 0 1 16 0M21 21l-4.35-4.35";
|
|
3
|
+
const icons = {
|
|
4
|
+
close: {
|
|
5
|
+
stroke: "1.5",
|
|
6
|
+
paths: ["M18 6L6.00081 17.9992M17.9992 18L6 6.00085"],
|
|
7
|
+
},
|
|
8
|
+
previous: { stroke: "1.8", paths: ["m15 18-6-6 6-6"] },
|
|
9
|
+
next: { stroke: "1.8", paths: ["m9 18 6-6-6-6"] },
|
|
10
|
+
zoomIn: { stroke: "1.5", paths: [lens, "M11 8v6M8 11h6"] },
|
|
11
|
+
zoomOut: { stroke: "1.5", paths: [lens, "M8 11h6"] },
|
|
12
|
+
fullscreenEnter: {
|
|
13
|
+
stroke: "1.5",
|
|
14
|
+
paths: [
|
|
15
|
+
"M15.5 21C16.8956 21 17.5933 21 18.1611 20.8278C19.4395 20.44 20.44 19.4395 20.8278 18.1611C21 17.5933 21 16.8956 21 15.5M21 8.5C21 7.10444 21 6.40666 20.8278 5.83886C20.44 4.56046 19.4395 3.56004 18.1611 3.17224C17.5933 3 16.8956 3 15.5 3M8.5 21C7.10444 21 6.40666 21 5.83886 20.8278C4.56046 20.44 3.56004 19.4395 3.17224 18.1611C3 17.5933 3 16.8956 3 15.5M3 8.5C3 7.10444 3 6.40666 3.17224 5.83886C3.56004 4.56046 4.56046 3.56004 5.83886 3.17224C6.40666 3 7.10444 3 8.5 3",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
fullscreenExit: {
|
|
19
|
+
stroke: "1.5",
|
|
20
|
+
paths: [
|
|
21
|
+
"M13 4L13 7.00002C13 8.88563 13.0001 9.82843 13.5858 10.4142C14.1716 11 15.1144 11 17 11L20 11",
|
|
22
|
+
"M11.0001 20L11 17C11 15.1144 11 14.1715 10.4142 13.5858C9.82843 13 8.88563 13 7.00002 13L4.00006 13",
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
download: {
|
|
26
|
+
stroke: "1.5",
|
|
27
|
+
paths: [
|
|
28
|
+
"M16.9504 12.1817C17.1981 12.814 16.5076 13.5726 15.1267 15.0899C13.6702 16.6902 12.9201 17.4904 12 17.5C11.0799 17.4904 10.3298 16.6902 8.87331 15.0899C7.49239 13.5726 6.80193 12.814 7.04964 12.1817C7.05868 12.1586 7.06851 12.1359 7.0791 12.1135C7.34928 11.542 8.24477 11.5029 10 11.5002V4.99998C10 4.53501 10 4.30253 10.0511 4.11179C10.1898 3.59414 10.5941 3.1898 11.1118 3.05111C11.3025 3 11.535 3 12 3C12.4649 3 12.6974 3 12.8882 3.05111C13.4058 3.1898 13.8102 3.59414 13.9489 4.11179C14 4.30253 14 4.53501 14 4.99998V11.5002C15.7552 11.5029 16.6507 11.542 16.9209 12.1135C16.9315 12.1359 16.9413 12.1586 16.9504 12.1817Z",
|
|
29
|
+
"M5.00006 21H19.0001",
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
play: { stroke: "2", paths: ["M8 5v14l11-7z"] },
|
|
33
|
+
pause: { stroke: "2", paths: ["M9 5v14m6-14v14"] },
|
|
13
34
|
};
|
|
14
35
|
const svgNamespace = "http://www.w3.org/2000/svg";
|
|
15
36
|
export function showIcon(button, name) {
|
|
16
|
-
const
|
|
17
|
-
|
|
37
|
+
const { stroke, paths } = icons[name];
|
|
38
|
+
const shown = [...button.querySelectorAll("path")].map((path) => path.getAttribute("d"));
|
|
39
|
+
if (shown.join(" ") === paths.join(" "))
|
|
18
40
|
return;
|
|
19
41
|
const doc = button.ownerDocument;
|
|
20
42
|
const svg = doc.createElementNS(svgNamespace, "svg");
|
|
@@ -24,7 +46,7 @@ export function showIcon(button, name) {
|
|
|
24
46
|
viewBox: "0 0 24 24",
|
|
25
47
|
fill: "none",
|
|
26
48
|
stroke: "currentColor",
|
|
27
|
-
"stroke-width":
|
|
49
|
+
"stroke-width": stroke,
|
|
28
50
|
"stroke-linecap": "round",
|
|
29
51
|
"stroke-linejoin": "round",
|
|
30
52
|
"aria-hidden": "true",
|
|
@@ -33,8 +55,10 @@ export function showIcon(button, name) {
|
|
|
33
55
|
svg.setAttribute(key, value);
|
|
34
56
|
if (name === "previous" || name === "next")
|
|
35
57
|
svg.setAttribute("class", "re-lightbox-arrow-icon");
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
58
|
+
for (const d of paths) {
|
|
59
|
+
const path = doc.createElementNS(svgNamespace, "path");
|
|
60
|
+
path.setAttribute("d", d);
|
|
61
|
+
svg.append(path);
|
|
62
|
+
}
|
|
39
63
|
button.replaceChildren(svg);
|
|
40
64
|
}
|
package/dist/index.js
CHANGED
|
@@ -762,12 +762,42 @@ export function createLightbox(options = {}) {
|
|
|
762
762
|
x: (inset.right - inset.left) / 2,
|
|
763
763
|
y: inset.bottom / 2,
|
|
764
764
|
};
|
|
765
|
+
const left = rect.left + inset.left;
|
|
766
|
+
const right = rect.right - inset.right;
|
|
767
|
+
const bottom = rect.top + s.box.height;
|
|
768
|
+
let top = 0;
|
|
769
|
+
for (const group of s.toolbar.children) {
|
|
770
|
+
const shown = rendered(group);
|
|
771
|
+
if (shown)
|
|
772
|
+
top = Math.max(top, shown.bottom - rect.top);
|
|
773
|
+
}
|
|
774
|
+
const edge = {
|
|
775
|
+
top: top + padding,
|
|
776
|
+
right: padding,
|
|
777
|
+
bottom: padding,
|
|
778
|
+
left: padding,
|
|
779
|
+
};
|
|
780
|
+
for (const arrow of items.length > 1 ? [s.prev, s.next] : []) {
|
|
781
|
+
const shown = arrow && rendered(arrow);
|
|
782
|
+
if (!shown || shown.bottom <= rect.top + top || shown.top >= bottom)
|
|
783
|
+
continue;
|
|
784
|
+
if (shown.left + shown.right < left + right)
|
|
785
|
+
edge.left = Math.max(edge.left, shown.right - left + padding);
|
|
786
|
+
else
|
|
787
|
+
edge.right = Math.max(edge.right, right - shown.left + padding);
|
|
788
|
+
}
|
|
789
|
+
s.window = {
|
|
790
|
+
width: Math.max(1, s.box.width - edge.left - edge.right),
|
|
791
|
+
height: Math.max(1, s.box.height - edge.top - edge.bottom),
|
|
792
|
+
x: (edge.left - edge.right) / 2,
|
|
793
|
+
y: (edge.top - edge.bottom) / 2,
|
|
794
|
+
};
|
|
765
795
|
}
|
|
766
796
|
function view(s) {
|
|
767
797
|
return s.box;
|
|
768
798
|
}
|
|
769
799
|
function area(s, scale) {
|
|
770
|
-
return scale > 1 ? s.area : s
|
|
800
|
+
return scale > 1 ? s.area : room(state.index, s);
|
|
771
801
|
}
|
|
772
802
|
function bound(s, zoom) {
|
|
773
803
|
return boundZoom(zoom, fit(state.index, s), area(s, zoom.scale));
|
|
@@ -804,22 +834,67 @@ export function createLightbox(options = {}) {
|
|
|
804
834
|
return filling(image.naturalWidth / image.naturalHeight, s);
|
|
805
835
|
return view(s);
|
|
806
836
|
}
|
|
837
|
+
function framed(index, s) {
|
|
838
|
+
if (items[index].type || s.loaded.get(index)?.status === "failed")
|
|
839
|
+
return false;
|
|
840
|
+
const { width, height } = imageSize(index, s);
|
|
841
|
+
return height > 2 * width;
|
|
842
|
+
}
|
|
843
|
+
function room(index, s) {
|
|
844
|
+
return framed(index, s) ? s.window : view(s);
|
|
845
|
+
}
|
|
846
|
+
function spacing(index, s) {
|
|
847
|
+
return framed(index, s) ? 0 : padding;
|
|
848
|
+
}
|
|
807
849
|
function tall(index, s) {
|
|
808
|
-
if (items[index].type)
|
|
850
|
+
if (items[index].type || s.loaded.get(index)?.status === "failed")
|
|
809
851
|
return false;
|
|
810
|
-
return shapeOf(imageSize(index, s),
|
|
852
|
+
return (shapeOf(imageSize(index, s), room(index, s), spacing(index, s)) === "tall");
|
|
811
853
|
}
|
|
812
854
|
function fit(index, s) {
|
|
813
855
|
// A player leaves 24px at each side for a swipe that pages past it.
|
|
814
|
-
return (tall(index, s) ? widthFit : contain)(imageSize(index, s),
|
|
856
|
+
return (tall(index, s) ? widthFit : contain)(imageSize(index, s), room(index, s), items[index].type ? Math.max(padding, 24) : spacing(index, s));
|
|
857
|
+
}
|
|
858
|
+
function resting(s, index) {
|
|
859
|
+
const size = fit(index, s);
|
|
860
|
+
const space = room(index, s);
|
|
861
|
+
return boundZoom({
|
|
862
|
+
scale: 1,
|
|
863
|
+
x: 0,
|
|
864
|
+
y: tall(index, s) ? panRange(1, size, space).y.max : 0,
|
|
865
|
+
}, size, space);
|
|
815
866
|
}
|
|
816
867
|
function restZoom(s, index) {
|
|
817
|
-
const zoom =
|
|
818
|
-
? { scale: 1, x: 0, y: panRange(1, fit(index, s), view(s)).y.max }
|
|
819
|
-
: { ...identity };
|
|
868
|
+
const zoom = resting(s, index);
|
|
820
869
|
s.rest = zoom;
|
|
821
870
|
return zoom;
|
|
822
871
|
}
|
|
872
|
+
function photoRect(s) {
|
|
873
|
+
const box = s.loaded.get(state.index)?.frame.getBoundingClientRect();
|
|
874
|
+
if (!box || state.zoom.scale > 1 || !framed(state.index, s))
|
|
875
|
+
return box;
|
|
876
|
+
const { width, height, x = 0, y = 0 } = s.window;
|
|
877
|
+
const left = s.box.left + s.box.width / 2 + x - width / 2;
|
|
878
|
+
const top = s.box.top + s.box.height / 2 + y - height / 2;
|
|
879
|
+
return {
|
|
880
|
+
left: Math.max(box.left, left),
|
|
881
|
+
top: Math.max(box.top, top),
|
|
882
|
+
right: Math.min(box.right, left + width),
|
|
883
|
+
bottom: Math.min(box.bottom, top + height),
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
function markFramed(s, index) {
|
|
887
|
+
const slide = s.slides[index];
|
|
888
|
+
if (!slide)
|
|
889
|
+
return;
|
|
890
|
+
if (!s.loaded.has(index) || !framed(index, s)) {
|
|
891
|
+
slide.removeAttribute("data-framed");
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
const value = index === state.index && state.zoom.scale < 1 - 1e-3 ? "out" : "rest";
|
|
895
|
+
if (slide.dataset.framed !== value)
|
|
896
|
+
slide.dataset.framed = value;
|
|
897
|
+
}
|
|
823
898
|
function limits(s, index = state.index) {
|
|
824
899
|
const item = items[index];
|
|
825
900
|
const entry = s.loaded.get(index);
|
|
@@ -828,9 +903,9 @@ export function createLightbox(options = {}) {
|
|
|
828
903
|
return zoomLimits({
|
|
829
904
|
fileWidth: largestWidth(item?.srcset) ?? entry?.natural ?? item?.width,
|
|
830
905
|
image: imageSize(index, s),
|
|
831
|
-
viewport:
|
|
906
|
+
viewport: room(index, s),
|
|
832
907
|
zoomed: s.area,
|
|
833
|
-
padding,
|
|
908
|
+
padding: spacing(index, s),
|
|
834
909
|
svg: Boolean(item?.src &&
|
|
835
910
|
formatOf(item.src, s.dialog.ownerDocument.baseURI) === "svg"),
|
|
836
911
|
maxZoom: settings.maxZoom,
|
|
@@ -868,6 +943,8 @@ export function createLightbox(options = {}) {
|
|
|
868
943
|
showStateIcon(zoomButton, "zoom", "zoomOut", out);
|
|
869
944
|
s.dialog.dataset.zoomed = String(state.zoom.scale > 1);
|
|
870
945
|
s.dialog.dataset.zoom = out ? "out" : "in";
|
|
946
|
+
for (const index of s.loaded.keys())
|
|
947
|
+
markFramed(s, index);
|
|
871
948
|
if (s.watchedScale !== state.zoom.scale) {
|
|
872
949
|
s.watchedScale = state.zoom.scale;
|
|
873
950
|
clearTimeout(s.sharpTimer);
|
|
@@ -1235,12 +1312,25 @@ export function createLightbox(options = {}) {
|
|
|
1235
1312
|
else
|
|
1236
1313
|
win.requestIdleCallback(apply);
|
|
1237
1314
|
}
|
|
1315
|
+
function placeWindow(s, index, size) {
|
|
1316
|
+
const rest = resting(s, index);
|
|
1317
|
+
const x = s.inset.left + s.box.width / 2;
|
|
1318
|
+
const y = s.box.height / 2;
|
|
1319
|
+
const { width, height, x: dx = 0, y: dy = 0 } = s.window;
|
|
1320
|
+
const top = y + Math.max(rest.y - size.height / 2, dy - height / 2);
|
|
1321
|
+
const bottom = y + Math.min(rest.y + size.height / 2, dy + height / 2);
|
|
1322
|
+
const left = x + Math.max(rest.x - size.width / 2, dx - width / 2);
|
|
1323
|
+
const right = x + Math.min(rest.x + size.width / 2, dx + width / 2);
|
|
1324
|
+
s.slides[index]?.style.setProperty("--re-lightbox-window", `${top}px ${s.area.width - right}px ${s.area.height - bottom}px ${left}px`);
|
|
1325
|
+
}
|
|
1238
1326
|
function layout(s) {
|
|
1239
1327
|
const resting = s.rest !== undefined && sameZoom(state.zoom, s.rest);
|
|
1240
1328
|
for (const [index, entry] of s.loaded) {
|
|
1241
1329
|
const size = fit(index, s);
|
|
1242
1330
|
entry.frame.style.width = `${size.width}px`;
|
|
1243
1331
|
entry.frame.style.height = `${size.height}px`;
|
|
1332
|
+
if (framed(index, s))
|
|
1333
|
+
placeWindow(s, index, size);
|
|
1244
1334
|
}
|
|
1245
1335
|
requestSizes(s);
|
|
1246
1336
|
if (resting)
|
|
@@ -1329,6 +1419,7 @@ export function createLightbox(options = {}) {
|
|
|
1329
1419
|
entry.cancel();
|
|
1330
1420
|
entry.frame.remove();
|
|
1331
1421
|
s.loaded.delete(index);
|
|
1422
|
+
markFramed(s, index);
|
|
1332
1423
|
}
|
|
1333
1424
|
}
|
|
1334
1425
|
// The current image loads first; the neighbors wait until it has decoded or failed, and
|
|
@@ -1659,8 +1750,11 @@ export function createLightbox(options = {}) {
|
|
|
1659
1750
|
return;
|
|
1660
1751
|
failed();
|
|
1661
1752
|
settle("failed");
|
|
1662
|
-
if (
|
|
1663
|
-
|
|
1753
|
+
if (state.isClosing)
|
|
1754
|
+
return;
|
|
1755
|
+
layout(s);
|
|
1756
|
+
if (s.flying)
|
|
1757
|
+
entry.commit = () => layout(s);
|
|
1664
1758
|
};
|
|
1665
1759
|
if (item.srcset) {
|
|
1666
1760
|
loader.srcset = item.srcset;
|
|
@@ -2745,7 +2839,7 @@ export function createLightbox(options = {}) {
|
|
|
2745
2839
|
!gesture.pinched &&
|
|
2746
2840
|
!gesture.axis &&
|
|
2747
2841
|
Math.hypot(dx, dy) >= 10) {
|
|
2748
|
-
const range = panRange(gesture.zoom.scale, fit(state.index, s),
|
|
2842
|
+
const range = panRange(gesture.zoom.scale, fit(state.index, s), area(s, gesture.zoom.scale)).y;
|
|
2749
2843
|
gesture.axis =
|
|
2750
2844
|
Math.abs(dy) <= Math.abs(dx)
|
|
2751
2845
|
? "x"
|
|
@@ -2826,7 +2920,7 @@ export function createLightbox(options = {}) {
|
|
|
2826
2920
|
const now = Date.now();
|
|
2827
2921
|
s.suppressClickUntil = now + 400;
|
|
2828
2922
|
const current = point(event);
|
|
2829
|
-
const box = s
|
|
2923
|
+
const box = photoRect(s);
|
|
2830
2924
|
const onPhoto = box !== undefined &&
|
|
2831
2925
|
current.x >= box.left &&
|
|
2832
2926
|
current.x <= box.right &&
|
|
@@ -2919,7 +3013,7 @@ export function createLightbox(options = {}) {
|
|
|
2919
3013
|
target.closest("[data-lightbox-interactive],button,a,input,textarea,select"))
|
|
2920
3014
|
return;
|
|
2921
3015
|
// A pan captures the pointer, which retargets its click to the viewport.
|
|
2922
|
-
const box = s
|
|
3016
|
+
const box = photoRect(s);
|
|
2923
3017
|
const onPhoto = target.closest(".re-lightbox-frame") !== null ||
|
|
2924
3018
|
(box !== undefined &&
|
|
2925
3019
|
event.clientX >= box.left &&
|
|
@@ -3650,6 +3744,7 @@ export function createLightbox(options = {}) {
|
|
|
3650
3744
|
heading: 1,
|
|
3651
3745
|
strings,
|
|
3652
3746
|
slots: [],
|
|
3747
|
+
toolbar,
|
|
3653
3748
|
footer,
|
|
3654
3749
|
thumbStrip,
|
|
3655
3750
|
thumbRing,
|
|
@@ -3694,6 +3789,7 @@ export function createLightbox(options = {}) {
|
|
|
3694
3789
|
paddingProbe,
|
|
3695
3790
|
box: { left: 0, top: 0, width: 1, height: 1 },
|
|
3696
3791
|
area: { width: 1, height: 1 },
|
|
3792
|
+
window: { width: 1, height: 1 },
|
|
3697
3793
|
inset: { left: 0, right: 0, bottom: 0 },
|
|
3698
3794
|
room: { left: 0, right: 0, bottom: 0 },
|
|
3699
3795
|
suppressClickUntil: 0,
|
|
@@ -4114,6 +4210,7 @@ export function createLightbox(options = {}) {
|
|
|
4114
4210
|
cancelAnimations(s);
|
|
4115
4211
|
s.viewport.append(...slides);
|
|
4116
4212
|
}
|
|
4213
|
+
const arrowsBefore = items.length > 1;
|
|
4117
4214
|
items = nextItems;
|
|
4118
4215
|
sources = [...input];
|
|
4119
4216
|
s.slides = slides;
|
|
@@ -4141,6 +4238,10 @@ export function createLightbox(options = {}) {
|
|
|
4141
4238
|
});
|
|
4142
4239
|
publish({ index: target, count: items.length });
|
|
4143
4240
|
update(s);
|
|
4241
|
+
if (arrowsBefore !== items.length > 1) {
|
|
4242
|
+
const win = s.dialog.ownerDocument.defaultView;
|
|
4243
|
+
s.resizeFrame ??= win?.requestAnimationFrame(() => resized(s));
|
|
4244
|
+
}
|
|
4144
4245
|
s.reported = target;
|
|
4145
4246
|
if (!kept)
|
|
4146
4247
|
arrived(s, target);
|
package/dist/theme.css
CHANGED
|
@@ -1,38 +1,58 @@
|
|
|
1
1
|
@layer re.base, re.theme;
|
|
2
2
|
@layer re.theme {
|
|
3
3
|
.re-lightbox {
|
|
4
|
-
--re-lightbox-background:
|
|
5
|
-
--re-lightbox-foreground: #
|
|
6
|
-
--re-lightbox-
|
|
4
|
+
--re-lightbox-background: #fcfcfc;
|
|
5
|
+
--re-lightbox-foreground: #1f1f1f;
|
|
6
|
+
--re-lightbox-muted: color-mix(
|
|
7
|
+
in srgb,
|
|
8
|
+
var(--re-lightbox-foreground) 80%,
|
|
9
|
+
var(--re-lightbox-background)
|
|
10
|
+
);
|
|
11
|
+
--re-lightbox-control: #fff;
|
|
7
12
|
--re-lightbox-control-hover: color-mix(
|
|
8
13
|
in srgb,
|
|
9
|
-
var(--re-lightbox-control)
|
|
14
|
+
var(--re-lightbox-control) 95%,
|
|
10
15
|
var(--re-lightbox-foreground)
|
|
11
16
|
);
|
|
12
|
-
--re-lightbox-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
--re-lightbox-ring:
|
|
18
|
+
0 0 0 0.5px rgb(0 0 0 / 10%), 0 1px 2px rgb(0 0 0 / 6%),
|
|
19
|
+
0 2px 6px rgb(0 0 0 / 4%);
|
|
20
|
+
--re-lightbox-panel: #fff;
|
|
21
|
+
--re-lightbox-button-size: 40px;
|
|
22
|
+
--re-lightbox-button-padding: 0px;
|
|
15
23
|
--re-lightbox-button-radius: 50%;
|
|
16
|
-
--re-lightbox-press-scale: 0.
|
|
17
|
-
--re-lightbox-icon-size:
|
|
24
|
+
--re-lightbox-press-scale: 0.95;
|
|
25
|
+
--re-lightbox-icon-size: 18px;
|
|
18
26
|
--re-lightbox-font-size: 14px;
|
|
19
27
|
--re-lightbox-counter-font-size: 13px;
|
|
20
|
-
--re-lightbox-
|
|
28
|
+
--re-lightbox-counter-padding: 0 14px;
|
|
29
|
+
--re-lightbox-counter-radius: 999px;
|
|
30
|
+
--re-lightbox-caption-padding: 0px;
|
|
31
|
+
--re-lightbox-caption-radius: 0px;
|
|
21
32
|
--re-lightbox-inset: 16px;
|
|
22
|
-
--re-lightbox-gap:
|
|
23
|
-
--re-lightbox-arrow-inset:
|
|
24
|
-
--re-lightbox-footer-inset:
|
|
25
|
-
--re-lightbox-
|
|
26
|
-
--re-lightbox-
|
|
27
|
-
--re-lightbox-
|
|
28
|
-
--re-lightbox-
|
|
33
|
+
--re-lightbox-gap: 8px;
|
|
34
|
+
--re-lightbox-arrow-inset: var(--re-lightbox-inset);
|
|
35
|
+
--re-lightbox-footer-inset: var(--re-lightbox-inset);
|
|
36
|
+
--re-lightbox-padding: 24px;
|
|
37
|
+
--re-lightbox-caption-room: 30px;
|
|
38
|
+
--re-lightbox-strip-room: 0px;
|
|
39
|
+
--re-lightbox-bottom-room: calc(
|
|
40
|
+
var(--re-lightbox-caption-room) +
|
|
41
|
+
var(--re-lightbox-strip-room)
|
|
42
|
+
);
|
|
29
43
|
--re-lightbox-thumbnail-size: 44px;
|
|
30
|
-
--re-lightbox-thumbnail-radius:
|
|
31
|
-
--re-lightbox-thumbnail-gap:
|
|
44
|
+
--re-lightbox-thumbnail-radius: 8px;
|
|
45
|
+
--re-lightbox-thumbnail-gap: 6px;
|
|
32
46
|
--re-lightbox-thumbnails-padding: 4px;
|
|
47
|
+
--re-lightbox-thumbnail-background: #e6e6e3;
|
|
33
48
|
--re-lightbox-error-padding: 24px;
|
|
34
|
-
--re-lightbox-placeholder: rgb(
|
|
49
|
+
--re-lightbox-placeholder: rgb(0 0 0 / 5%);
|
|
35
50
|
--re-lightbox-media-background: #f2f2f2;
|
|
51
|
+
--re-lightbox-media-ring: color-mix(
|
|
52
|
+
in srgb,
|
|
53
|
+
var(--re-lightbox-foreground) 14%,
|
|
54
|
+
transparent
|
|
55
|
+
);
|
|
36
56
|
--re-lightbox-retry-padding: 8px 16px;
|
|
37
57
|
--re-lightbox-retry-radius: 20px;
|
|
38
58
|
--re-lightbox-aside-width: 320px;
|
|
@@ -54,22 +74,33 @@
|
|
|
54
74
|
sans-serif
|
|
55
75
|
);
|
|
56
76
|
}
|
|
77
|
+
.re-lightbox [class*="re-lightbox"],
|
|
78
|
+
.re-lightbox [class*="re-lightbox"]::before,
|
|
79
|
+
.re-lightbox [class*="re-lightbox"]::after {
|
|
80
|
+
box-sizing: border-box;
|
|
81
|
+
}
|
|
57
82
|
.re-lightbox-backdrop {
|
|
58
83
|
background: var(--re-lightbox-background);
|
|
59
84
|
transition: background-color var(--re-lightbox-background-duration, 0ms) ease;
|
|
60
85
|
}
|
|
61
86
|
.re-lightbox-button {
|
|
62
|
-
box-sizing: border-box;
|
|
63
87
|
width: var(--re-lightbox-button-size);
|
|
64
88
|
height: var(--re-lightbox-button-size);
|
|
65
89
|
padding: var(--re-lightbox-button-padding);
|
|
66
90
|
border: 0;
|
|
67
91
|
border-radius: var(--re-lightbox-button-radius);
|
|
68
92
|
background: var(--re-lightbox-control);
|
|
93
|
+
box-shadow: var(--re-lightbox-ring);
|
|
69
94
|
color: inherit;
|
|
70
95
|
font: inherit;
|
|
71
96
|
line-height: 1;
|
|
72
|
-
|
|
97
|
+
}
|
|
98
|
+
/* The arrows take their opacity transitions from the phase rules in base.css. */
|
|
99
|
+
.re-lightbox-button:where(:not(.re-lightbox-prev, .re-lightbox-next)) {
|
|
100
|
+
transition:
|
|
101
|
+
background-color 150ms ease,
|
|
102
|
+
scale 160ms cubic-bezier(0.23, 1, 0.32, 1),
|
|
103
|
+
opacity 300ms ease;
|
|
73
104
|
}
|
|
74
105
|
.re-lightbox-button svg {
|
|
75
106
|
width: var(--re-lightbox-icon-size);
|
|
@@ -92,7 +123,18 @@
|
|
|
92
123
|
opacity: calc(0.3 * var(--re-lightbox-chrome-opacity, 1));
|
|
93
124
|
}
|
|
94
125
|
.re-lightbox-close {
|
|
95
|
-
transition:
|
|
126
|
+
transition:
|
|
127
|
+
background-color 150ms ease,
|
|
128
|
+
scale 160ms cubic-bezier(0.23, 1, 0.32, 1),
|
|
129
|
+
opacity 300ms ease,
|
|
130
|
+
rotate var(--re-lightbox-control-duration) ease;
|
|
131
|
+
}
|
|
132
|
+
/* Repeats base.css's zoomed fade, which the transitions above replace. */
|
|
133
|
+
:where(.re-lightbox[data-zoomed="true"] .re-lightbox-toolbar-end)
|
|
134
|
+
> :not(.re-lightbox-zoom, .re-lightbox-close) {
|
|
135
|
+
transition:
|
|
136
|
+
opacity 300ms ease,
|
|
137
|
+
visibility 0s 300ms;
|
|
96
138
|
}
|
|
97
139
|
.re-lightbox-download {
|
|
98
140
|
text-decoration: none;
|
|
@@ -129,27 +171,56 @@
|
|
|
129
171
|
[data-re-focus-quiet]:focus-visible {
|
|
130
172
|
outline: none;
|
|
131
173
|
}
|
|
174
|
+
.re-lightbox-prev,
|
|
175
|
+
.re-lightbox-next {
|
|
176
|
+
top: calc(
|
|
177
|
+
(100% - var(--re-lightbox-bottom-room)) /
|
|
178
|
+
2 -
|
|
179
|
+
var(--re-lightbox-button-size) /
|
|
180
|
+
2
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
.re-lightbox-footer {
|
|
184
|
+
gap: 10px;
|
|
185
|
+
}
|
|
132
186
|
.re-lightbox-counter {
|
|
187
|
+
display: flex;
|
|
188
|
+
height: var(--re-lightbox-button-size);
|
|
133
189
|
padding: var(--re-lightbox-counter-padding);
|
|
190
|
+
align-items: center;
|
|
134
191
|
border-radius: var(--re-lightbox-counter-radius);
|
|
135
192
|
background: var(--re-lightbox-control);
|
|
193
|
+
box-shadow: var(--re-lightbox-ring);
|
|
136
194
|
font-size: var(--re-lightbox-counter-font-size);
|
|
195
|
+
font-weight: 500;
|
|
137
196
|
font-variant-numeric: tabular-nums;
|
|
138
|
-
|
|
197
|
+
}
|
|
198
|
+
.re-lightbox-counter[hidden] {
|
|
199
|
+
display: none;
|
|
139
200
|
}
|
|
140
201
|
.re-lightbox-caption {
|
|
202
|
+
order: 1;
|
|
141
203
|
padding: var(--re-lightbox-caption-padding);
|
|
142
204
|
border-radius: var(--re-lightbox-caption-radius);
|
|
143
|
-
|
|
205
|
+
color: var(--re-lightbox-muted);
|
|
144
206
|
font-size: var(--re-lightbox-font-size);
|
|
145
|
-
line-height:
|
|
207
|
+
line-height: 20px;
|
|
146
208
|
text-align: center;
|
|
147
209
|
}
|
|
210
|
+
.re-lightbox[data-thumbnails="bottom"] {
|
|
211
|
+
--re-lightbox-strip-room: 64px;
|
|
212
|
+
}
|
|
213
|
+
.re-lightbox:has(.re-lightbox-aside > .re-lightbox-caption) {
|
|
214
|
+
--re-lightbox-caption-room: 0px;
|
|
215
|
+
}
|
|
148
216
|
.re-lightbox-thumbnails {
|
|
149
217
|
gap: var(--re-lightbox-thumbnail-gap);
|
|
150
218
|
}
|
|
151
219
|
.re-lightbox[data-thumbnails="bottom"] .re-lightbox-thumbnails {
|
|
152
|
-
|
|
220
|
+
order: 2;
|
|
221
|
+
max-width: 100%;
|
|
222
|
+
margin: 0;
|
|
223
|
+
padding: 5px 50%;
|
|
153
224
|
}
|
|
154
225
|
.re-lightbox[data-thumbnails="side"] .re-lightbox-thumbnails {
|
|
155
226
|
padding: 0 var(--re-lightbox-thumbnails-padding);
|
|
@@ -160,7 +231,7 @@
|
|
|
160
231
|
padding: 0;
|
|
161
232
|
border: 0;
|
|
162
233
|
border-radius: var(--re-lightbox-thumbnail-radius);
|
|
163
|
-
background:
|
|
234
|
+
background: var(--re-lightbox-thumbnail-background);
|
|
164
235
|
opacity: 0.45;
|
|
165
236
|
transition: opacity var(--re-lightbox-control-duration) ease;
|
|
166
237
|
}
|
|
@@ -179,14 +250,16 @@
|
|
|
179
250
|
}
|
|
180
251
|
.re-lightbox-thumbnail-ring {
|
|
181
252
|
border-radius: var(--re-lightbox-thumbnail-radius);
|
|
182
|
-
|
|
183
|
-
|
|
253
|
+
box-shadow:
|
|
254
|
+
0 0 0 2px var(--re-lightbox-background),
|
|
255
|
+
0 0 0 3.5px var(--re-lightbox-foreground);
|
|
184
256
|
transition:
|
|
185
257
|
width var(--re-lightbox-ring-duration) ease,
|
|
186
258
|
height var(--re-lightbox-ring-duration) ease;
|
|
187
259
|
}
|
|
188
260
|
@media (prefers-reduced-motion: reduce) {
|
|
189
|
-
.re-lightbox-thumbnail-ring
|
|
261
|
+
.re-lightbox-thumbnail-ring,
|
|
262
|
+
.re-lightbox-thumbnails button {
|
|
190
263
|
transition: none;
|
|
191
264
|
}
|
|
192
265
|
}
|
|
@@ -200,10 +273,11 @@
|
|
|
200
273
|
var(--re-lightbox-gap)
|
|
201
274
|
)
|
|
202
275
|
var(--re-lightbox-inset) var(--re-lightbox-inset);
|
|
203
|
-
border-radius: 0;
|
|
204
|
-
background: none;
|
|
205
276
|
text-align: start;
|
|
206
277
|
}
|
|
278
|
+
.re-lightbox-slide[data-framed]::after {
|
|
279
|
+
box-shadow: inset 0 0 0 1px var(--re-lightbox-media-ring);
|
|
280
|
+
}
|
|
207
281
|
.re-lightbox-frame:is([data-loading], [data-error]) {
|
|
208
282
|
background: var(--re-lightbox-placeholder);
|
|
209
283
|
}
|
|
@@ -217,6 +291,7 @@
|
|
|
217
291
|
border: 0;
|
|
218
292
|
border-radius: var(--re-lightbox-retry-radius);
|
|
219
293
|
background: var(--re-lightbox-control);
|
|
294
|
+
box-shadow: var(--re-lightbox-ring);
|
|
220
295
|
color: inherit;
|
|
221
296
|
font: inherit;
|
|
222
297
|
}
|
|
@@ -227,10 +302,25 @@
|
|
|
227
302
|
outline: 2px solid currentColor;
|
|
228
303
|
outline-offset: 3px;
|
|
229
304
|
}
|
|
230
|
-
@media (max-width:
|
|
305
|
+
@media (max-width: 559.98px) {
|
|
231
306
|
.re-lightbox {
|
|
232
|
-
--re-lightbox-
|
|
233
|
-
--re-lightbox-
|
|
307
|
+
--re-lightbox-inset: 12px;
|
|
308
|
+
--re-lightbox-padding: 12px;
|
|
309
|
+
--re-lightbox-thumbnail-size: 36px;
|
|
310
|
+
}
|
|
311
|
+
.re-lightbox[data-thumbnails="bottom"] {
|
|
312
|
+
--re-lightbox-strip-room: 56px;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
@media (max-height: 479.98px) {
|
|
316
|
+
.re-lightbox[data-thumbnails="bottom"] {
|
|
317
|
+
--re-lightbox-strip-room: 0px;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
@media (prefers-reduced-motion: reduce) {
|
|
321
|
+
.re-lightbox,
|
|
322
|
+
.re-lightbox * {
|
|
323
|
+
transition-duration: 0ms;
|
|
234
324
|
}
|
|
235
325
|
}
|
|
236
326
|
}
|
package/dist/themes/dark.css
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
.re-lightbox {
|
|
4
4
|
--re-lightbox-background: rgb(15 15 17 / 96%);
|
|
5
5
|
--re-lightbox-foreground: #fff;
|
|
6
|
+
--re-lightbox-muted: rgb(255 255 255 / 72%);
|
|
6
7
|
--re-lightbox-control: rgb(35 35 38 / 96%);
|
|
7
8
|
--re-lightbox-control-hover: rgb(58 58 62 / 98%);
|
|
9
|
+
--re-lightbox-ring: none;
|
|
8
10
|
--re-lightbox-panel: rgb(24 24 27 / 96%);
|
|
9
11
|
--re-lightbox-placeholder: rgb(255 255 255 / 6%);
|
|
12
|
+
--re-lightbox-thumbnail-background: #222;
|
|
10
13
|
--re-lightbox-media-background: #f2f2f2;
|
|
11
14
|
}
|
|
12
15
|
}
|