collapsible.js: Don't collapse until at least twice the visible space is required

This commit is contained in:
Johannes Meyer 2019-07-26 07:35:04 +02:00
parent 74bf1bdc89
commit 91a8bdf786
1 changed files with 4 additions and 8 deletions

View File

@ -166,18 +166,14 @@
Collapsible.prototype.canCollapse = function($collapsible) {
var rowSelector = this.getRowSelector($collapsible);
if (!! rowSelector) {
return $(rowSelector, $collapsible).length > ($collapsible.data('visibleRows') || this.defaultVisibleRows);
var visibleRows = $collapsible.data('visibleRows') || this.defaultVisibleRows;
return $(rowSelector, $collapsible).length > visibleRows * 2;
} else {
var actualHeight = $collapsible[0].scrollHeight;
var maxHeight = $collapsible.data('visibleHeight') || this.defaultVisibleHeight;
if (actualHeight <= maxHeight) {
return false;
}
// Although the height seems larger than what it should be, make sure it's not just a small fraction
// i.e. more than 12 pixel and at least 10% difference
return actualHeight - maxHeight > 12 && actualHeight / maxHeight >= 1.1;
return actualHeight >= maxHeight * 2;
}
};