@knaw-huc/osd-iiif-viewer 0.2.3 → 0.2.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.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Viewer as Viewer$1 } from "openseadragon";
|
|
3
3
|
import { createContext, useContext, useMemo, useState, useRef, useEffect, useCallback } from "react";
|
|
4
4
|
import { createStore } from "zustand/vanilla";
|
|
5
|
-
import { useStore } from "zustand
|
|
5
|
+
import { useStore } from "zustand";
|
|
6
6
|
import { createPortal } from "react-dom";
|
|
7
7
|
function e$7(t3) {
|
|
8
8
|
"@babel/helpers - typeof";
|
|
@@ -1807,7 +1807,6 @@ const defaultManifest = {
|
|
|
1807
1807
|
id: null,
|
|
1808
1808
|
url: null,
|
|
1809
1809
|
isLoading: !1,
|
|
1810
|
-
isReady: !1,
|
|
1811
1810
|
error: null
|
|
1812
1811
|
}, createManifestSlice = (vault) => (set) => ({
|
|
1813
1812
|
vault,
|
|
@@ -1837,11 +1836,14 @@ const defaultManifest = {
|
|
|
1837
1836
|
}, createCanvasSlice = (set, get) => ({
|
|
1838
1837
|
...defaultCanvas,
|
|
1839
1838
|
goToCanvas: (index) => {
|
|
1840
|
-
const { vault, id: manifestId } = get();
|
|
1839
|
+
const { vault, id: manifestId, currentIndex } = get();
|
|
1841
1840
|
if (!manifestId)
|
|
1842
1841
|
return;
|
|
1843
|
-
const manifest = vault.get({ id: manifestId, type: "Manifest" }),
|
|
1844
|
-
|
|
1842
|
+
const manifest = vault.get({ id: manifestId, type: "Manifest" }), newIndex = Math.max(0, Math.min(index, manifest.items.length - 1));
|
|
1843
|
+
newIndex !== currentIndex && set({
|
|
1844
|
+
currentIndex: newIndex,
|
|
1845
|
+
viewerReady: !1
|
|
1846
|
+
});
|
|
1845
1847
|
},
|
|
1846
1848
|
goToCanvasById: (id) => {
|
|
1847
1849
|
const { vault, id: manifestId, goToCanvas } = get();
|
|
@@ -2032,8 +2034,8 @@ function Viewer(props) {
|
|
|
2032
2034
|
}
|
|
2033
2035
|
useEffect(openTileSource, [tileSource, store, isContainerReady]);
|
|
2034
2036
|
function openTileSource() {
|
|
2035
|
-
const
|
|
2036
|
-
!viewer || !tileSource ||
|
|
2037
|
+
const viewer = store.getState().viewer;
|
|
2038
|
+
!viewer || !tileSource || viewer.open(tileSource);
|
|
2037
2039
|
}
|
|
2038
2040
|
useEffect(resizeViewerOnContainerResize, [store]);
|
|
2039
2041
|
function resizeViewerOnContainerResize() {
|