Skip to content

Commit 8ed17fe

Browse files
committed
fixed bug when initial state = show
1 parent dc2dfa5 commit 8ed17fe

5 files changed

Lines changed: 45 additions & 15 deletions

File tree

build/simple-modal.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,21 @@ var Modal = (function (_React$Component) {
3535
this.fadeIn = this.fadeIn.bind(this);
3636
this.fadeOut = this.fadeOut.bind(this);
3737

38+
var opacity = 0,
39+
display = 'block',
40+
visibility = 'hidden';
41+
42+
if (props.show) {
43+
opacity = 1;
44+
display = 'block';
45+
visibility = 'visible';
46+
}
47+
3848
this.state = {
39-
opacity: 0,
40-
display: 'none',
41-
visibility: 'hidden',
42-
show: false
49+
opacity: opacity,
50+
display: display,
51+
visibility: visibility,
52+
show: props.show
4353
};
4454
}
4555

dist/simple-react-modal.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,21 @@ var Modal = (function (_React$Component) {
3737
this.fadeIn = this.fadeIn.bind(this);
3838
this.fadeOut = this.fadeOut.bind(this);
3939

40+
var opacity = 0,
41+
display = 'block',
42+
visibility = 'hidden';
43+
44+
if (props.show) {
45+
opacity = 1;
46+
display = 'block';
47+
visibility = 'visible';
48+
}
49+
4050
this.state = {
41-
opacity: 0,
42-
display: 'none',
43-
visibility: 'hidden',
44-
show: false
51+
opacity: opacity,
52+
display: display,
53+
visibility: visibility,
54+
show: props.show
4555
};
4656
}
4757

dist/simple-react-modal.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "simple-react-modal",
33
"description": "The simplest modal",
4-
"version": "0.4.0",
4+
"version": "0.4.1",
55
"main": "./build/simple-modal.js",
66
"directories": {
77
"example": "example"

src/simple-modal.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,23 @@ export default class Modal extends React.Component{
99
this.fadeIn = this.fadeIn.bind(this)
1010
this.fadeOut = this.fadeOut.bind(this)
1111

12-
this.state = {
13-
opacity: 0,
14-
display: 'none',
15-
visibility: 'hidden',
16-
show: false
12+
let opacity = 0,
13+
display = 'block',
14+
visibility = 'hidden';
15+
16+
if(props.show){
17+
opacity = 1;
18+
display = 'block';
19+
visibility = 'visible'
1720
}
1821

22+
this.state = {
23+
opacity,
24+
display,
25+
visibility,
26+
show: props.show
27+
};
28+
1929
}
2030

2131
hideOnOuterClick(event){

0 commit comments

Comments
 (0)