Skip to content

Commit

Permalink
bug(cssTransition): pass 'appearing' param from Transition to CSSTran…
Browse files Browse the repository at this point in the history
…sition
  • Loading branch information
alonbt committed Aug 3, 2017
1 parent 8968fd6 commit 93cec5d
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/CSSTransition.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ class CSSTransition extends React.Component {
const { className } = this.getClassNames(appearing ? 'appear' : 'enter')

this.removeClasses(node, 'exit');
addClass(node, className)
addClass(node, className);

if (this.props.onEnter) {
this.props.onEnter(node)
this.props.onEnter(node, appearing);
}
}

Expand All @@ -172,18 +172,18 @@ class CSSTransition extends React.Component {
appearing ? 'appear' : 'enter'
);

this.reflowAndAddClass(node, activeClassName)
this.reflowAndAddClass(node, activeClassName);

if (this.props.onEntering) {
this.props.onEntering(node)
this.props.onEntering(node, appearing);
}
}

onEntered = (node, appearing) => {
this.removeClasses(node, appearing ? 'appear' : 'enter');

if (this.props.onEntered) {
this.props.onEntered(node)
this.props.onEntered(node, appearing);
}
}

Expand Down
66 changes: 65 additions & 1 deletion test/CSSTransition-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('CSSTransition', () => {
<div/>
</CSSTransition>
)
.render();
.render();

instance.props({
in: true,
Expand All @@ -112,6 +112,70 @@ describe('CSSTransition', () => {
}
});
});

describe('isAppearing', () => {

it('should be false', done => {

instance = tsp(
<CSSTransition
timeout={10}
classNames="test"
>
<div/>
</CSSTransition>
)
.render();


instance.props({
in: true,
onEnter(node, isAppearing){
expect(isAppearing).toEqual(false);
},

onEntering(node, isAppearing){
expect(isAppearing).toEqual(false);
},

onEntered(node, isAppearing){
expect(isAppearing).toEqual(false);
done();
}
});
});

it('should be true', done => {

instance = tsp(
<CSSTransition
timeout={10}
appear={true}
in={true}
classNames="test"
>
<div/>
</CSSTransition>
)
.render();

instance.props({
onEnter(node, isAppearing){
expect(isAppearing).toEqual(true);
},

onEntering(node, isAppearing){
expect(isAppearing).toEqual(true);
},

onEntered(node, isAppearing){
expect(isAppearing).toEqual(true);
done();
}
});
});

});
});

describe('exiting', ()=> {
Expand Down

0 comments on commit 93cec5d

Please sign in to comment.