@canopy-iiif/app 1.9.18 → 1.9.20
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 +65 -9
- package/ui/dist/index.mjs.map +3 -3
- package/ui/dist/server.mjs +65 -9
- package/ui/dist/server.mjs.map +3 -3
- package/ui/styles/base/_markdown.scss +2 -1
- package/ui/styles/index.css +2 -0
package/ui/dist/server.mjs
CHANGED
|
@@ -699,21 +699,16 @@ var ImageStory = (props = {}) => {
|
|
|
699
699
|
if (!node) return void 0;
|
|
700
700
|
let cleanup = null;
|
|
701
701
|
let cancelled = false;
|
|
702
|
+
let mounted = false;
|
|
703
|
+
let resizeObserver = null;
|
|
704
|
+
let pollId = null;
|
|
702
705
|
const payload = sanitizeImageStoryProps({
|
|
703
706
|
iiifContent,
|
|
704
707
|
disablePanAndZoom,
|
|
705
708
|
pointOfInterestSvgUrl,
|
|
706
709
|
viewerOptions
|
|
707
710
|
});
|
|
708
|
-
|
|
709
|
-
if (cancelled) {
|
|
710
|
-
destroy && destroy();
|
|
711
|
-
return;
|
|
712
|
-
}
|
|
713
|
-
cleanup = typeof destroy === "function" ? destroy : null;
|
|
714
|
-
});
|
|
715
|
-
return () => {
|
|
716
|
-
cancelled = true;
|
|
711
|
+
const destroyCleanup = () => {
|
|
717
712
|
if (cleanup) {
|
|
718
713
|
try {
|
|
719
714
|
cleanup();
|
|
@@ -722,6 +717,67 @@ var ImageStory = (props = {}) => {
|
|
|
722
717
|
cleanup = null;
|
|
723
718
|
}
|
|
724
719
|
};
|
|
720
|
+
const disconnectWatchers = () => {
|
|
721
|
+
if (resizeObserver) {
|
|
722
|
+
try {
|
|
723
|
+
resizeObserver.disconnect();
|
|
724
|
+
} catch (_) {
|
|
725
|
+
}
|
|
726
|
+
resizeObserver = null;
|
|
727
|
+
}
|
|
728
|
+
if (pollId) {
|
|
729
|
+
window.clearTimeout(pollId);
|
|
730
|
+
pollId = null;
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
const hasUsableSize = () => {
|
|
734
|
+
if (!node) return false;
|
|
735
|
+
const rect = node.getBoundingClientRect();
|
|
736
|
+
const width = (rect == null ? void 0 : rect.width) || node.offsetWidth || node.clientWidth;
|
|
737
|
+
const height2 = (rect == null ? void 0 : rect.height) || node.offsetHeight || node.clientHeight;
|
|
738
|
+
return width > 2 && height2 > 2;
|
|
739
|
+
};
|
|
740
|
+
const mountViewer = () => {
|
|
741
|
+
if (!node || mounted || cancelled) return false;
|
|
742
|
+
if (!hasUsableSize()) return false;
|
|
743
|
+
mounted = true;
|
|
744
|
+
disconnectWatchers();
|
|
745
|
+
mountImageStory(node, payload).then((destroy) => {
|
|
746
|
+
if (cancelled) {
|
|
747
|
+
destroy && destroy();
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
cleanup = typeof destroy === "function" ? destroy : null;
|
|
751
|
+
});
|
|
752
|
+
return true;
|
|
753
|
+
};
|
|
754
|
+
if (!mountViewer()) {
|
|
755
|
+
if (typeof window !== "undefined" && typeof window.ResizeObserver === "function") {
|
|
756
|
+
resizeObserver = new window.ResizeObserver(() => {
|
|
757
|
+
if (mounted || cancelled) return;
|
|
758
|
+
mountViewer();
|
|
759
|
+
});
|
|
760
|
+
try {
|
|
761
|
+
resizeObserver.observe(node);
|
|
762
|
+
} catch (_) {
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
const schedulePoll = () => {
|
|
766
|
+
if (mounted || cancelled) return;
|
|
767
|
+
pollId = window.setTimeout(() => {
|
|
768
|
+
pollId = null;
|
|
769
|
+
if (!mountViewer()) {
|
|
770
|
+
schedulePoll();
|
|
771
|
+
}
|
|
772
|
+
}, 200);
|
|
773
|
+
};
|
|
774
|
+
schedulePoll();
|
|
775
|
+
}
|
|
776
|
+
return () => {
|
|
777
|
+
cancelled = true;
|
|
778
|
+
disconnectWatchers();
|
|
779
|
+
destroyCleanup();
|
|
780
|
+
};
|
|
725
781
|
}, [iiifContent, disablePanAndZoom, pointOfInterestSvgUrl, viewerOptions]);
|
|
726
782
|
return /* @__PURE__ */ React6.createElement(
|
|
727
783
|
"div",
|