Drag and drop file uploads a single normalized event
JavaScript
Latest commit 3b39a91 Feb 11, 2014 @TooTallNate TooTallNate Release 0.1.7
Permalink
Failed to load latest commit information.
.gitignore Initial commit Apr 25, 2013
History.md Release 0.1.7 Feb 11, 2014
Makefile Initial commit Apr 25, 2013
Readme.md docs Apr 25, 2013
component.json Release 0.1.7 Feb 11, 2014
example.html example: add a child node for testing Dec 12, 2013
index.js index: re-add the "dragover" handler Dec 12, 2013
package.json Release 0.1.7 Feb 11, 2014

Readme.md

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.

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