react-img-mapper icon indicating copy to clipboard operation
react-img-mapper copied to clipboard

preStrokeColor prop

Open ghost opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. I want an area to be always highlighted like the preFillColor works, but I want only the stroke to be drawn. The stroke should be white and if the mouse enter the area the stroke should turn green.

Describe the solution you'd like I want a new prop preStrokeColor that allows to set different stroke color in highlighted and default state.

Describe alternatives you've considered I tried using the the preFillColor with alpha 0, but that way the stroke color is always the same if the mouse moves over the are or not. I need the stroke to be always white and if the mouse enters the are the stroke should turn green.

I also tried to use the callbacks onMouseEnter and onMouseLeave to change the map areas stroke color. But the rerendering gave me flashings and unexpected results.

ghost avatar May 09 '23 08:05 ghost

There could be a natural fillColor variable as well. P.S.: I have just discovered, there is a preFillColor

teddybee avatar Jul 10 '23 22:07 teddybee

Came across this issue and found out that you can achieve it by setting preFillColor to transparent and define a strokeColor. (Drawback is you have to manually handle toggle of highlighting.)

 <ImageMapper
  areas={areas.map((area) => {
    return {
      ...area,
      preFillColor: 'transparent',
      strokeColor: 'lime',
      lineWidth: 5,
    };
  })}
  ...
/>

Feels more like a bug than a feature so it might break in future versions but in v2.0.0 it worked for me.

mbarde avatar Feb 27 '25 09:02 mbarde