Created
October 21, 2016 22:10
-
-
Save gartenfeld/f8a8f499df2473f95f5ae75b11994146 to your computer and use it in GitHub Desktop.
Drag and Drop Files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var element = $('#drop-area')[0]; | |
| var callback = function onFileDrop() { | |
| var filenames = event.target.result; | |
| }; | |
| function droppable(element, callback) { | |
| element.addEventListener('dragover', function onDrag(event) { | |
| event.stopPropagation(); | |
| event.preventDefault(); | |
| event.dataTransfer.dropEffect = 'copy'; | |
| }); | |
| element.addEventListener('drop', function onDrop(event) { | |
| event.stopPropagation(); | |
| event.preventDefault(); | |
| callback(event.dataTransfer.files); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment