From 10284a997c638f2bcfff126d0a30f8e4909209ad Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 21 Aug 2015 14:46:12 +0800 Subject: [PATCH] Fix upload bug in safari and ie8/9, ref #138 --- components/upload/index.jsx | 22 ++++++++++++---------- style/components/upload.less | 29 +++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/components/upload/index.jsx b/components/upload/index.jsx index 8cb3f377b..7cf510aa3 100644 --- a/components/upload/index.jsx +++ b/components/upload/index.jsx @@ -25,9 +25,9 @@ let AntUpload = React.createClass({ }); }, handleSuccess(ret, file) { - var matchWay = file.uid === '' ? 'byName' : 'byUid'; + let matchWay = (!file.uid) ? 'byName' : 'byUid'; Message.success(file.name + '上传完成'); - for (var i = 0; i < this.state.downloadList.length; i++) { + for (let i = 0; i < this.state.downloadList.length; i++) { if (matchWay === 'byName') { if (this.state.downloadList[i].filename === file.name) { this.state.downloadList[i].status = 'done'; @@ -84,20 +84,22 @@ let AntUpload = React.createClass({ }; if (type === 'drag') { return ( - -
+
+
{this.props.children}
-
- + +
); } else if (type === 'select') { return ( -
- - {this.props.children} - +
+
+ + {this.props.children} + +
); diff --git a/style/components/upload.less b/style/components/upload.less index 32bafd178..5cf3f31a3 100644 --- a/style/components/upload.less +++ b/style/components/upload.less @@ -1,6 +1,21 @@ @upload-prefix-cls: ant-upload; .@{upload-prefix-cls} { + + > span { + display: block; + width: 100%; + height: 100%; + } + + input[type=file] { + cursor: pointer; + } + + &.@{upload-prefix-cls}-select { + display: inline-block; + } + &.@{upload-prefix-cls}-drag { border: 1px dashed #d9d9d9; transition: all 0.3s ease; @@ -11,13 +26,15 @@ height: 100%; position: relative; - .@{upload-prefix-cls}-drag-container { - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - width: 100%; + > span { + display: table; } + + .@{upload-prefix-cls}-drag-container { + display: table-cell; + vertical-align: middle; + } + &:hover { border: 1px dashed #999; }