|
@ -1,26 +1,18 @@ |
|
|
import React from 'react'; |
|
|
import React from 'react'; |
|
|
import { classSet } from 'rc-util'; |
|
|
import { classSet } from 'rc-util'; |
|
|
|
|
|
import { isCssAnimationSupported } from 'css-animation'; |
|
|
const AntSpin = React.createClass({ |
|
|
const AntSpin = React.createClass({ |
|
|
getDefaultProps() { |
|
|
getDefaultProps() { |
|
|
return { |
|
|
return { |
|
|
size: 'default', |
|
|
size: 'default' |
|
|
loading: false |
|
|
|
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
propTypes: { |
|
|
propTypes: { |
|
|
loading: React.PropTypes.bool, |
|
|
|
|
|
className: React.PropTypes.string, |
|
|
className: React.PropTypes.string, |
|
|
size: React.PropTypes.oneOf(['small', 'default', 'large']) |
|
|
size: React.PropTypes.oneOf(['small', 'default', 'large']) |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
getIEVersion() { |
|
|
|
|
|
let ua = navigator.userAgent.toLowerCase(); |
|
|
|
|
|
let s = ua.match(/msie ([\d.]+)/); |
|
|
|
|
|
return s ? s[1] : false; |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
isNestedPattern() { |
|
|
isNestedPattern() { |
|
|
return this.props.children ? true : false; |
|
|
return this.props.children ? true : false; |
|
|
}, |
|
|
}, |
|
@ -28,15 +20,14 @@ const AntSpin = React.createClass({ |
|
|
render() { |
|
|
render() { |
|
|
const prefix = 'ant-spin'; |
|
|
const prefix = 'ant-spin'; |
|
|
const nestedStatus = this.isNestedPattern(); |
|
|
const nestedStatus = this.isNestedPattern(); |
|
|
const { loading, className, size, ...others } = this.props; |
|
|
const { className, size, ...others } = this.props; |
|
|
const sizeCls = ({ |
|
|
const sizeCls = ({ |
|
|
'large': 'lg', |
|
|
'large': 'lg', |
|
|
'small': 'sm' |
|
|
'small': 'sm' |
|
|
})[size] || ''; |
|
|
})[size] || ''; |
|
|
|
|
|
|
|
|
let loadingClassName = classSet({ |
|
|
let loadingClassName = classSet({ |
|
|
'ant-spin-nested-loading': nestedStatus && !!loading, |
|
|
'ant-spin-nested-loading': nestedStatus |
|
|
'ant-spin-not-nested-loading': !nestedStatus |
|
|
|
|
|
}); |
|
|
}); |
|
|
let spinClassName = classSet({ |
|
|
let spinClassName = classSet({ |
|
|
'ant-spin': true, |
|
|
'ant-spin': true, |
|
@ -44,9 +35,8 @@ const AntSpin = React.createClass({ |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
let spinEl; |
|
|
let spinEl; |
|
|
let _IE = this.getIEVersion(); |
|
|
if (!isCssAnimationSupported) { |
|
|
if (_IE === '8.0' || _IE === '9.0') { |
|
|
// not support for animation, just use text instead |
|
|
// IE 8 or IE 9 |
|
|
|
|
|
spinEl = <div className={ spinClassName }>加载中...</div>; |
|
|
spinEl = <div className={ spinClassName }>加载中...</div>; |
|
|
}else { |
|
|
}else { |
|
|
let spinWrapperClassName = classSet({ |
|
|
let spinWrapperClassName = classSet({ |
|
|