Skip to content

Commit

Permalink
publish 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yangchch6 committed Jan 15, 2020
1 parent cada233 commit f48f741
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<a name="2.1.0"></a>
# [2.1.0](https://github.com/tinper-bee/upload/compare/v2.0.8...v2.1.0) (2020-01-15)



<a name="2.0.8"></a>
## [2.0.8](https://github.com/tinper-bee/upload/compare/v2.0.7...v2.0.8) (2019-12-20)

Expand Down
3 changes: 3 additions & 0 deletions build/Upload.css
Original file line number Diff line number Diff line change
Expand Up @@ -2684,3 +2684,6 @@
to {
margin-top: -25px;
opacity: 0; } }

.u-upload.u-upload-drag-hover * {
pointer-events: none; }
28 changes: 24 additions & 4 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ var Upload = function (_Component) {

// beforeUpload=(file,fileList)=>{
// this.props.beforeUpload(file,this.state.fileList)
// }
// }

};

Expand Down Expand Up @@ -289,6 +289,24 @@ var Upload = function (_Component) {
}
};

_this.onDragEnter = function (e) {
_this.lastenter = e.target; // 记录最后进入的元素
_this.setState({
dragState: 'dragover'
});
};

_this.onDragLeave = function (e) {
// 如果此时退的元素是最后进入的元素,说明是真正退出了`drag-zone`元素
if (_this.lastenter === e.target) {
_this.setState({
dragState: e.type
});
e.stopPropagation();
e.preventDefault();
}
};

_this.onFileDrop = function (e) {
_this.setState({
dragState: e.type
Expand Down Expand Up @@ -317,6 +335,7 @@ var Upload = function (_Component) {
fileList: _this.props.fileList || _this.props.defaultFileList || [],
dragState: 'drop'
};
_this.lastenter = null;
return _this;
}

Expand Down Expand Up @@ -444,9 +463,10 @@ var Upload = function (_Component) {
'div',
{
className: dragCls,
onDrop: this.onFileDrop,
onDragOver: this.onFileDrop,
onDragLeave: this.onFileDrop
onDrop: this.onFileDrop
// onDragOver={this.onFileDrop}
, onDragLeave: this.onDragLeave,
onDragEnter: this.onDragEnter
},
_react2["default"].createElement(
_Upload2["default"],
Expand Down
3 changes: 3 additions & 0 deletions dist/demo.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/demo.css.map

Large diffs are not rendered by default.

45 changes: 34 additions & 11 deletions dist/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -36690,10 +36690,11 @@
_this.state = {
previewVisible: false,
previewImage: ''
};

_this.beforeUpload = function (file, fileList) {
_this.props.beforeUpload(file, _this.state.fileList);
// beforeUpload=(file,fileList)=>{
// this.props.beforeUpload(file,this.state.fileList)
// }

};

_this.onStart = function (file) {
Expand Down Expand Up @@ -36790,6 +36791,24 @@
}
};

_this.onDragEnter = function (e) {
_this.lastenter = e.target; // 记录最后进入的元素
_this.setState({
dragState: 'dragover'
});
};

_this.onDragLeave = function (e) {
// 如果此时退的元素是最后进入的元素,说明是真正退出了`drag-zone`元素
if (_this.lastenter === e.target) {
_this.setState({
dragState: e.type
});
e.stopPropagation();
e.preventDefault();
}
};

_this.onFileDrop = function (e) {
_this.setState({
dragState: e.type
Expand Down Expand Up @@ -36818,6 +36837,7 @@
fileList: _this.props.fileList || _this.props.defaultFileList || [],
dragState: 'drop'
};
_this.lastenter = null;
return _this;
}

Expand Down Expand Up @@ -36918,8 +36938,8 @@
onStart: this.onStart,
onError: this.onError,
onProgress: this.onProgress,
onSuccess: this.onSuccess,
beforeUpload: this.beforeUpload
onSuccess: this.onSuccess
// beforeUpload:this.beforeUpload
});
delete rcUploadProps.className;

Expand All @@ -36945,9 +36965,10 @@
'div',
{
className: dragCls,
onDrop: this.onFileDrop,
onDragOver: this.onFileDrop,
onDragLeave: this.onFileDrop
onDrop: this.onFileDrop
// onDragOver={this.onFileDrop}
, onDragLeave: this.onDragLeave,
onDragEnter: this.onDragEnter
},
_react2['default'].createElement(
_Upload2['default'],
Expand Down Expand Up @@ -37384,13 +37405,15 @@
if (file && file.uid) {
uid = file.uid;
}
if (reqs[uid]) {
if (reqs[uid] && reqs[uid].abort) {
reqs[uid].abort();
delete reqs[uid];
}
delete reqs[uid];
} else {
Object.keys(reqs).forEach(function (uid) {
reqs[uid].abort();
if (reqs[uid] && reqs[uid].abort) {
reqs[uid].abort();
}
delete reqs[uid];
});
}
Expand Down
2 changes: 1 addition & 1 deletion dist/demo.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bee-upload",
"version": "2.0.8",
"version": "2.1.0",
"description": "upload ui component for react",
"keywords": [
"react",
Expand Down
4 changes: 4 additions & 0 deletions src/Upload.scss
Original file line number Diff line number Diff line change
Expand Up @@ -469,3 +469,7 @@
opacity: 0;
}
}
// fix: dragleave-of-parent-element-fires-when-dragging-over-children-elements
.u-upload.u-upload-drag-hover * {
pointer-events: none;
}
30 changes: 25 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class Upload extends Component {
fileList: this.props.fileList || this.props.defaultFileList || [],
dragState: 'drop',
};
this.lastenter = null;
}
state = {
previewVisible: false,
Expand All @@ -151,7 +152,7 @@ class Upload extends Component {

// beforeUpload=(file,fileList)=>{
// this.props.beforeUpload(file,this.state.fileList)
// }
// }

onStart = (file) => {
let targetItem;
Expand Down Expand Up @@ -310,10 +311,28 @@ class Upload extends Component {
}
}

onDragEnter = (e) => {
this.lastenter = e.target; // 记录最后进入的元素
this.setState({
dragState: 'dragover'
})
}

onDragLeave = (e) => {
// 如果此时退的元素是最后进入的元素,说明是真正退出了`drag-zone`元素
if(this.lastenter === e.target){
this.setState({
dragState: e.type
})
e.stopPropagation();
e.preventDefault();
}
}

onFileDrop = (e) => {
this.setState({
dragState: e.type,
});
dragState: e.type
})
}

clearProgressTimer() {
Expand Down Expand Up @@ -373,8 +392,9 @@ class Upload extends Component {
<div
className={dragCls}
onDrop={this.onFileDrop}
onDragOver={this.onFileDrop}
onDragLeave={this.onFileDrop}
// onDragOver={this.onFileDrop}
onDragLeave={this.onDragLeave}
onDragEnter={this.onDragEnter}
>
<RcUpload {...rcUploadProps} ref="upload" className={`${clsPrefix}-btn`}>
<div className={`${clsPrefix}-drag-container`}>
Expand Down

0 comments on commit f48f741

Please sign in to comment.