Browse Source

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

pull/2489/head
陆离 8 years ago
committed by Benjy Cui
parent
commit
0f6a8e2ff7
  1. 5
      components/spin/index.tsx

5
components/spin/index.tsx

@ -53,12 +53,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 });
}

Loading…
Cancel
Save