Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanety/stimulus-dropzone
https://github.com/kanety/stimulus-dropzone
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kanety/stimulus-dropzone
- Owner: kanety
- License: mit
- Created: 2021-10-07T13:20:48.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-06-27T07:30:22.000Z (7 months ago)
- Last Synced: 2024-11-08T05:44:08.498Z (2 months ago)
- Language: JavaScript
- Size: 42 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
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).