OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

fabric.js-How to select the smaller shape which has some overlaps with other shapes when drawing order is unknown?

  • Thread starter Thread starter user25639440
  • Start date Start date
U

user25639440

Guest
For example, if the mouse clicks anywhere in the yellow area (the overlap), the red rectangle should be selected because its area is smaller. Similarly, if the mouse clicks the yellow area where the purple circle overlaps with another shape, the purple circle should be selected.

Without knowing the drawing order, how to implement the feature with fabric.js: when clicking anywhere in the overlapping part of some shapes, the one with the smaller area is selectable?

Thanks.

<p><a href="https://i.sstatic.net/gwRzhk2I.png" rel="nofollow noreferrer">For example, if the mouse clicks anywhere in the yellow area (the overlap), the red rectangle should be selected because its area is smaller. Similarly, if the mouse clicks the yellow area where the purple circle overlaps with another shape, the purple circle should be selected.</a></p>
<p>Without knowing the drawing order, how to implement the feature with fabric.js: when clicking anywhere in the overlapping part of some shapes, the one with the smaller area is selectable?</p>
<p>Thanks.</p>
 
Top