mirror of
https://github.com/ascribe/onion.git
synced 2025-01-03 18:35:09 +01:00
Rearrange handleDrop() to flow more naturally
This commit is contained in:
parent
fe24a5e15a
commit
916ec7aace
@ -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 () {
|
||||
|
Loading…
Reference in New Issue
Block a user