# box-selection

> Small library for making box selections on HTML elements in JavaScript

Latest version **0.0.8** (published 2019-03-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install box-selection
pnpm add box-selection
yarn add box-selection
bun add box-selection
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2019-03-29 |
| First published | 2019-03-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 663.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Kevin Karsopawiro |
| Maintainers | afterburn |
| Keywords | html, elements, box, selection |

## Links

- npm: https://www.npmjs.com/package/box-selection
- Repository: https://github.com/afterburn/box-selection
- Homepage: https://github.com/afterburn/box-selection#readme
- Issues: https://github.com/afterburn/box-selection/issues
- npm.io page: https://npm.io/package/box-selection

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 0.0.8 (latest) — 2019-03-29
- 0.0.7 — 2019-03-29
- 0.0.6 — 2019-03-29
- 0.0.5 — 2019-03-29
- 0.0.4 — 2019-03-29
- 0.0.3 — 2019-03-29
- 0.0.2 — 2019-03-29
- 0.0.1 — 2019-03-29

## README

# Box Selection
![](https://img.shields.io/npm/v/box-selection.svg) ![](https://img.shields.io/npm/dt/box-selection.svg)

Small JavaScript library for making box selections on HTML elements.
Makes use of CSS transforms so there is no paint flashing.

![](https://raw.githubusercontent.com/afterburn/box-selection/master/assets/box-selection.gif)

#### Installation
```bash
npm install --save box-selection
```

#### Usage
```javascript
const instance = new BoxSelection({
  container: document.getElementById('container'), // The scope in which BoxSelection should function.
  itemSelector: '.item', // The CSS class BoxSelection will use to target items.
  selectedClass: '.selected', // The CSS class that will be added to the HTML elements that fall within the selection box.
  selectionClass: '.selection', // The CSS class that will be added to the selection box.
  mode: 'loose', // 'loose' or 'strict'
  onSelectionChange: (selectedItems) => {
    console.log(selectedItems) // Array of HTML elements that fall within the selection box.
  }
})

instance.unbind() // Function you can call to unbind all of BoxSelection's events.
```

#### Customization
CSS styling used in GIF:
```
.selection {
	background-color: rgba(255, 165, 0, 0.5);
	border: 1px solid darkorange;
	z-index: 1;
}
```

---
_Source: https://npm.io/package/box-selection · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
