Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 68e5366

Browse files
committed
added support for horizontal masonry
1 parent da514f8 commit 68e5366

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/index.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,27 @@ const RNMasonryScrollView = ({
3535
columnStyle = null,
3636
oddColumnStyle = null,
3737
evenColumnStyle = null,
38+
horizontal,
3839
...otherProps
3940
}: RNMasonryScrollViewProps) => {
4041
const masonryGrid = generateMasonryGrid(children, columns);
4142

4243
return (
43-
<ScrollView contentContainerStyle={styles.columnStyle} {...otherProps}>
44+
<ScrollView
45+
contentContainerStyle={
46+
horizontal ? styles.horizontalColumnStyle : styles.verticalColumnStyle
47+
}
48+
horizontal={horizontal}
49+
{...otherProps}
50+
>
4451
{masonryGrid.map((column, columnIndex) => {
4552
return (
4653
<View
4754
key={columnIndex}
4855
style={[
56+
!horizontal
57+
? styles.horizontalColumnStyle
58+
: styles.verticalColumnStyle,
4959
columnStyle,
5060
columnIndex % 2 === 0 ? evenColumnStyle : oddColumnStyle
5161
]}
@@ -59,7 +69,8 @@ const RNMasonryScrollView = ({
5969
};
6070

6171
const styles = StyleSheet.create({
62-
columnStyle: { flexDirection: "row" }
72+
verticalColumnStyle: { flexDirection: "row" },
73+
horizontalColumnStyle: { flexDirection: "column" }
6374
});
6475

6576
export default RNMasonryScrollView;

0 commit comments

Comments
 (0)