
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
simple-dropzone
Advanced tools
A simple multi-file drag-and-drop input using vanilla JavaScript.
A simple drag-and-drop input using vanilla JavaScript.
The library supports supports selection of multiple files, ZIP decoding, and fallback to <input type=file multiple>
on older browsers.
npm install --save simple-dropzone
Create DOM elements for the dropzone and a file input (for compatibility with older browsers). Both may be styled in CSS however you choose.
<div id="dropzone"></div>
<input type="file" id="input">
Create a SimpleDropzone
controller. When files are added, by drag-and-drop or selection with the input, a drop
event is emitted. This event contains a map of filenames to HTML5 File objects. The file list is flat, although directory structure is shown in the filenames.
dropzone.on('drop', ({files}) => {
console.log(files);
});
Optionally, you may want to set additional attributes to configure the file input element, e.g. to allow selection of multiple files.
dropEl
, inputEl
)Constructor takes two DOM elements, for the dropzone and file input.
const dropEl = document.querySelector('#dropzone');
const inputEl = document.querySelector('#input');
const dropCtrl = new SimpleDropzone(dropEl, inputEl);
<div id="dropzone"></div>
<input type="file" id="input">
event
, callback
) : this
Listens for event
and invokes the callback.
dropCtrl.on('drop', ({files}) => {
console.log(files);
});
Destroys the instance and unbinds all events.
Event | Properties | Description |
---|---|---|
drop | files : Map<string, File>, archive?: File | New files added, from either drag-and-drop or selection. archive is provided if the files were extracted from a ZIP archive. |
dropstart | — | Selection is in progress. Decompressing ZIP archives may take several seconds. |
droperror | message : string | Selection has failed. |
FAQs
A simple multi-file drag-and-drop input using vanilla JavaScript.
The npm package simple-dropzone receives a total of 589 weekly downloads. As such, simple-dropzone popularity was classified as not popular.
We found that simple-dropzone demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.