Skip to content

Commit

Permalink
Fix bug with new leftMaxSize/rightMaxSize options. Now work properly.…
Browse files Browse the repository at this point in the history
… Add test.
  • Loading branch information
Hilton Janfield committed Sep 14, 2015
1 parent e006a5f commit e9e1249
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion css/jquery.enhsplitter.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* jQuery Enhanced Splitter Plugin
* LESS / CSS File
* Version 1.2.1
* Version 1.2.2
*
* https://github.com/hiltonjanfield/jquery.enhsplitter
*
Expand Down
2 changes: 1 addition & 1 deletion css/jquery.enhsplitter.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* jQuery Enhanced Splitter Plugin
* LESS / CSS File
* Version 1.2.1
* Version 1.2.2
*
* https://github.com/hiltonjanfield/jquery.enhsplitter
*
Expand Down
7 changes: 6 additions & 1 deletion js/jquery.enhsplitter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* jQuery Enhanced Splitter Plugin
* Main ECMAScript File
* Version 1.2.1
* Version 1.2.2
*
* https://github.com/hiltonjanfield/jquery.enhsplitter
*
Expand Down Expand Up @@ -212,6 +212,11 @@
} else if (newPos >= self.containerSize - settings.rightMinSize - self.splitterSize) {
newPos = self.containerSize - settings.rightMinSize - self.splitterSize;
}
if (settings.leftMaxSize !== null && newPos >= settings.leftMaxSize) {
newPos = settings.leftMaxSize;
} else if (settings.rightMaxSize !== null && newPos <= self.containerSize - settings.rightMaxSize - self.splitterSize) {
newPos = self.containerSize - settings.rightMaxSize - self.splitterSize;
}
self.currentPosition = newPos;

if (self.settings.vertical) {
Expand Down
10 changes: 7 additions & 3 deletions test.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,15 @@ <h1>jquery.enhsplitter Features Tests</h1>
);

addTest(
{invisible: true},
'Invisible splitter. Splitter should still be fully functional (excluding the collapse handle).'
{invisible: true, leftMinSize: 10, leftMaxSize: 150},
'Invisible splitter. Splitter should still be fully functional (excluding the collapse handle).<br>' +
'Left panel should be able to go from 10 to 150 pixels in size and no bigger.'
);

addTest(
{
leftMaxSize: 300,
rightMaxSize: 300,
onDragStart: function (e, splitter) {
bar = splitter.find('.splitter_bar');
bar.css('background', 'repeating-linear-gradient(60deg, silver, silver 5px, grey 5px, grey 10px)');
Expand All @@ -150,7 +153,8 @@ <h1>jquery.enhsplitter Features Tests</h1>
}
},
'Demonstration of onDragStart and onDragEnd events.<br>' +
'Splitter should gain a striped background when being dragged.'
'Splitter should gain a striped background when being dragged.<br>'+
'Tests an alternate form of size restriction by setting maximum sizes for each panel rather than minimums.'
);

addTest(
Expand Down

0 comments on commit e9e1249

Please sign in to comment.