Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(CSSTransition): done classname for appearing #383

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/CSSTransition.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const propTypes = {
* classNames={{
* appear: 'my-appear',
* appearActive: 'my-active-appear',
* appearDone: 'my-done-appear',
* enter: 'my-enter',
* enterActive: 'my-active-enter',
* enterDone: 'my-done-enter',
Expand All @@ -50,6 +51,7 @@ const propTypes = {
* @type {string | {
* appear?: string,
* appearActive?: string,
* appearDone?: string,
* enter?: string,
* enterActive?: string,
* enterDone?: string,
Expand Down Expand Up @@ -147,7 +149,9 @@ class CSSTransition extends React.Component {
}

onEntered = (node, appearing) => {
const { doneClassName } = this.getClassNames('enter');
const { doneClassName } = this.getClassNames(
appearing ? 'appear' : 'enter'
);

this.removeClasses(node, appearing ? 'appear' : 'enter');
addClass(node, doneClassName);
Expand Down
65 changes: 65 additions & 0 deletions test/CSSTransition-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,71 @@ describe('CSSTransition', () => {
});
});

describe('appearing', () => {

beforeEach(() => {
});

it('should apply classes at each transition state', done => {
let count = 0;

mount(
<CSSTransition
appear
in
timeout={10}
classNames="test"
onEnter={(node) => {
count++;
expect(node.className).toEqual('test-appear');
}}
onEntering={(node) => {
count++;
expect(node.className).toEqual('test-appear test-appear-active');
}}
onEntered={(node) => {
expect(node.className).toEqual('test-appear-done');
expect(count).toEqual(2);
done();
}}
>
<div/>
</CSSTransition>
)
});

it('should apply custom classNames names', done => {
let count = 0;
mount(
<CSSTransition
appear
in
timeout={10}
classNames={{
appear: 'custom',
appearActive: 'custom-super-active',
appearDone: 'custom-super-done',
}}
onEnter={(node) => {
count++;
expect(node.className).toEqual('custom');
}}
onEntering={(node) => {
count++;
expect(node.className).toEqual('custom custom-super-active');
}}
onEntered={(node) => {
expect(node.className).toEqual('custom-super-done');
expect(count).toEqual(2);
done();
}}
>
<div/>
</CSSTransition>
);
});
});

describe('exiting', ()=> {
let instance;

Expand Down