Skip to content

Commit

Permalink
add both className and node to the queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyan Zhang committed Jun 3, 2016
1 parent aca7a1b commit a899587
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/addons/transitions/ReactCSSTransitionGroupChild.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var ReactCSSTransitionGroupChild = React.createClass({
CSSCore.addClass(node, className);

// Need to do this to actually trigger a transition.
this.queueClass(activeClassName);
this.queueClassAndNode(activeClassName, node);

// If the user specified a timeout delay.
if (userSpecifiedDelay) {
Expand All @@ -102,26 +102,29 @@ var ReactCSSTransitionGroupChild = React.createClass({
}
},

queueClass: function(className) {
this.classNameQueue.push(className);
queueClassAndNode: function(className, node) {
this.classNameAndNodeQueue.push({
className: className,
node: node,
});

if (!this.timeout) {
this.timeout = setTimeout(this.flushClassNameQueue, TICK);
this.timeout = setTimeout(this.flushClassNameAndNodeQueue, TICK);
}
},

flushClassNameQueue: function() {
flushClassNameAndNodeQueue: function() {
if (this.isMounted()) {
this.classNameQueue.forEach(
CSSCore.addClass.bind(CSSCore, ReactDOM.findDOMNode(this))
);
this.classNameAndNodeQueue.forEach(function(obj) {
CSSCore.addClass(obj.node, obj.className);
});
}
this.classNameQueue.length = 0;
this.classNameAndNodeQueue.length = 0;
this.timeout = null;
},

componentWillMount: function() {
this.classNameQueue = [];
this.classNameAndNodeQueue = [];
this.transitionTimeouts = [];
},

Expand All @@ -132,6 +135,8 @@ var ReactCSSTransitionGroupChild = React.createClass({
this.transitionTimeouts.forEach(function(timeout) {
clearTimeout(timeout);
});

this.classNameAndNodeQueue.length = 0;
},

componentWillAppear: function(done) {
Expand Down

0 comments on commit a899587

Please sign in to comment.