Skip to content
Open
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
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ Example
import React from 'react';
import ReactDOM from 'react-dom';
import ReactDrawer from 'react-drawer';

/* if you using webpack, should not apply identity to this css */
import 'react-drawer/lib/react-drawer.css';

class Main extends React.Component {
Expand Down
4 changes: 2 additions & 2 deletions src/ReactDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class ReactDrawer extends React.Component {
componentWillMount() {
this.setState({
open: this.props.open,
hiddenOverlay: true,
hiddenDrawer: true
hiddenOverlay: !this.props.open,
hiddenDrawer: !this.props.open
});
}

Expand Down
14 changes: 8 additions & 6 deletions src/ReactDrawer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ describe('ReactDrawer', () => {
);
let instance = wrapper.instance();
expect(instance.state.open).toBe(false);
expect(instance.state.hiddenOverlay).toBe(true);
expect(instance.state.hiddenDrawer).toBe(true);
wrapper = mount(
<ReactDrawer open />
);
instance = wrapper.instance();
expect(instance.state.open).toBe(true);
expect(instance.state.hiddenOverlay).toBe(true);
expect(instance.state.hiddenDrawer).toBe(true);
expect(instance.state.hiddenOverlay).toBe(false);
expect(instance.state.hiddenDrawer).toBe(false);
});

it('should closeDrawer set some state', () => {
Expand Down Expand Up @@ -145,11 +147,11 @@ describe('ReactDrawer', () => {
);
const instance = wrapper.instance();
let c = instance.getOverlayClassName(theme, animate).split(' ');
expect(c.length).toBe(4);
expect(c.length).toBe(3);
expect(c.indexOf('react-drawer-overlay')).not.toBe(-1);
expect(c.indexOf('test-overlay')).not.toBe(-1);
expect(c.indexOf('test-fadeIn')).not.toBe(-1);
expect(c.indexOf('test-hidden')).not.toBe(-1);
expect(c.indexOf('test-hidden')).toBe(-1);

instance.state.open = false;
c = instance.getOverlayClassName(theme, animate).split(' ');
Expand Down Expand Up @@ -185,10 +187,10 @@ describe('ReactDrawer', () => {
);
let instance = wrapper.instance();
let c = instance.getDrawerClassName(theme, animate).split(' ');
expect(c.length).toBe(5);
expect(c.length).toBe(4);
expect(c.indexOf('react-drawer-drawer')).not.toBe(-1);
expect(c.indexOf('test-drawer')).not.toBe(-1);
expect(c.indexOf('test-hidden')).not.toBe(-1);
expect(c.indexOf('test-hidden')).toBe(-1);
expect(c.indexOf('test-fadeInUp')).toBe(-1);
expect(c.indexOf('test-fadeInRight')).not.toBe(-1);
expect(c.indexOf('test-fadeInDown')).toBe(-1);
Expand Down