Select elements by dragging a box

You can select elements easily drawing a box with your mouse without using jQuery UI or third party plugins. Just handle 2 mouse events and check if at least one point of each element is within your box area.

Notice, that we are using a third event (as guidance) simply to draw the area.

In my first implementation, it was available to select any element by surrounding any of its corners or a minimum area inside it, but due to its complexity and most of the used scenarios, I decided to change the selection criteria to the center point with all elements same size.

2 replies
    • Génesis
      Génesis says:

      Yes, not very happy indeed, I’m working in a better solution where all the elements have the same proportions xD

Comments are closed.