summerstyle / summer

Html image map editor based on javascript, html5, inline SVG (modern FF, Chrome, Opera and IE10+)
http://summerstyle.github.io/summer/
MIT License
356 stars 136 forks source link

Hotspots can be moved outside image boundaries #15

Closed chrjs closed 8 years ago

chrjs commented 8 years ago

Hotspots can be moved outside image boundaries (see attachment). hs

summerstyle commented 8 years ago

Hi, chrjs.

Yes, the specification https://www.w3.org/TR/2011/WD-html5-20110525/the-map-element.html allows negative values of coords for html image maps.

chrjs commented 8 years ago

Thank you Vera. I see, quite surprising... Since we don't have this requirement in our editor, we would like to have the movement blocked on the image edges. Is there any possibility to have this option implemented? How much it will cost? Thanks.

summerstyle commented 8 years ago

For the editor, negative coordinates is normal, but now I am making big refactoring of the editor. I want to divide coords library (for drawing/editing/loading/saving/exporting areas) from the editor. Then users will can simply create many editors on one page in their projects.

This option is possible,maybe, as parameter, something like this:

var editor = new Editor(url, containerEl, {
    isMovableOutsideCanvas: true
});

But, i don't know, when it happens - I have not enough time.

You can add checking for negative coordinates in process of moving here: https://github.com/summerstyle/summer/blob/master/summerHTMLImageMapCreator.js#L856 like this:

this.setCoords(Area.getMovingNormalizedCoords(this.edit('move', dx, dy))).redraw();

and for all types of areas static method for normalizing coords like this: https://github.com/summerstyle/summer/blob/master/summerHTMLImageMapCreator.js#L1388