Skip to content
This repository has been archived by the owner on Apr 2, 2023. It is now read-only.

Fixes a glitch of opening editor at first click #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rafaelbeckel
Copy link

When the user draws more than three polygons, the editor was opening in the first click of the third polygon.

It was happening because Annotorious is sending two clicks in the second polygon, three clicks in the third, and so on. The isClosed function checks if it's at least the third point and if it's 5 pixels close to the _anchor point, so it was causing the window to open wrongly.

My contribution is a workaround to check if the click is the same as the last one, so it doesn't call the isClosed function if so.

It doesn't correct the multiple-click event issue (I think it's a core Annotorious glitch), but it fixes the expected behavior.

If you draw more than three polygons, the editor was opening in the first click of the third polygon.

It was happening because Annotorious is sending two clicks in the second polygon, three clicks in the third, and so on. The isClosed function checks if it's at least the third point and if it's 5 pixels close to the _anchor point, so it was causing the window to open wrongly.

My contribution is a workaround to check if the click is the same as the last one, so it doesn't call the isClosed function if so.

It doesn't correct the multiple-click event issue (I think it's a core Annotorious glitch), but it corrects the expected behavior.
@rsimon
Copy link
Member

rsimon commented Jan 28, 2014

Hi Rafael,

ah - thanks for spotting this! I need to take closer look myself, but it seems it could be because the selector registers mouse listeners on the canvas when it's activated:

https://github.com/annotorious/annotorious-selector-pack/blob/master/src/polygon_selector.js#L197

and then when it's deactivated, it doesn't de-register them (it only deletes the reference):

https://github.com/annotorious/annotorious-selector-pack/blob/master/src/polygon_selector.js#L160-168

If that's indeed the root cause - sorry for this! (Happened when I pulled the polygon selector out of the core code, migrating from Google's Closure Tools utility to JS code without the Closure dependency. The commented lines are still there - yikes!)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants