feat: debounce before spinning => debounce after spinning (#2486)

This commit is contained in:
陆离 2016-07-25 16:31:59 +08:00 committed by Benjy Cui
parent ca57794ae7
commit ac32dd5811

View File

@ -52,12 +52,13 @@ export default class Spin extends React.Component {
}
componentWillReceiveProps(nextProps) {
const currentSpinning = this.getSpinning(this.props);
const spinning = this.getSpinning(nextProps);
if (this.debounceTimeout) {
clearTimeout(this.debounceTimeout);
}
if (spinning) {
this.debounceTimeout = setTimeout(() => this.setState({ spinning }), 250);
if (currentSpinning && !spinning) {
this.debounceTimeout = setTimeout(() => this.setState({ spinning }), 500);
} else {
this.setState({ spinning });
}