diff --git a/src/gridstack.js b/src/gridstack.js index 518942def..f83d9229a 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -673,6 +673,9 @@ this.grid = new GridStackEngine(this.opts.width, function(nodes, detachNode) { detachNode = typeof detachNode === 'undefined' ? true : detachNode; var maxHeight = 0; + _.each(this.nodes, function(n) { + maxHeight = Math.max(maxHeight, n.y + n.height); + }); _.each(nodes, function(n) { if (detachNode && n._id === null) { if (n.el) { @@ -684,7 +687,6 @@ .attr('data-gs-y', n.y) .attr('data-gs-width', n.width) .attr('data-gs-height', n.height); - maxHeight = Math.max(maxHeight, n.y + n.height); } }); self._updateStyles(maxHeight + 10);