https://github.com/component/drop
Drag and drop file uploads a single normalized event
https://github.com/component/drop
Last synced: 7 months ago
JSON representation
Drag and drop file uploads a single normalized event
- Host: GitHub
- URL: https://github.com/component/drop
- Owner: component
- Created: 2013-04-25T17:46:26.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2014-02-11T01:42:00.000Z (about 12 years ago)
- Last Synced: 2025-08-16T04:56:24.600Z (8 months ago)
- Language: JavaScript
- Size: 216 KB
- Stars: 31
- Watchers: 7
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# Drop
Drag and drop upload component providing each
drop as a single event for easy filtering and custom
precedence.
## Installation
$ component install component/drop
## Features
- normalizes all items and files into a single `e.items` array
- auto-populates `.string` for string related items
- walks directories (webkit only)
## Example
The `e.items` array contains `File` objects for file uploads,
and regular objects for string related drops.
```js
var drop = require('drop')
var el = document.querySelector('#drop')
drop(el, function(e){
var items = e.items
items.forEach(function(item){
console.log(item)
})
})
```
### File
Dropping files results in `File` objects with the following properties. When
file(s) are uploaded via dropping a directory the `.entry` property is populated
which allows you to reference `item.entry.fullPath`.
- `kind` "file"
- `lastModifiedDate`
- `name` filename
- `size` file size
- `type` mime type
- `entry` `FileEntry` object
### Item
Dropping strings or urls results in objects with the following properties:
- `kind` "string"
- `type` mime type
- `string` value
# License
MIT