A small JS library for making square selections on HTML elements. Uses CSS transforms so there’s no paint flicker.
Box Selection is a small JavaScript vanilla library for easy DOM selection that enables the user to select multiple items within a container by mouse drag.
JavaScript Library That Groups HTML Draggable Elements | magnet.js
How to make use of it:
1. Install and import the Box Selection.
# NPM $ npm i box-selection --save module.exports = require('./lib/box-selection')
2. Add items to be selectable to a container component as follows:
<div class="wrapper" id="container"> <div class="item"> </div> <div class="item"> </div> <div class="item"> </div> <div class="item"> </div> <div class="item"> </div> </div>
3. Create an instance of the Box Selection and executed.
const instance = new BoxSelection({ // default: the whole document container: document.getElementById('container'), // default: .item itemSelector: '.item' })
4. Get the selected items using the onSelectionChange
callback.
const instance = new BoxSelection({ onSelectionChange: (selectedItems) => { console.log(selectedItems) } })
5. Customize the styles of the selection box.
const instance = new BoxSelection({ selectionClass: '.selection' })
.selection { background-color: rgba(255, 255, 255, 0.5); }
6. Customize the styles of the items when selected.
const instance = new BoxSelection({ selectedClass: '.selected' })
.selected { background-color: #222; }
7. Determine the selection mode: ‘strict’ or ‘loose’.
const instance = new BoxSelection({ mode: 'loose' })
Tiny Draggable Selection JavaScript Library, javascript mouse drag selection, Box Selection Github
See Demo And Download

Official Website(afterburn): Click Here
This superior jQuery/javascript plugin is developed by afterburn. For extra Advanced Usages, please go to the official website.