Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/kanety/stimulus-dropzone


https://github.com/kanety/stimulus-dropzone

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# stimulus-dropzone

A stimulus controller for simple drop zone.

## Dependencies

* @hotwired/stimulus 3.0+

## Installation

Install from npm:

$ npm install @kanety/stimulus-dropzone --save

## Usage

Register controller:

```javascript
import { Application } from '@hotwired/stimulus';
import DropzoneController from '@kanety/stimulus-dropzone';

const application = Application.start();
application.register('dropzone', DropzoneController);
```

Import css:

```css
@import '@kanety/stimulus-dropzone';
```

Build html as follows:

```html



Drop here



```

Dropped files will be set in the input tag:

### options

#### grow-width, grow-heigth

Grow drop zone size while dragging:

```html



Drop here



```

### Callbacks

Run callbacks when files are dropped:

```javascript
let element = document.querySelector('[data-controller="dropzone"]');
element.addEventListener('dropzone:dropped', e => {
// e.detail.files are dropped files
console.log("dropped " + e.detail.files);
});
```

## License

The library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).