Skip to content

Commit

Permalink
Handle default columns count
Browse files Browse the repository at this point in the history
  • Loading branch information
xuopled committed Jun 14, 2017
1 parent 092fce5 commit 35d7a56
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.2.3 - 2017-06-14

* Update: handle default columns count

# 1.2.2 - 2017-06-03

* Add: `files` to package.json
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class MyWrapper extends Component {

### Mansonry component
* `columnsCount`: Number - injected by ResponsiveMasonry - default 3,
* `gutter`: String - margin surrounding each item (in pixels) - default "0",
* `gutter`: String - margin surrounding each item - default "0" - eg: "10px",

### ResponsiveMasonry component
* `columnsCountBreakPoints`: Object, keys are breakpoints in px, values are the columns number - default {350: 1, 750: 2, 900: 3},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-responsive-masonry",
"version": "1.2.2",
"version": "1.2.3",
"description": "React responsive masonry component built with css flexbox",
"repository": {
"type": "git",
Expand Down
6 changes: 5 additions & 1 deletion src/ResponsiveMasonry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, {Component} from "react"
import PropTypes from "prop-types"

const DEFAULT_COLUMNS_COUNT = 1

class MasonryResponsive extends Component {
constructor(props) {
super(props)
Expand Down Expand Up @@ -30,7 +32,9 @@ class MasonryResponsive extends Component {
const {columnsCountBreakPoints} = this.props
const containerWidth = this.container.offsetWidth
const breakPoints = this.getSortedBreakPoints()
let columnsCount
let columnsCount = breakPoints.length > 0
? columnsCountBreakPoints[breakPoints[0]]
: DEFAULT_COLUMNS_COUNT

breakPoints.forEach(breakPoint => {
if (breakPoint < containerWidth) {
Expand Down

0 comments on commit 35d7a56

Please sign in to comment.