diff --git a/README.md b/README.md index 1e3e882..a79dbe2 100644 --- a/README.md +++ b/README.md @@ -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 { diff --git a/src/ReactDrawer.js b/src/ReactDrawer.js index b295ad9..340436f 100644 --- a/src/ReactDrawer.js +++ b/src/ReactDrawer.js @@ -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 }); } diff --git a/src/ReactDrawer.test.js b/src/ReactDrawer.test.js index 8087dc4..1dd73f0 100644 --- a/src/ReactDrawer.test.js +++ b/src/ReactDrawer.test.js @@ -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( ); 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', () => { @@ -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(' '); @@ -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);