Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit caffe02

Browse files
author
adumesny
committed
use verticalMargin when calculating min height in rows
Testing: 1. run two.html and check that yellow grid has height of 300px 2. modify two.html to have #grid1 { background: lightgoldenrodyellow; min-height: 300px; } 3. rerun and notice grid1 now has 380px actual height (passed last item) ! 4. adding removing items will shrink grow, but not to the correct min 300px size.
1 parent 030d1c5 commit caffe02

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
"main": "dist/gridstack.js",
66
"repository": {
77
"type": "git",
8-
"url": "git+https://github.com/troolee/gridstack.js.git"
8+
"url": "git+https://github.com/gridstack/gridstack.js.git"
99
},
1010
"scripts": {
1111
"build": "grunt ; doctoc ./README.md ; doctoc ./doc/README.md ; doctoc ./doc/CHANGES.md",
12-
"test": "grunt lint && karma start karma.conf.js"
12+
"test": "grunt lint && karma start karma.conf.js",
13+
"lint": "grunt lint"
1314
},
1415
"keywords": [
1516
"gridstack",
@@ -24,9 +25,9 @@
2425
],
2526
"license": "MIT",
2627
"bugs": {
27-
"url": "https://github.com/troolee/gridstack.js/issues"
28+
"url": "https://github.com/gridstack/gridstack.js/issues"
2829
},
29-
"homepage": "http://troolee.github.io/gridstack.js/",
30+
"homepage": "http://gridstack.github.io/gridstack.js/",
3031
"dependencies": {
3132
"jquery": "^3.1.0",
3233
"jquery-ui": "^1.12.0",

src/gridstack.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,9 +1033,13 @@
10331033
return;
10341034
}
10351035
var height = this.grid.getGridHeight();
1036-
var minHeight = parseInt(this.container.css('min-height')) / this.cellHeight();
1037-
if (height < minHeight) {
1038-
height = minHeight;
1036+
// check for css min height. Each row is cellHeight + verticalMargin, until last one which has no margin below
1037+
var cssMinHeight = parseInt(this.container.css('min-height'));
1038+
if (cssMinHeight > 0) {
1039+
var minHeight = (cssMinHeight + this.opts.verticalMargin) / (this.cellHeight() + this.opts.verticalMargin);
1040+
if (height < minHeight) {
1041+
height = minHeight;
1042+
}
10391043
}
10401044
this.container.attr('data-gs-current-height', height);
10411045
if (!this.opts.cellHeight) {

0 commit comments

Comments
 (0)