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

Skip to content

Commit 47d0933

Browse files
Bug wrong maxHeight for updateStyles function
When there are 4 row of grid items and more. There are bug of updates styles. The function does not take into account all nodes, but only those that have been changed (_dirty). In this regard, the styles for the lower layers do not sink, and they rise upward. The solution is to calculate the maxHeight for all nodes.
1 parent 57c6511 commit 47d0933

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/gridstack.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,9 @@
673673
this.grid = new GridStackEngine(this.opts.width, function(nodes, detachNode) {
674674
detachNode = typeof detachNode === 'undefined' ? true : detachNode;
675675
var maxHeight = 0;
676+
_.each(this.nodes, function(n) {
677+
maxHeight = Math.max(maxHeight, n.y + n.height);
678+
}
676679
_.each(nodes, function(n) {
677680
if (detachNode && n._id === null) {
678681
if (n.el) {
@@ -684,7 +687,6 @@
684687
.attr('data-gs-y', n.y)
685688
.attr('data-gs-width', n.width)
686689
.attr('data-gs-height', n.height);
687-
maxHeight = Math.max(maxHeight, n.y + n.height);
688690
}
689691
});
690692
self._updateStyles(maxHeight + 10);

0 commit comments

Comments
 (0)