提交 b9ce4c7d 编写于 作者: K KgTong

replace the table loading with spin

上级 5c1a1171
...@@ -17,7 +17,7 @@ let AntSpin = React.createClass({ ...@@ -17,7 +17,7 @@ let AntSpin = React.createClass({
render() { render() {
const props = this.props; const props = this.props;
let className = classSet({ let className = classSet({
spin: 1, spin: 1,
[`spin-${props.type}`]: 1, [`spin-${props.type}`]: 1,
......
...@@ -5,6 +5,7 @@ import Checkbox from '../checkbox'; ...@@ -5,6 +5,7 @@ import Checkbox from '../checkbox';
import FilterDropdown from './filterDropdown'; import FilterDropdown from './filterDropdown';
import Pagination from '../pagination'; import Pagination from '../pagination';
import objectAssign from 'object-assign'; import objectAssign from 'object-assign';
import Spin from '../spin';
function noop() { function noop() {
} }
...@@ -468,9 +469,6 @@ let AntTable = React.createClass({ ...@@ -468,9 +469,6 @@ let AntTable = React.createClass({
let columns = this.renderRowSelection(); let columns = this.renderRowSelection();
let classString = ''; let classString = '';
let expandIconAsCell = this.props.expandedRowRender && this.props.expandIconAsCell !== false; let expandIconAsCell = this.props.expandedRowRender && this.props.expandIconAsCell !== false;
if (this.state.loading && !this.isLocalDataSource()) {
classString += ' ant-table-loading';
}
if (this.props.size === 'small') { if (this.props.size === 'small') {
classString += ' ant-table-small'; classString += ' ant-table-small';
} }
...@@ -490,7 +488,23 @@ let AntTable = React.createClass({ ...@@ -490,7 +488,23 @@ let AntTable = React.createClass({
</div>; </div>;
emptyClass = ' ant-table-empty'; emptyClass = ' ant-table-empty';
} }
return <div className={'clearfix' + emptyClass}> // spin holder
let spinEl;
let spinWrapperClass = '';
if (this.state.loading && !this.isLocalDataSource()) {
// if there is no pagination or no data, the height of spin should decrease by half of pagination
let paginationPatchClass = (this.hasPagination() && data && data.length !== 0)
? 'ant-table-with-pagination'
: 'ant-table-without-pagination';
let spinClass = `${paginationPatchClass} ant-table-spin-holder`;
spinEl = <div className={spinClass}>
<Spin size="md" type="primary"/>
</div>;
spinWrapperClass = ' ant-table-loading';
}
return <div className={'clearfix' + emptyClass + spinWrapperClass}>
<Table <Table
{...this.props} {...this.props}
data={data} data={data}
...@@ -499,6 +513,7 @@ let AntTable = React.createClass({ ...@@ -499,6 +513,7 @@ let AntTable = React.createClass({
expandIconAsCell={expandIconAsCell} expandIconAsCell={expandIconAsCell}
/> />
{emptyText} {emptyText}
{spinEl}
{this.renderPagination()} {this.renderPagination()}
</div>; </div>;
} }
......
...@@ -82,23 +82,21 @@ ...@@ -82,23 +82,21 @@
&-loading { &-loading {
position: relative; position: relative;
.@{table-prefix-cls}-body { .@{table-prefix-cls}-body {
opacity: 0.42; opacity: 0.6;
} }
&:after { .@{table-prefix-cls}-spin-holder {
position: absolute;
display: inline-block;
.animation(loadingCircle 1.5s infinite linear);
content: "\e610";
top: 50%;
left: 50%;
margin-top: -10px;
margin-left: -10px;
font-family: anticon;
width: 20px;
height: 20px; height: 20px;
line-height: 20px; line-height: 20px;
font-size: 20px; left: 50%;
color: @primary-color; top: 50%;
margin-left: -30px;
position: absolute;
}
.@{table-prefix-cls}-with-pagination {
margin-top: -20px;
}
.@{table-prefix-cls}-without-pagination {
margin-top: 10px;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册