Skip to content

Commit 2b830d9

Browse files
committed
fix empty child refresh stopped animate
1 parent 9e4d3f8 commit 2b830d9

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

examples/custom-ease.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import ReactDom from 'react-dom';
55

66
ReactDom.render(
77
<div style={{ height: 500 }}>
8-
<QueueAnim ease={[0.175, 0.885, 0.32, 1.275]}>
8+
<QueueAnim ease={[[0.175, 0.885, 0.32, 1.275]]}>
99
<div key="1">div 1</div>
1010
<div key="2">div 1</div>
1111
<div key="3">div 1</div>

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-queue-anim",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "Queue animation component for react",
55
"keywords": [
66
"react",
@@ -54,13 +54,12 @@
5454
"expect.js": "0.3.x",
5555
"pre-commit": "1.x",
5656
"rc-test": "6.x",
57-
"rc-tools": "6.x",
57+
"rc-tools": "7.x",
5858
"react": "^16.0.0",
5959
"react-dom": "^16.0.0",
6060
"antd": "^2.12.3",
61-
"jquery": "~1.11.3",
6261
"precommit-hook": "1.x",
63-
"rc-dialog": "~5.2.1",
62+
"rc-dialog": "~7.0.4",
6463
"react-router-dom": "^4.1.0",
6564
"react-router": "~4.1.0"
6665
},

src/QueueAnim.jsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ class QueueAnim extends React.Component {
8787
}
8888

8989
componentWillReceiveProps(nextProps) {
90-
const nextChildren = toArrayChildren(nextProps.children);
91-
let currentChildren = this.originalChildren;
92-
if (!nextChildren.length && !currentChildren.length && this.state.children.length) {
90+
const nextChildren = toArrayChildren(nextProps.children).filter(item => item);
91+
let currentChildren = this.originalChildren.filter(item => item);
92+
const emptyBool = !nextChildren.length && !currentChildren.length && this.state.children.length;
93+
if (emptyBool) {
9394
/**
9495
* 多次刷新空子级处理
9596
* 如果 state.children 里还有元素,元素还在动画,当前子级设回 state.children;
@@ -104,14 +105,16 @@ class QueueAnim extends React.Component {
104105
const childrenShow = !newChildren.length ? {} : this.state.childrenShow;
105106
this.keysToEnterPaused = {};
106107
// 在出场没结束时,childrenShow 里的值将不会清除。再触发进场时, childrenShow 里的值是保留着的, 设置了 enterForcedRePlay 将重新播放进场。
107-
this.keysToLeave.forEach(key => {
108-
// 将所有在出场里的停止掉。避免间隔性出现
109-
this.keysToEnterPaused[key] = true;
110-
if (nextProps.enterForcedRePlay) {
111-
// 清掉所有出场的。
112-
delete childrenShow[key];
113-
}
114-
});
108+
if (!emptyBool) {// 空子级状态下刷新不做处理
109+
this.keysToLeave.forEach(key => {
110+
// 将所有在出场里的停止掉。避免间隔性出现
111+
this.keysToEnterPaused[key] = true;
112+
if (nextProps.enterForcedRePlay) {
113+
// 清掉所有出场的。
114+
delete childrenShow[key];
115+
}
116+
});
117+
}
115118

116119
this.keysToEnter = [];
117120
this.keysToLeave = [];
@@ -295,6 +298,7 @@ class QueueAnim extends React.Component {
295298
}
296299
}
297300
const paused = this.keysToEnterPaused[key] && !this.keysToLeave.indexOf(key) >= 0;
301+
298302
animation = paused ? null : animation;
299303
const isFunc = typeof child.type === 'function';
300304
const forcedJudg = isFunc ? {} : null;

0 commit comments

Comments
 (0)