Skip to content

Commit e180baa

Browse files
committed
add placeholderNode to timeout
1 parent aa5d6f9 commit e180baa

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

src/QueueAnim.jsx

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class QueueAnim extends React.Component {
2626
this.keysToLeave = [];
2727
this.keysAnimating = [];
2828

29+
this.placeholder = {};
30+
2931
// 第一次进入,默认进场
3032
const children = toArrayChildren(getChildrenFromProps(this.props));
3133
children.forEach(child => {
@@ -148,22 +150,22 @@ class QueueAnim extends React.Component {
148150
}
149151

150152
performEnter(key, i) {
151-
/*
152-
*占位符在暴击时是不存在的,所以用create
153-
*/
154-
const placeholderNode = document.createElement('div');
155-
if (!placeholderNode) {
156-
return;
157-
}
153+
/* const placeholderNode = findDOMNode(this.refs[placeholderKeyPrefix + key]);
154+
if (!placeholderNode) {
155+
return;
156+
}*/
157+
158158
const interval = transformArguments(this.props.interval, key, i)[0];
159159
const delay = transformArguments(this.props.delay, key, i)[0];
160-
placeholderNode.style.visibility = 'hidden';
161-
velocity(placeholderNode, 'stop');
162-
velocity(placeholderNode, {opacity: [0, 0]}, {
163-
delay: interval * i + delay,
164-
duration: 0,
165-
begin: this.performEnterBegin.bind(this, key, i),
166-
});
160+
/*
161+
placeholderNode.style.visibility = 'hidden';
162+
velocity(placeholderNode, 'stop', true);
163+
velocity(placeholderNode, {opacity: [0, 0]}, {
164+
delay: interval * i + delay,
165+
duration: 0,
166+
begin: this.performEnterBegin.bind(this, key, i),
167+
});*/
168+
this.placeholder[key] = setTimeout(this.performEnterBegin.bind(this, key, i), interval * i + delay);
167169
if (this.keysToEnter.indexOf(key) >= 0) {
168170
this.keysToEnter.splice(this.keysToEnter.indexOf(key), 1);
169171
}
@@ -200,14 +202,19 @@ class QueueAnim extends React.Component {
200202

201203
performLeave(key, i) {
202204
const node = findDOMNode(this.refs[key]);
205+
/*
206+
this.placeholder.forEach((item)=> {
207+
velocity(item, 'stop', true);
208+
});*/
209+
clearTimeout(this.placeholder[key]);
203210
if (!node) {
204211
return;
205212
}
206213
const interval = transformArguments(this.props.interval, key, i)[1];
207214
const delay = transformArguments(this.props.delay, key, i)[1];
208215
const duration = transformArguments(this.props.duration, key, i)[1];
209216
const order = this.props.leaveReverse ? (this.keysToLeave.length - i - 1) : i;
210-
velocity(node, 'stop');
217+
velocity(node, 'stop', true);
211218
velocity(node, this.getVelocityLeaveConfig(key, i), {
212219
delay: interval * order + delay,
213220
duration: duration,
@@ -248,7 +255,13 @@ class QueueAnim extends React.Component {
248255
if (this.keysToLeave.indexOf(key) >= 0) {
249256
this.keysToLeave.splice(this.keysToLeave.indexOf(key), 1);
250257
}
251-
if (this.keysToLeave.length === 0) {
258+
let leaveEnd;
259+
this.keysToLeave.forEach((c)=> {
260+
if (childrenShow[c]) {
261+
leaveEnd = true;
262+
}
263+
});
264+
if (!leaveEnd) {
252265
const currentChildren = toArrayChildren(getChildrenFromProps(this.props));
253266
this.setState({
254267
children: currentChildren,

0 commit comments

Comments
 (0)