Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Commit

Permalink
v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ieschalier committed Apr 12, 2017
1 parent 63189dc commit 2b214f7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ export default class Something extends React.Component {

### Render

![Render](render.png)
![Render](https://github.com/inextensodigital/masonreact/blob/master/render.png)
32 changes: 26 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,21 @@ var Masonreact = function (_React$Component) {
}, 0);
}, _this.componentDidMount = function () {

_this.msnry = new _masonryLayout2.default('.grid', {
_this.msnry = new _masonryLayout2.default('.' + _this.props.gridClassName, {
percentPosition: true,
transitionDuration: _this.props.transitionDuration || 0
transitionDuration: _this.props.transitionDuration
});

window.addEventListener('masonreact', _this.deferred);
}, _this.componentWillUnmount = function () {
window.removeEventListener('masonreact', _this.deferred);
}, _this.render = function () {
var _this$props = _this.props,
cols = _this$props.cols,
margin = _this$props.margin,
children = _this$props.children,
gridClassName = _this$props.gridClassName;

var cols = _this.props.cols || 1;
var margin = _this.props.margin || 5;

var style = {
item: {
Expand All @@ -70,8 +73,8 @@ var Masonreact = function (_React$Component) {

return _react2.default.createElement(
'div',
{ className: 'grid', style: style.grid },
_react2.default.Children.map(_this.props.children, function (child) {
{ className: gridClassName, style: style.grid },
_react2.default.Children.map(children, function (child) {
return child ? _react2.default.cloneElement(child, {
style: _extends({}, child.props.style, style.item)
}) : null;
Expand All @@ -83,6 +86,23 @@ var Masonreact = function (_React$Component) {
return Masonreact;
}(_react2.default.Component);

Masonreact.propTypes = {
children: _react2.default.PropTypes.node.isRequired,
style: _react2.default.PropTypes.shape({}),
cols: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.number, _react2.default.PropTypes.string]),
margin: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.number, _react2.default.PropTypes.string]),
transitionDuration: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.number, _react2.default.PropTypes.string]),
gridClassName: _react2.default.PropTypes.string
};

Masonreact.defaultProps = {
style: undefined,
cols: 1,
margin: 5,
transitionDuration: 0,
gridClassName: 'grid'
};

exports.default = Masonreact;


Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "masonreact",
"version": "1.0.0",
"version": "1.0.1",
"description": "React component to play with the great library Masonry from desandro.",
"main": "index.js",
"repository": {
Expand All @@ -16,6 +16,9 @@
"grid"
],
"author": "Didier Franc",
"contributors": [
"Igor ESCHALIER <igor.eschalier@gmail.com> (https://github.com/ieschalier/)"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/xeonys/masonreact/issues"
Expand Down

0 comments on commit 2b214f7

Please sign in to comment.