Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read only mode removes the mask #349

Open
JamMaster1999 opened this issue Jan 10, 2024 · 3 comments
Open

Read only mode removes the mask #349

JamMaster1999 opened this issue Jan 10, 2024 · 3 comments
Labels
v2.x Legacy 2.x relesae

Comments

@JamMaster1999
Copy link

Hello and thank you for your work on annotorius. It's AWESOME! Can't wait for V3.
I do have one small suggestion for improvement that I think is really simple to fix but would be greatly appreciated.
Right now I have setup the library to look like this
image
But when I turn on the readOnly mode it looks like this:
image
IS there anyway you would be willing to add the selection mask back so everything around it gets opaque and it becomes super clear where the user should be paying attention to? I believe this is a simple change as you just have to add the <path fill-rule="evenodd" d="...." class="a9s-selection-mask"></path> back in when in read only mode.

Thank you again!

@rsimon
Copy link
Member

rsimon commented Jan 10, 2024

Thanks!

Unfortunately, it's no as easy a change. The mask is currently a sub-part of the editing tool. Which means there's extra plumbing needed to make it available separately. It's not just a matter of turning it on at least. I'm happy to take a PR around this, but will likely not have time to look into this myself.

@JamMaster1999
Copy link
Author

@rsimon Thanks for the swift reply. Ok no worries. I have two other ways that do not require extra plumbing. Can you tell me if either of these would work at scale?

  1. Store the path in a variable mapped to the id of the annotation and update it whenever there is a change to the annotation position. Then in read-only mode, when a annotation is selected, add the path again and remove it once annotation is unselected.
  2. Come up with a third mode that combines disableEditor and readOnly. The disableEditor already contains the mask all we need to do is just add back in the annotation without any editing capabilities.

@rsimon
Copy link
Member

rsimon commented Jan 10, 2024

Hi,

I'm not sure about your 2nd option, TBH. This might be going down a rabbit hole of dealing with various plumbing aspects inside Annotorious. (Even I don't remember all the pathways and dirty shortcuts I might have made back then ;-)

The first option sounds definitely feasible though. In read-only mode, there's probably not even a need to listen to annotation changes. You can just listen to the select event, which will give you the annotation & the annotation's SVG element. Grab the points from the SVG polygon, and create a mask element on the fly, using this piece of code as a guide.

If I remember correctly, the cancelSelected event is always fired when the selection is closed (or changed), this would be the point where you can delete your mask element again.

FWIW: there's no mask element in Annotorious v3 yet. I'll keep it mind to add it over there, too. (Selection, editing and read-only mode work in a different way there. I.e. it would actually be easier to build a mask that works both with and without the editing tools.)

@rsimon rsimon added the v2.x Legacy 2.x relesae label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2.x Legacy 2.x relesae
Projects
None yet
Development

No branches or pull requests

2 participants