Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/n1crack/mouse-select

Simple javascript class for mouse selection.
https://github.com/n1crack/mouse-select

es2015 mouse-events mouse-selection selection

Last synced: 2 days ago
JSON representation

Simple javascript class for mouse selection.

Awesome Lists containing this project

README

        

# mouse-select
An elegant javascript class for mouse selection.

## Demo
Try it: [Live demo](https://codepen.io/anon/pen/vrWXxX)

## installation
````
npm install mouse-select
````

## basic usage
````javascript
import mselect from 'mouse-select';

window.select = new mselect({
el: 'ul'
});

select.onSelect(function (item, index) {
// add active class to selected items.
item.classList.add('active');

}).onClear(function () {
// when starting new selection, remove existing selection
document.querySelectorAll('li.active')
.forEach(function (el) {
el.classList.remove("active")
});
});

````