Skip to content

Commit

Permalink
Fix to work enter animation with CSSTransitionGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 committed Feb 8, 2017
1 parent f00acae commit e3ad7e4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/CSSTransitionGroupChild.js
@@ -1,12 +1,14 @@
import addClass from 'dom-helpers/class/addClass';
import removeClass from 'dom-helpers/class/removeClass';
import raf from 'dom-helpers/util/requestAnimationFrame';
import { transitionEnd, animationEnd } from 'dom-helpers/transition/properties';
import React from 'react';
import { findDOMNode } from 'react-dom';

import { nameShape } from './utils/PropTypes';

const TICK = 17;
const nextTick = cb => setTimeout(cb, TICK);

let events = [];
if (transitionEnd) events.push(transitionEnd);
if (animationEnd) events.push(animationEnd);
Expand Down Expand Up @@ -117,8 +119,8 @@ class CSSTransitionGroupChild extends React.Component {
node,
});

if (!this.rafHandle) {
this.rafHandle = raf(() => this.flushClassNameAndNodeQueue());
if (!this.nextTickHandle) {
this.nextTickHandle = nextTick(() => this.flushClassNameAndNodeQueue());
}
}

Expand All @@ -129,7 +131,7 @@ class CSSTransitionGroupChild extends React.Component {
});
}
this.classNameAndNodeQueue.length = 0;
this.rafHandle = null;
this.nextTickHandle = null;
}

componentWillAppear = (done) => {
Expand Down Expand Up @@ -165,6 +167,7 @@ class CSSTransitionGroupChild extends React.Component {
delete props.appearTimeout;
delete props.enterTimeout;
delete props.leaveTimeout;
delete props.children;
return React.cloneElement(React.Children.only(this.props.children), props);
}
}
Expand Down

0 comments on commit e3ad7e4

Please sign in to comment.