mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-21 08:29:18 +08:00
Merge pull request #504 from ant-design/feat-upload-drag-hover
feat add hover style
This commit is contained in:
commit
e9e9932182
@ -49,7 +49,8 @@ function genPercentAdd() {
|
|||||||
const AntUpload = React.createClass({
|
const AntUpload = React.createClass({
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return {
|
return {
|
||||||
fileList: this.props.fileList || this.props.defaultFileList || []
|
fileList: this.props.fileList || this.props.defaultFileList || [],
|
||||||
|
dragState: 'drop'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onStart(file) {
|
onStart(file) {
|
||||||
@ -178,6 +179,17 @@ const AntUpload = React.createClass({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onFileDrop(e) {
|
||||||
|
if (e.type === 'dragover') {
|
||||||
|
this.setState({
|
||||||
|
dragState: 'dragover'
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
dragState: 'drop'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
clearProgressTimer() {
|
clearProgressTimer() {
|
||||||
clearInterval(this.progressTimer);
|
clearInterval(this.progressTimer);
|
||||||
},
|
},
|
||||||
@ -196,14 +208,15 @@ const AntUpload = React.createClass({
|
|||||||
if (type === 'drag') {
|
if (type === 'drag') {
|
||||||
let dragUploadingClass = '';
|
let dragUploadingClass = '';
|
||||||
let fileList = this.state.fileList;
|
let fileList = this.state.fileList;
|
||||||
|
const dragState = this.state.dragState;
|
||||||
for (let i = 0; i < fileList.length; i ++) {
|
for (let i = 0; i < fileList.length; i ++) {
|
||||||
if (fileList[i].status === 'uploading') {
|
if (fileList[i].status === 'uploading') {
|
||||||
dragUploadingClass = ` ${prefixCls}-drag-uploading`;
|
dragUploadingClass = ` ${prefixCls}-drag-uploading ${dragState === 'drop' ? '' : `${prefixCls}-drag-hover`}`;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div className={prefixCls + ' ' + prefixCls + '-drag-area'}>
|
<div className={prefixCls + ' ' + prefixCls + '-drag-area'} onDrop={this.onFileDrop} onDragOver={this.onFileDrop}>
|
||||||
<div className={prefixCls + ' ' + prefixCls + '-drag' + dragUploadingClass}>
|
<div className={prefixCls + ' ' + prefixCls + '-drag' + dragUploadingClass}>
|
||||||
<Upload {...props}>
|
<Upload {...props}>
|
||||||
<div className={prefixCls + '-drag-container'}>
|
<div className={prefixCls + '-drag-container'}>
|
||||||
|
@ -25,6 +25,10 @@
|
|||||||
height: 180px;
|
height: 180px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
&.@{upload-prefix-cls}-drag-hover {
|
||||||
|
border-color: tint(@primary-color, 20%);
|
||||||
|
}
|
||||||
|
|
||||||
> span {
|
> span {
|
||||||
display: table;
|
display: table;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
Loading…
Reference in New Issue
Block a user