Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clicking a svg line its hard to hit,any ideas how to put a click area around a line [duplicate]

Tags:

click

svg

line

I have a SVG Drawing, I want to click the lines on it. That works fine, if you hit the sometimes realy thin guy.

Does anybody have an idea, how to make the line clicking easier - without just enlarging "stroke-width"?

I tried using two lines (one white thicker one black thin), but then the rendering order destroys parts of the drawing.

any idea?

like image 644
halfbit Avatar asked Dec 09 '22 13:12

halfbit


2 Answers

Draw two lines, one the one you want to see and another thicker i.e. with a stroke-width but with visibility="hidden" and then treat clicks on the hidden line as clicks on the visible line. You may need to adjust the pointer-events property to disable it for the visible line (pointer-events="none") and enable it for the hidden line (pointer-events="all")

like image 190
Robert Longson Avatar answered Dec 29 '22 00:12

Robert Longson


one simple trick (in addition to above) is, use an other cursor in css of this element, eg: 'pointer', so your cusomers get a chance to "feel" if they are "above" the line

like image 32
halfbit Avatar answered Dec 29 '22 01:12

halfbit