Skip to content

Commit

Permalink
TEMP: zoomToWorld after adding a TiledImageSource
Browse files Browse the repository at this point in the history
- see also ProjectMirador#4104
- this is not ideal from a performance standpoint and interferes with viewport preservation
  • Loading branch information
barmintor committed Feb 21, 2025
1 parent f2124c4 commit 86a1ec3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/OpenSeadragonTileSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import OpenSeadragonViewerContext from '../contexts/OpenSeadragonViewerContext';
/** OSD tile source shim that adds + updates its tile source data */
export default function OpenSeadragonTileSource({
index = undefined, opacity = undefined, fitBounds = undefined, tileSource = {}, url = undefined,
zoomToWorld = undefined,
}) {
const viewer = useContext(OpenSeadragonViewerContext);
const tiledImage = useRef(undefined);
Expand Down Expand Up @@ -46,6 +47,7 @@ export default function OpenSeadragonTileSource({
tileSource: localTileSource,
});
}).then((event) => {
if (zoomToWorld) zoomToWorld();
tiledImage.current = event.item;
});

Expand All @@ -68,4 +70,5 @@ OpenSeadragonTileSource.propTypes = {
opacity: PropTypes.number,
tileSource: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
url: PropTypes.string,
zoomToWorld: PropTypes.func,
};
2 changes: 2 additions & 0 deletions src/components/OpenSeadragonViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export function OpenSeadragonViewer({
fitBounds={fitBounds}
index={index}
opacity={opacity}
zoomToWorld={zoomToWorld}
/>
);
})}
Expand All @@ -131,6 +132,7 @@ export function OpenSeadragonViewer({
fitBounds={fitBounds}
index={index}
opacity={opacity}
zoomToWorld={zoomToWorld}
/>
);
})}
Expand Down

0 comments on commit 86a1ec3

Please sign in to comment.