annotorious / annotorious-openseadragon

An OpenSeadragon plugin for annotating high-res zoomable images
https://annotorious.github.io
BSD 3-Clause "New" or "Revised" License
124 stars 44 forks source link

Added endSelection event #106

Closed Dzeri96 closed 1 year ago

Dzeri96 commented 2 years ago

This is needed because even though startSelection always fires from the MouseTracker, the cancel event in Tool is basically ignored. This makes cancelSelected and createSelection work unreliably as indicators that drawing of a very small rectangle has ended. This new event only fires if startSelection has previously fired.

TODO: Add documentation

It could be that this PR belongs in the base Annotorious repo. I need it in my fork of Annotorious-openseadragon, but I'll be happy to open it there also.

rsimon commented 1 year ago

Hi,

thanks for the message! Just to confirm: this will always fire when a selection has ended, correct? Regardless of whether the selection has ended by creating a new shape, or by canceling the selection (because the rectangle was too small). And in the case a new selection is created, the event sequence would be startSelection -> endSelection -> selectionCreated?

Dzeri96 commented 1 year ago

To be honest, I forgot everything about this codebase. I'll have to get back into it this week.

Dzeri96 commented 1 year ago

After looking at the code again, yes, it seems that the endSelection event gets triggered always. The chain of events would actually be startSelection-> endSelection and then either complete, which triggers selectionCreated, or cancel, which does nothing as far as I understand.

rsimon commented 1 year ago

Merged this now - thanks!

Dzeri96 commented 1 year ago

Great, but we shouldn't forget to add the documentation!