@canopy-iiif/app 0.13.1 → 0.13.2
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/package.json +1 -1
- package/ui/dist/index.mjs +11 -5
- package/ui/dist/index.mjs.map +2 -2
- package/ui/dist/server.mjs +14 -9
- package/ui/dist/server.mjs.map +4 -4
package/package.json
CHANGED
package/ui/dist/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ var HelloWorld = () => {
|
|
|
6
6
|
|
|
7
7
|
// ui/src/layout/Card.jsx
|
|
8
8
|
import React2, { useEffect, useRef, useState } from "react";
|
|
9
|
+
var DEFAULT_CARD_ASPECT_RATIO = 4 / 3;
|
|
9
10
|
function Card({
|
|
10
11
|
href,
|
|
11
12
|
src,
|
|
@@ -23,12 +24,15 @@ function Card({
|
|
|
23
24
|
...rest
|
|
24
25
|
}) {
|
|
25
26
|
const containerRef = useRef(null);
|
|
26
|
-
const
|
|
27
|
-
const
|
|
27
|
+
const isBrowser = typeof window !== "undefined";
|
|
28
|
+
const supportsIntersectionObserver = typeof IntersectionObserver === "function";
|
|
29
|
+
const shouldRenderImmediately = !lazy || !isBrowser || !supportsIntersectionObserver;
|
|
30
|
+
const [inView, setInView] = useState(shouldRenderImmediately);
|
|
31
|
+
const [imageLoaded, setImageLoaded] = useState(shouldRenderImmediately);
|
|
28
32
|
useEffect(() => {
|
|
29
33
|
if (!lazy) return;
|
|
30
34
|
if (!containerRef.current) return;
|
|
31
|
-
if (
|
|
35
|
+
if (!supportsIntersectionObserver) {
|
|
32
36
|
setInView(true);
|
|
33
37
|
return;
|
|
34
38
|
}
|
|
@@ -58,10 +62,12 @@ function Card({
|
|
|
58
62
|
} catch (_) {
|
|
59
63
|
}
|
|
60
64
|
};
|
|
61
|
-
}, [lazy]);
|
|
65
|
+
}, [lazy, supportsIntersectionObserver]);
|
|
62
66
|
const w = Number(imgWidth);
|
|
63
67
|
const h = Number(imgHeight);
|
|
64
|
-
const
|
|
68
|
+
const hasAspectRatio = Number.isFinite(Number(aspectRatio)) && Number(aspectRatio) > 0;
|
|
69
|
+
const hasDimensions = Number.isFinite(w) && w > 0 && Number.isFinite(h) && h > 0;
|
|
70
|
+
const ratio = hasAspectRatio ? Number(aspectRatio) : hasDimensions ? w / h : src ? DEFAULT_CARD_ASPECT_RATIO : void 0;
|
|
65
71
|
const paddingPercent = ratio ? 100 / ratio : 100;
|
|
66
72
|
const caption = /* @__PURE__ */ React2.createElement("figcaption", null, title && /* @__PURE__ */ React2.createElement("span", null, title), subtitle && /* @__PURE__ */ React2.createElement("span", null, subtitle), children);
|
|
67
73
|
return /* @__PURE__ */ React2.createElement(
|