Skip to content

Commit

Permalink
Merge pull request #58 from zerkms/ISSUE-56_MAXSIZE_PROP
Browse files Browse the repository at this point in the history
Added maxSize property
  • Loading branch information
tomkp committed Mar 31, 2016
2 parents 894cb0c + b4db70a commit 1cb47c5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion demo/Example.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var Example = React.createClass({

render: function() {
return (
<SplitPane split="vertical" minSize="50" defaultSize="100" className="primary">
<SplitPane split="vertical" minSize="50" maxSize="300" defaultSize="100" className="primary">
<div></div>
<SplitPane split="horizontal">
<div></div>
Expand Down
8 changes: 6 additions & 2 deletions demo/bundle.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/SplitPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default React.createClass({
propTypes: {
primary: React.PropTypes.oneOf(['first', 'second']),
minSize: React.PropTypes.number,
maxSize: React.PropTypes.number,
defaultSize: React.PropTypes.number,
size: React.PropTypes.number,
allowResize: React.PropTypes.bool,
Expand Down Expand Up @@ -100,7 +101,9 @@ export default React.createClass({
let newSize = size - newPosition;

if (newSize < this.props.minSize) {
newSize = this.props.minSize;
newSize = this.props.minSize;
} else if (newSize > this.props.maxSize) {
newSize = this.props.maxSize;
} else {
this.setState({
position: current,
Expand Down

0 comments on commit 1cb47c5

Please sign in to comment.