Skip to content

Commit 961eafe

Browse files
authored
Merge pull request #767 from radiolips/bugfix/628
Bugfix/628
2 parents f39cf22 + e12b460 commit 961eafe

File tree

9 files changed

+104
-21
lines changed

9 files changed

+104
-21
lines changed

dist/gridstack-extra.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gridstack.all.js

Lines changed: 23 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gridstack.jQueryUI.min.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gridstack.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,25 @@
106106
height = parseFloat(match[1]);
107107
}
108108
return {height: height, unit: heightUnit};
109+
},
110+
111+
removePositioningStyles: function(el) {
112+
var style = el[0].style;
113+
if (style.position) {
114+
style.removeProperty('position');
115+
}
116+
if (style.left) {
117+
style.removeProperty('left');
118+
}
119+
if (style.top) {
120+
style.removeProperty('top');
121+
}
122+
if (style.width) {
123+
style.removeProperty('width');
124+
}
125+
if (style.height) {
126+
style.removeProperty('height');
127+
}
109128
}
110129
};
111130

@@ -869,13 +888,14 @@
869888
$(ui.helper).remove();
870889
node.el = el;
871890
self.placeholder.hide();
891+
Utils.removePositioningStyles(el);
892+
872893
el
873894
.attr('data-gs-x', node.x)
874895
.attr('data-gs-y', node.y)
875896
.attr('data-gs-width', node.width)
876897
.attr('data-gs-height', node.height)
877898
.addClass(self.opts.itemClass)
878-
.removeAttr('style')
879899
.enableSelection()
880900
.removeData('draggable')
881901
.removeClass('ui-draggable ui-draggable-dragging ui-draggable-disabled')
@@ -947,14 +967,14 @@
947967
if (typeof maxHeight == 'undefined') {
948968
maxHeight = this._styles._max;
949969
}
970+
if (this._styles._max !== 0 && maxHeight <= this._styles._max) { // Keep this._styles._max increasing
971+
return ;
972+
}
950973
this._initStyles();
951974
this._updateContainerHeight();
952975
if (!this.opts.cellHeight) { // The rest will be handled by CSS
953976
return ;
954977
}
955-
if (this._styles._max !== 0 && maxHeight <= this._styles._max) {
956-
return ;
957-
}
958978

959979
if (!this.opts.verticalMargin || this.opts.cellHeightUnit === this.opts.verticalMarginUnit) {
960980
getHeight = function(nbRows, nbMargins) {
@@ -1008,6 +1028,10 @@
10081028
return;
10091029
}
10101030
var height = this.grid.getGridHeight();
1031+
var minHeight = parseInt(this.container.css('min-height')) / this.cellHeight();
1032+
if (height < minHeight) {
1033+
height = minHeight;
1034+
}
10111035
this.container.attr('data-gs-current-height', height);
10121036
if (!this.opts.cellHeight) {
10131037
return ;
@@ -1170,19 +1194,19 @@
11701194
} else {
11711195
self._clearRemovingTimeout(el);
11721196
if (!node._temporaryRemoved) {
1197+
Utils.removePositioningStyles(o);
11731198
o
11741199
.attr('data-gs-x', node.x)
11751200
.attr('data-gs-y', node.y)
11761201
.attr('data-gs-width', node.width)
1177-
.attr('data-gs-height', node.height)
1178-
.removeAttr('style');
1202+
.attr('data-gs-height', node.height);
11791203
} else {
1204+
Utils.removePositioningStyles(o);
11801205
o
11811206
.attr('data-gs-x', node._beforeDragX)
11821207
.attr('data-gs-y', node._beforeDragY)
11831208
.attr('data-gs-width', node.width)
1184-
.attr('data-gs-height', node.height)
1185-
.removeAttr('style');
1209+
.attr('data-gs-height', node.height);
11861210
node.x = node._beforeDragX;
11871211
node.y = node._beforeDragY;
11881212
self.grid.addNode(node);

dist/gridstack.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gridstack.min.js

Lines changed: 18 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gridstack.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Change log
2323
- widgets can have their own resize handles. Use `data-gs-resize-handles` element attribute to use. For example, `data-gs-resize-handles="e,w"` will make the particular widget only resize west and east. ([#494](https://github.com/troolee/gridstack.js/issues/494)).
2424
- enable sidebar items to be duplicated properly. Pass `helper: 'clone'` in `draggable` options. ([#661](https://github.com/troolee/gridstack.js/issues/661), ([#396](https://github.com/troolee/gridstack.js/issues/396), ([#499](https://github.com/troolee/gridstack.js/issues/499)).
2525
- fix `staticGrid` grid option ([#743](https://github.com/troolee/gridstack.js/issues/743))
26+
- preserve inline styles when moving/cloning items (thanks silverwind)
27+
- fix bug causing heights not to get set ([#744](https://github.com/troolee/gridstack.js/issues/744))
28+
- allow grid to have min-height, fixes ([#628](https://github.com/troolee/gridstack.js/issues/628))
2629

2730
## v0.3.0 (2017-04-21)
2831

src/gridstack.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,22 @@
109109
},
110110

111111
removePositioningStyles: function(el) {
112-
var style = el[0].style;
113-
if (style.position) style.removeProperty('position');
114-
if (style.left) style.removeProperty('left');
115-
if (style.top) style.removeProperty('top');
112+
var style = el[0].style;
113+
if (style.position) {
114+
style.removeProperty('position');
115+
}
116+
if (style.left) {
117+
style.removeProperty('left');
118+
}
119+
if (style.top) {
120+
style.removeProperty('top');
121+
}
122+
if (style.width) {
123+
style.removeProperty('width');
124+
}
125+
if (style.height) {
126+
style.removeProperty('height');
127+
}
116128
}
117129
};
118130

@@ -1016,6 +1028,10 @@
10161028
return;
10171029
}
10181030
var height = this.grid.getGridHeight();
1031+
var minHeight = parseInt(this.container.css('min-height')) / this.cellHeight();
1032+
if (height < minHeight) {
1033+
height = minHeight;
1034+
}
10191035
this.container.attr('data-gs-current-height', height);
10201036
if (!this.opts.cellHeight) {
10211037
return ;

0 commit comments

Comments
 (0)