From 93cec5df76c5e564c9af54b4cd8bc876305b337b Mon Sep 17 00:00:00 2001 From: Alon Bartur Date: Thu, 3 Aug 2017 22:52:52 +0300 Subject: [PATCH] bug(cssTransition): pass 'appearing' param from Transition to CSSTransition --- src/CSSTransition.js | 10 +++--- test/CSSTransition-test.js | 66 +++++++++++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 6 deletions(-) diff --git a/src/CSSTransition.js b/src/CSSTransition.js index a3da236d..956cdc85 100644 --- a/src/CSSTransition.js +++ b/src/CSSTransition.js @@ -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); } } @@ -172,10 +172,10 @@ 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); } } @@ -183,7 +183,7 @@ class CSSTransition extends React.Component { this.removeClasses(node, appearing ? 'appear' : 'enter'); if (this.props.onEntered) { - this.props.onEntered(node) + this.props.onEntered(node, appearing); } } diff --git a/test/CSSTransition-test.js b/test/CSSTransition-test.js index ff98507d..b2289350 100644 --- a/test/CSSTransition-test.js +++ b/test/CSSTransition-test.js @@ -90,7 +90,7 @@ describe('CSSTransition', () => {
) - .render(); + .render(); instance.props({ in: true, @@ -112,6 +112,70 @@ describe('CSSTransition', () => { } }); }); + + describe('isAppearing', () => { + + it('should be false', done => { + + instance = tsp( + +
+ + ) + .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( + +
+ + ) + .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', ()=> {