Is it possible to pass a custom OSD viewer instance to OpenSeadragonAnnotator? #464
Replies: 2 comments 5 replies
-
Thanks for the kind feedback! I don't have formal support this scenario - yet. But I agree it would be a good addition to the But as long as that's not yet possible: I think it would be fairly straightforward to build your own workaround. You're exactly on the right path. The only key step is to pass the viewer instance into the context. Here's what the default In your
// ...
const MyOSDViewer = (props: { viewer: OpenSeadragon.Viewer }) => {
const { setViewer } = useContext(OpenSeadragonAnnotatorContext);
// ...
useEffect(() => {
setViewer(props.viewer);
}, [props.viewer]);
return null;
} Everything else should just work... fingers crossed ;-) |
Beta Was this translation helpful? Give feedback.
-
Thanks @rsimon! Yes, maybe you can point me, because I was trying this: and getting the error: I think you export a way to access the viewer but not set it, and you don't export the Context? I only see Are you saying I would need to go into the source myself in order to access this component? Thank you for clarifying and sorry if I am missing something. |
Beta Was this translation helpful? Give feedback.
-
Hi all and thank you for all the contributions to this great tool and active codebase!
I would love to use Annotorious and the OpenSeadragonAnnotator with an existing React project that implements OpenSeadragon already.
So, these are the imports described in the documentation to get started:
We would not use the imported
OpenSeadragonViewer
, rather we would pass our existing viewer to Annotorious. Our React code would do something like:But I know this is not so simple due to the needed Context. I did not understand a way to access the Context externally and set a different viewer. Thank you for any examples or insight.
Edit: I found this as a possible reference, but it is the old version of Annotorious:
https://github.com/rsimon/mirador-annotorious/blob/bb6b44debb76571994ace69937176535190edede/src/AnnotoriousPlugin.jsx#L12
Beta Was this translation helpful? Give feedback.
All reactions