1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 13:41:57 +02:00

Rearrange handleDrop() to flow more naturally

This commit is contained in:
Brett Sun 2015-12-02 13:52:17 +01:00
parent fe24a5e15a
commit 916ec7aace

View File

@ -59,11 +59,9 @@ let FileDragAndDrop = React.createClass({
handleDrop(event) {
event.preventDefault();
event.stopPropagation();
let files;
if(this.props.dropzoneInactive) {
return;
}
if (!this.props.dropzoneInactive) {
let files;
// handle Drag and Drop
if(event.dataTransfer && event.dataTransfer.files.length > 0) {
@ -75,7 +73,7 @@ let FileDragAndDrop = React.createClass({
if(typeof this.props.onDrop === 'function' && files) {
this.props.onDrop(files);
}
}
},
handleDeleteFile(fileId) {
@ -107,14 +105,10 @@ let FileDragAndDrop = React.createClass({
},
handleOnClick() {
// do not propagate event if the drop zone's inactive,
// for example when multiple is set to false and the user already uploaded a piece
if (!this.props.dropzoneInactive) {
let evt;
// when multiple is set to false and the user already uploaded a piece,
// do not propagate event
if(this.props.dropzoneInactive) {
// if there is a handle function for doing stuff
// when the dropzone is inactive, then call it
return;
}
try {
evt = new MouseEvent('click', {
@ -129,6 +123,7 @@ let FileDragAndDrop = React.createClass({
}
this.refs.fileSelector.getDOMNode().dispatchEvent(evt);
}
},
render: function () {