Skip to content

Commit 01be0f9

Browse files
committed
Removed scrollOnWindowOverflow prop & update readme
1 parent 4432356 commit 01be0f9

File tree

8 files changed

+52
-61
lines changed

8 files changed

+52
-61
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,29 @@ npm i -S react-swipeable-bottom-sheet
2525
```
2626
import SwipeableBottomSheet from 'react-swipeable-bottom-sheet';
2727
28-
<SwipeableBottomSheet
29-
overflowHeight={64}>
28+
<SwipeableBottomSheet overflowHeight={64}>
3029
<div style={{ height: '240px' }}>
3130
Here goes the content of your bottom sheet
3231
</div>
3332
</SwipeableBottomSheet>
3433
```
3534

36-
The bottom sheet's height (when open) scales automatically with its content.
35+
The bottom sheet's height (when open) scales automatically with its content. If it exceeds the window height, content is scrollable.
3736

3837

39-
### Properties
38+
### Props
4039

4140
| Name | Type | Default | Description |
4241
|:-----|:-----|:--------|:------------|
4342
| overflowHeight | number | 0 | The height (in px) of the sheet when closed. |
4443
| open | bool | | Use this property to enable controlled mode. If `true`, it will open the sheet. |
4544
| defaultOpen | bool | false | If `true`, the sheet is open at component mount. |
4645
| onChange | function(isOpen) | | The callback that fires after sheet opens or closes. |
47-
| scrollOnWindowOverflow | bool | true | If `true`, the sheet content will scroll when overflowing window height |
4846
| fullScreen | bool | false | If `true`, the sheet takes the full height of the window when open. |
4947
| shadowTip | bool | true | If `true`, a box shadow is displayed at sheet bottom when closed. This is used to show that content is hidden below. |
5048
| topShadow | bool | true | If `true`, a box shadow is displayed at sheet top border. |
5149
| overlay | bool | true | If `true`, an overlay is displayed behind sheet when open. A click on the overlay closes the sheet. |
52-
| swipeableViewsProps | object | `{}` | Props passed to SwipeableViews component. |
50+
| swipeableViewsProps | object | `{}` | Props passed to SwipeableViews component (see [documentation](https://github.com/oliviertassinari/react-swipeable-views#api)). |
5351
| style | object | `{}` | Style applied on the root (non-swiped) component. |
5452
| bodyStyle | object | `{}` | Style applied on the body of the bottom sheet. |
5553
| overlayStyle | object | `{}` | Style applied on the overlay. |

dist/react-swipeable-bottom-sheet.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3973,7 +3973,6 @@ var SwipeableBottomSheet = (function (_Component) {
39733973
var _props = this.props;
39743974
var overflowHeight = _props.overflowHeight;
39753975
var fullScreen = _props.fullScreen;
3976-
var scrollOnWindowOverflow = _props.scrollOnWindowOverflow;
39773976
var open = _props.open;
39783977
var topShadow = _props.topShadow;
39793978
var shadowTip = _props.shadowTip;
@@ -4011,12 +4010,10 @@ var SwipeableBottomSheet = (function (_Component) {
40114010
marginBottom: overflowHeight
40124011
},
40134012
body: _extends({
4014-
overflow: 'hidden',
4015-
backgroundColor: 'white'
4016-
}, scrollOnWindowOverflow && {
40174013
overflow: isOpen ? 'auto' : 'hidden',
4014+
backgroundColor: 'white',
40184015
height: fullScreen ? this.state.height : 'initial',
4019-
maxHeight: fullScreen ? 'initial' : this.state.height
4016+
maxHeight: this.state.height
40204017
}, this.props.bodyStyle)
40214018
},
40224019
overlay: _extends({
@@ -4048,9 +4045,10 @@ var SwipeableBottomSheet = (function (_Component) {
40484045
return _react2['default'].createElement(
40494046
'div',
40504047
{ style: styles.root },
4051-
scrollOnWindowOverflow && _react2['default'].createElement(_HeightUpdater2['default'], {
4048+
_react2['default'].createElement(_HeightUpdater2['default'], {
40524049
height: this.state.height,
4053-
onHeightChange: this.onHeightChange.bind(this) }),
4050+
onHeightChange: this.onHeightChange.bind(this)
4051+
}),
40544052
overlay && _react2['default'].createElement('div', { style: styles.overlay, onClick: function () {
40554053
return _this.onChangeIndex(0);
40564054
} }),
@@ -4064,7 +4062,8 @@ var SwipeableBottomSheet = (function (_Component) {
40644062
}, this.props.swipeableViewsProps, {
40654063
style: styles.swiper.root,
40664064
containerStyle: styles.swiper.container,
4067-
slideStyle: styles.swiper.slide }),
4065+
slideStyle: styles.swiper.slide
4066+
}),
40684067
_react2['default'].createElement(
40694068
'div',
40704069
{ style: styles.swiper.body },
@@ -4092,7 +4091,6 @@ SwipeableBottomSheet.propTypes = {
40924091
overflowHeight: _propTypes2['default'].number,
40934092
overlay: _propTypes2['default'].bool,
40944093
overlayStyle: _propTypes2['default'].object,
4095-
scrollOnWindowOverflow: _propTypes2['default'].bool,
40964094
shadowTip: _propTypes2['default'].bool,
40974095
style: _propTypes2['default'].object,
40984096
swipeableViewsProps: _propTypes2['default'].object,
@@ -4104,7 +4102,6 @@ SwipeableBottomSheet.defaultProps = {
41044102
fullScreen: false,
41054103
overflowHeight: 0,
41064104
overlay: true,
4107-
scrollOnWindowOverflow: true,
41084105
shadowTip: true,
41094106
swipeableViewsProps: {},
41104107
topShadow: true

dist/react-swipeable-bottom-sheet.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/src/controlled.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ class App extends React.Component {
4242
return (
4343
<div>
4444
<SwipeableBottomSheet
45-
overflowHeight={64}
46-
open={this.state.open}
47-
onChange={this.openBottomSheet.bind(this)}>
45+
overflowHeight={64}
46+
open={this.state.open}
47+
onChange={this.openBottomSheet.bind(this)}
48+
>
4849
<div style={styles.title}>
4950
Controlled bottom sheet&nbsp;
5051
<button onClick={this.toggleBottomSheet.bind(this)}>

example/src/fullscreen.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@ class App extends React.Component {
3535

3636
return (
3737
<div>
38-
<button onClick={() => this.openBottomSheet(true)}>Open bottom sheet</button>
38+
<button onClick={() => this.openBottomSheet(true)}>
39+
Open bottom sheet
40+
</button>
3941
<SwipeableBottomSheet
40-
open={this.state.open}
41-
onChange={this.openBottomSheet.bind(this)}
42-
fullScreen
43-
shadowTip={false}
44-
topShadow={false}>
42+
open={this.state.open}
43+
onChange={this.openBottomSheet.bind(this)}
44+
fullScreen
45+
shadowTip={false}
46+
topShadow={false}
47+
>
4548
<div style={styles.title}>
4649
Controlled fullscreen bottom sheet
4750
</div>
@@ -52,7 +55,9 @@ class App extends React.Component {
5255
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
5356
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
5457
deserunt mollit anim id est laborum.<br/>
55-
<button onClick={() => this.openBottomSheet(false)}>Close</button>
58+
<button onClick={() => this.openBottomSheet(false)}>
59+
Close
60+
</button>
5661
</div>
5762
</SwipeableBottomSheet>
5863
</div>

example/src/uncontrolled.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ class App extends React.Component {
2424

2525
return (
2626
<div>
27-
<SwipeableBottomSheet
28-
overflowHeight={64}>
27+
<SwipeableBottomSheet overflowHeight={64}>
2928
<div style={styles.title}>
3029
Swipeable bottom sheet
3130
</div>

lib/SwipeableBottomSheet.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ var SwipeableBottomSheet = (function (_Component) {
6969
var _props = this.props;
7070
var overflowHeight = _props.overflowHeight;
7171
var fullScreen = _props.fullScreen;
72-
var scrollOnWindowOverflow = _props.scrollOnWindowOverflow;
7372
var open = _props.open;
7473
var topShadow = _props.topShadow;
7574
var shadowTip = _props.shadowTip;
@@ -107,12 +106,10 @@ var SwipeableBottomSheet = (function (_Component) {
107106
marginBottom: overflowHeight
108107
},
109108
body: _extends({
110-
overflow: 'hidden',
111-
backgroundColor: 'white'
112-
}, scrollOnWindowOverflow && {
113109
overflow: isOpen ? 'auto' : 'hidden',
110+
backgroundColor: 'white',
114111
height: fullScreen ? this.state.height : 'initial',
115-
maxHeight: fullScreen ? 'initial' : this.state.height
112+
maxHeight: this.state.height
116113
}, this.props.bodyStyle)
117114
},
118115
overlay: _extends({
@@ -144,9 +141,10 @@ var SwipeableBottomSheet = (function (_Component) {
144141
return _react2['default'].createElement(
145142
'div',
146143
{ style: styles.root },
147-
scrollOnWindowOverflow && _react2['default'].createElement(_HeightUpdater2['default'], {
144+
_react2['default'].createElement(_HeightUpdater2['default'], {
148145
height: this.state.height,
149-
onHeightChange: this.onHeightChange.bind(this) }),
146+
onHeightChange: this.onHeightChange.bind(this)
147+
}),
150148
overlay && _react2['default'].createElement('div', { style: styles.overlay, onClick: function () {
151149
return _this.onChangeIndex(0);
152150
} }),
@@ -160,7 +158,8 @@ var SwipeableBottomSheet = (function (_Component) {
160158
}, this.props.swipeableViewsProps, {
161159
style: styles.swiper.root,
162160
containerStyle: styles.swiper.container,
163-
slideStyle: styles.swiper.slide }),
161+
slideStyle: styles.swiper.slide
162+
}),
164163
_react2['default'].createElement(
165164
'div',
166165
{ style: styles.swiper.body },
@@ -188,7 +187,6 @@ SwipeableBottomSheet.propTypes = {
188187
overflowHeight: _propTypes2['default'].number,
189188
overlay: _propTypes2['default'].bool,
190189
overlayStyle: _propTypes2['default'].object,
191-
scrollOnWindowOverflow: _propTypes2['default'].bool,
192190
shadowTip: _propTypes2['default'].bool,
193191
style: _propTypes2['default'].object,
194192
swipeableViewsProps: _propTypes2['default'].object,
@@ -200,7 +198,6 @@ SwipeableBottomSheet.defaultProps = {
200198
fullScreen: false,
201199
overflowHeight: 0,
202200
overlay: true,
203-
scrollOnWindowOverflow: true,
204201
shadowTip: true,
205202
swipeableViewsProps: {},
206203
topShadow: true

src/SwipeableBottomSheet.js

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class SwipeableBottomSheet extends Component {
3535
const {
3636
overflowHeight,
3737
fullScreen,
38-
scrollOnWindowOverflow,
3938
open,
4039
topShadow,
4140
shadowTip,
@@ -79,13 +78,10 @@ class SwipeableBottomSheet extends Component {
7978
marginBottom: overflowHeight,
8079
},
8180
body:{
82-
overflow: 'hidden',
81+
overflow: isOpen ? 'auto' : 'hidden',
8382
backgroundColor: 'white',
84-
...scrollOnWindowOverflow && {
85-
overflow: isOpen ? 'auto' : 'hidden',
86-
height: fullScreen ? this.state.height : 'initial',
87-
maxHeight: fullScreen ? 'initial' : this.state.height
88-
},
83+
height: fullScreen ? this.state.height : 'initial',
84+
maxHeight: this.state.height,
8985
...this.props.bodyStyle
9086
}
9187
},
@@ -119,23 +115,23 @@ class SwipeableBottomSheet extends Component {
119115

120116
return (
121117
<div style={styles.root}>
122-
{scrollOnWindowOverflow &&
123-
<HeightUpdater
118+
<HeightUpdater
124119
height={this.state.height}
125-
onHeightChange={this.onHeightChange.bind(this)}/>
126-
}
120+
onHeightChange={this.onHeightChange.bind(this)}
121+
/>
127122
{overlay &&
128123
<div style={styles.overlay} onClick={() => this.onChangeIndex(0)}/>
129124
}
130125
<SwipeableViews
131-
index={index}
132-
axis="y"
133-
enableMouseEvents
134-
onChangeIndex={this.onChangeIndex.bind(this)}
135-
{...this.props.swipeableViewsProps}
136-
style={styles.swiper.root}
137-
containerStyle={styles.swiper.container}
138-
slideStyle={styles.swiper.slide}>
126+
index={index}
127+
axis="y"
128+
enableMouseEvents
129+
onChangeIndex={this.onChangeIndex.bind(this)}
130+
{...this.props.swipeableViewsProps}
131+
style={styles.swiper.root}
132+
containerStyle={styles.swiper.container}
133+
slideStyle={styles.swiper.slide}
134+
>
139135
<div style={styles.swiper.body}>
140136
{this.props.children}
141137
</div>
@@ -159,7 +155,6 @@ SwipeableBottomSheet.propTypes = {
159155
overflowHeight: PropTypes.number,
160156
overlay: PropTypes.bool,
161157
overlayStyle: PropTypes.object,
162-
scrollOnWindowOverflow: PropTypes.bool,
163158
shadowTip: PropTypes.bool,
164159
style: PropTypes.object,
165160
swipeableViewsProps: PropTypes.object,
@@ -171,7 +166,6 @@ SwipeableBottomSheet.defaultProps = {
171166
fullScreen: false,
172167
overflowHeight: 0,
173168
overlay: true,
174-
scrollOnWindowOverflow: true,
175169
shadowTip: true,
176170
swipeableViewsProps: {},
177171
topShadow: true

0 commit comments

Comments
 (0)