Skip to content

Commit 47adbf1

Browse files
author
Alain Dumesny
committed
onStartMoving() fix to minHeight
*method was not correctly counting margin when figuring out minHeight during a drag (see #999) Note: many other places don't handle margin, both height and width of cells. Should probbaly be fix globally. WidthMargin is not in opts though but CSS, making it harder.
1 parent 6a8949e commit 47adbf1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/gridstack.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,8 +1278,9 @@
12781278
self.grid.cleanNodes();
12791279
self.grid.beginUpdate(node);
12801280
cellWidth = self.cellWidth();
1281-
var strictCellHeight = Math.ceil(o.outerHeight() / o.attr('data-gs-height'));
1282-
cellHeight = self.container.height() / parseInt(self.container.attr('data-gs-current-height'));
1281+
height = o.attr('data-gs-height');
1282+
verticalMargin = self.opts.verticalMargin;
1283+
cellHeight = Math.ceil((o.outerHeight() - (height - 1) * verticalMargin) / height);
12831284
self.placeholder
12841285
.attr('data-gs-x', o.attr('data-gs-x'))
12851286
.attr('data-gs-y', o.attr('data-gs-y'))
@@ -1290,9 +1291,9 @@
12901291
node._beforeDragX = node.x;
12911292
node._beforeDragY = node.y;
12921293
node._prevYPix = ui.position.top;
1293-
1294+
minHeight = (node.minHeight || 1);
12941295
self.dd.resizable(el, 'option', 'minWidth', cellWidth * (node.minWidth || 1));
1295-
self.dd.resizable(el, 'option', 'minHeight', strictCellHeight * (node.minHeight || 1));
1296+
self.dd.resizable(el, 'option', 'minHeight', cellHeight * minHeight + (minHeight - 1) * verticalMargin);
12961297

12971298
if (event.type == 'resizestart') {
12981299
o.find('.grid-stack-item').trigger('resizestart');

0 commit comments

Comments
 (0)