Is there any methods in 2.x can be used to implement a function like useViewportState in 3.x? #452
-
https://annotorious.dev/react/hooks-reference/ I will be very grateful if anyone can tell me how to do!! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It's certainly possible. But not trivial to implement. You'd need to listen to the If you are not expecting to have many annotations, then simply looping through all annotations will work. (If you expect to have many, you'd probably have to build a 2D index and keep it in sync as annotations are added, updated and removed. Annotorious v3 does that. But it's probably not necessary unless you go over several 100 if not 1000 annotations.) |
Beta Was this translation helpful? Give feedback.
It's certainly possible. But not trivial to implement. You'd need to listen to the
update-viewport
event on the OpenSeadragon viewer, then determine the current viewport bounds (using OpenSeadragon's API) in the coordinate space of the base image, and finally filter all annotations based on whether they intersect the bounds.If you are not expecting to have many annotations, then simply looping through all annotations will work. (If you expect to have many, you'd probably have to build a 2D index and keep it in sync as annotations are added, updated and removed. Annotorious v3 does that. But it's probably not necessary unless you go over several 100 if not 1000 annotations.)