Skip to content

Commit 7ccac40

Browse files
committed
Merge pull request #9 from react-component/reg-style
fix leaving or entering overlap
2 parents ac80a27 + 1e7d898 commit 7ccac40

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/QueueAnim.jsx

Lines changed: 19 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,7 +225,13 @@ class QueueAnim extends React.Component {
223225

224226
enterBegin(key, elements) {
225227
elements.forEach((elem) => {
226-
elem.className += (' ' + this.props.animatingClassName[0]);
228+
const animatingClassName = this.props.animatingClassName;
229+
if (elem.className.indexOf(animatingClassName[1]) >= 0) {
230+
elem.className = elem.className.replace(animatingClassName[1], '');
231+
}
232+
if (elem.className.indexOf(' ' + animatingClassName[0]) === -1) {
233+
elem.className += (' ' + animatingClassName[0]);
234+
}
227235
});
228236
}
229237

@@ -238,7 +246,13 @@ class QueueAnim extends React.Component {
238246

239247
leaveBegin(elements) {
240248
elements.forEach((elem) => {
241-
elem.className += (' ' + this.props.animatingClassName[1]);
249+
const animatingClassName = this.props.animatingClassName;
250+
if (elem.className.indexOf(animatingClassName[0]) >= 0) {
251+
elem.className = elem.className.replace(animatingClassName[0], '');
252+
}
253+
if (elem.className.indexOf(animatingClassName[1]) === -1) {
254+
elem.className += (' ' + animatingClassName[1]);
255+
}
242256
});
243257
}
244258

0 commit comments

Comments
 (0)