Skip to content

Commit 3cc5de7

Browse files
committed
fix leaving or entering overlap
1 parent ac80a27 commit 3cc5de7

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/QueueAnim.jsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { createElement, cloneElement } from 'react';
22
import { findDOMNode } from 'react-dom';
33

44
let velocity;
5-
if ( typeof document !== 'undefined' && typeof window !== 'undefined' ) {
5+
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
66
// only load velocity on the client
77
velocity = require('velocity-animate');
88
} else {
@@ -11,7 +11,9 @@ if ( typeof document !== 'undefined' && typeof window !== 'undefined' ) {
1111
const callback = arguments[arguments.length - 1];
1212
// call after stack flushes
1313
// in case you app depends on the asyncron nature of this function
14-
setImmediate(function() { callback(); });
14+
setImmediate(function() {
15+
callback();
16+
});
1517
};
1618
}
1719

@@ -21,7 +23,7 @@ import {
2123
mergeChildren,
2224
transformArguments,
2325
getChildrenFromProps,
24-
} from './utils';
26+
} from './utils';
2527
import AnimTypes from './animTypes';
2628

2729
const BackEase = {
@@ -223,6 +225,9 @@ class QueueAnim extends React.Component {
223225

224226
enterBegin(key, elements) {
225227
elements.forEach((elem) => {
228+
const currentClassName = this.props.animatingClassName[1];
229+
const reg = new RegExp(currentClassName, 'ig');
230+
elem.className = elem.className.replace(reg, '');
226231
elem.className += (' ' + this.props.animatingClassName[0]);
227232
});
228233
}
@@ -232,12 +237,17 @@ class QueueAnim extends React.Component {
232237
this.keysAnimating.splice(this.keysAnimating.indexOf(key), 1);
233238
}
234239
elements.forEach((elem) => {
235-
elem.className = elem.className.replace(this.props.animatingClassName[0], '').trim();
240+
const currentClassName = this.props.animatingClassName[0];
241+
const reg = new RegExp(currentClassName, 'ig');
242+
elem.className = elem.className.replace(reg, '').trim();
236243
});
237244
}
238245

239246
leaveBegin(elements) {
240247
elements.forEach((elem) => {
248+
const currentClassName = this.props.animatingClassName[0];
249+
const reg = new RegExp(currentClassName, 'ig');
250+
elem.className = elem.className.replace(reg, '');
241251
elem.className += (' ' + this.props.animatingClassName[1]);
242252
});
243253
}
@@ -261,7 +271,9 @@ class QueueAnim extends React.Component {
261271
});
262272
}
263273
elements.forEach((elem) => {
264-
elem.className = elem.className.replace(this.props.animatingClassName[1], '').trim();
274+
const currentClassName = this.props.animatingClassName[1];
275+
const reg = new RegExp(currentClassName, 'ig');
276+
elem.className = elem.className.replace(reg, '').trim();
265277
});
266278
}
267279

0 commit comments

Comments
 (0)