Saifis
Saifis

Reputation: 2237

Best way to draw rectangles via mouse drag in React.js?

I'm trying to highlight areas of an image like how you would on your mac or windows by dragging an area with the mouse in a React.js application.

I understand this would be best done on Canvas, by overlaying the canvas over the image, and then catch the mouse events and drawing the rectangle accordingly, is there a good library or something to do this? because writing raw code to implement this seem to be reinventing the wheel.

Thanks in advance.

Upvotes: 8

Views: 6620

Answers (2)

Azim Uddin Ahamed
Azim Uddin Ahamed

Reputation: 21

There are some libraries .

you can choose https://daybrush.com/scena/

and some paid libraries

Upvotes: 0

wootencl
wootencl

Reputation: 585

Not sure if this is enough to warrant a full answer but I ran into a similar situation and this library is the best I could find:

react-sketch

Admittedly though it seems the maintainer is very unresponsive/not maintaining the package which is a bit concerning.

Hope this helps :)

Upvotes: 1

Related Questions