Skip to content

Commit a680f5d

Browse files
committed
move set start style to getInitAnimType
1 parent 9ba82a7 commit a680f5d

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/QueueAnim.jsx

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ const BackEase = {
107107

108108
const placeholderKeyPrefix = 'ant-queue-anim-placeholder-';
109109

110+
const noop = () => {
111+
};
112+
110113
class QueueAnim extends React.Component {
111114
constructor() {
112115
super(...arguments);
@@ -262,27 +265,35 @@ class QueueAnim extends React.Component {
262265
* 而不是 animTypes 里的初始值,如果是初始值将会跳动。
263266
*/
264267
const data = { ...assignChild(velocityConfig) };
265-
const transformsBase = velocity &&
268+
const transformsBase = velocity && velocity.prototype.constructor &&
266269
velocity.prototype.constructor.CSS.Lists.transformsBase || [];
270+
const setPropertyValue = velocity && velocity.prototype.constructor &&
271+
velocity.prototype.constructor.CSS.setPropertyValue || noop;
272+
const getUnitType = velocity && velocity.prototype.constructor &&
273+
velocity.prototype.constructor.CSS.Values.getUnitType || noop;
267274
const nodeStyle = node.style;
268275
Object.keys(data).forEach(dataKey => {
276+
let cssName = dataKey;
269277
if (transformsBase.indexOf(dataKey) >= 0) {
270-
const transformString = nodeStyle[checkStyleName('transform')];
278+
cssName = 'transform';
279+
const transformString = nodeStyle[checkStyleName(cssName)];
271280
if (transformString && transformString !== 'none') {
272281
if (transformString.match(dataKey)) {
273282
const rep = new RegExp(`^.*${dataKey}\\(([^\\)]+?)\\).*`, 'i');
274283
const transformData = transformString.replace(rep, '$1');
275284
data[dataKey][1] = parseFloat(transformData);
276285
return;
277286
}
287+
} else {
288+
data[dataKey][1] = 0;
278289
}
279-
data[dataKey][1] = 0;
280-
}
281-
if (nodeStyle[dataKey] && parseFloat(nodeStyle[dataKey])) {
290+
} else if (nodeStyle[dataKey] && parseFloat(nodeStyle[dataKey])) {
282291
data[dataKey][1] = parseFloat(nodeStyle[dataKey]);
283292
} else {
284293
data[dataKey][1] = 0;
285294
}
295+
// 先把初始值设进 style 里。免得跳动;把下面的设置放到这里。
296+
setPropertyValue(node, cssName, `${data[dataKey][1]}${getUnitType(dataKey)}`);
286297
});
287298
return data;
288299
};
@@ -334,22 +345,13 @@ class QueueAnim extends React.Component {
334345
return;
335346
}
336347
const interval = transformArguments(this.props.interval, key, i)[1];
337-
let delay = transformArguments(this.props.delay, key, i)[1];
338-
let duration = transformArguments(this.props.duration, key, i)[1];
348+
const delay = transformArguments(this.props.delay, key, i)[1];
349+
const duration = transformArguments(this.props.duration, key, i)[1];
339350
const order = this.props.leaveReverse ? (this.keysToLeave.length - i - 1) : i;
340351
velocity(node, 'stop');
341-
delay = interval * order + delay;
342352
const data = this.getInitAnimType(node, this.getVelocityLeaveConfig(key, i));
343-
// 当数据为 [0, 0] 时,,有延时的话会出现跳动。。。
344-
Object.keys(data).forEach(dataKey => {
345-
const item = data[dataKey];
346-
if (Array.isArray(item) && item[0] === 0 && item[1] === 0) {
347-
delay = 0;
348-
duration = 0;
349-
}
350-
});
351353
velocity(node, data, {
352-
delay,
354+
delay: interval * order + delay,
353355
duration,
354356
easing: this.getVelocityEasing(key, i)[1],
355357
begin: this.leaveBegin.bind(this),

0 commit comments

Comments
 (0)