Open rafaelbeckel opened 10 years ago
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):
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!)
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.