Skip to content

Commit c14781d

Browse files
authored
Merge pull request #1 from bu1ka/container-with-overflow
Added support container with overflow
2 parents 88d53fa + 4a283c4 commit c14781d

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

src/components/App/App.jsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default class App extends React.Component {
1616
afterLoadText: 'afterLoad triggered',
1717
beforeLoadText: 'beforeLoad triggered',
1818
direction: 'vertical',
19+
containerWithOverflow: false,
1920
effect: '',
2021
showLowResImages: true,
2122
threshold: 100
@@ -48,7 +49,7 @@ export default class App extends React.Component {
4849

4950
render() {
5051
const {afterLoadText, beforeLoadText, direction,
51-
effect, showLowResImages, threshold} = this.state;
52+
effect, showLowResImages, threshold, containerWithOverflow} = this.state;
5253

5354
return (
5455
<div className={'app ' + direction}>
@@ -114,6 +115,21 @@ export default class App extends React.Component {
114115
</label>
115116
</p>
116117
</fieldset>
118+
<fieldset className="app-controls-fieldset">
119+
<p>
120+
<label>
121+
<input className="app-controls-checkbox"
122+
type="checkbox"
123+
onChange={() => {
124+
this.setState({
125+
containerWithOverflow: !this.state.containerWithOverflow
126+
});
127+
}}
128+
defaultChecked={this.state.containerWithOverflow} />
129+
Container with overflow
130+
</label>
131+
</p>
132+
</fieldset>
117133
<br />
118134
<fieldset className="app-controls-fieldset">
119135
<p>
@@ -142,6 +158,7 @@ export default class App extends React.Component {
142158
<Gallery
143159
afterLoadText={afterLoadText}
144160
beforeLoadText={beforeLoadText}
161+
containerWithOverflow={containerWithOverflow}
145162
direction={direction}
146163
effect={effect}
147164
showLowResImages={showLowResImages}

src/components/Gallery/Gallery.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ export class Gallery extends React.Component {
2121

2222
render() {
2323
const {afterLoadText, beforeLoadText, effect, direction,
24-
scrollPosition, showLowResImages, threshold} = this.props;
24+
scrollPosition, showLowResImages, threshold, containerWithOverflow
25+
} = this.props;
2526
const photos = getPhotos();
2627

2728
return (
28-
<div className={ 'gallery ' + direction }>
29+
<div className={ `gallery ${direction} ${containerWithOverflow ? 'with-overflow' : ''}` }>
2930
{photos.map((photo) =>
3031
<LazyLoadImage
3132
alt={photo.src}
@@ -47,6 +48,10 @@ export class Gallery extends React.Component {
4748
}
4849
}
4950

51+
Gallery.defaultProps = {
52+
containerWithOverflow: false
53+
};
54+
5055
Gallery.propTypes = {
5156
afterLoadText: PropTypes.string.isRequired,
5257
beforeLoadText: PropTypes.string.isRequired,
@@ -55,7 +60,8 @@ Gallery.propTypes = {
5560
effect: PropTypes.oneOf([
5661
'black-and-white', 'blur', 'opacity', '']).isRequired,
5762
showLowResImages: PropTypes.bool.isRequired,
58-
threshold: PropTypes.number.isRequired
63+
threshold: PropTypes.number.isRequired,
64+
containerWithOverflow: PropTypes.bool
5965
};
6066

6167
export default trackWindowScroll(Gallery);

src/components/Gallery/gallery.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
white-space: nowrap;
99
}
1010

11+
.with-overflow {
12+
max-height: 500px;
13+
overflow-y: scroll;
14+
-webkit-overflow-scrolling: touch;
15+
}
16+
17+
.horizontal.with-overflow {
18+
max-height: none;
19+
max-width: 990px;
20+
overflow-x: scroll;
21+
overflow-y: auto;
22+
}
23+
1124
.gallery.horizontal .gallery-img-wrapper {
1225
margin-left: 10px;
1326
}

0 commit comments

Comments
 (0)