Skip to content

Commit 3c8d9d3

Browse files
author
Alain Dumesny
committed
griditems with x=0 placement fix
fix for #1054 * had incorrect check for 0 value (valid) when sorting objects. Checking NaN instead. * this was introduced when fixing #1017
1 parent b31a569 commit 3c8d9d3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

doc/CHANGES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Change log
2828
- add `gridstack.poly.js` for IE and older browsers, removed `core-js` lib from samples (<1k vs 85k), and all IE8 mentions ([#1061](https://github.com/gridstack/gridstack.js/pull/1061)).
2929
- add `jquery-ui.js` (and min.js) as minimal subset we need (55k vs 248k), which is now part of `gridstack.all.js`. Include individual parts if you need your own lib instead of all.js
3030
([#1064](https://github.com/gridstack/gridstack.js/pull/1064)).
31-
- changed jquery dep to lowest we can use (>=1.8) ([#629](https://github.com/gridstack/gridstack.js/issues/629)).
31+
- changed jquery dependency to lowest we can use (>=1.8) ([#629](https://github.com/gridstack/gridstack.js/issues/629)).
32+
- fix for griditems with x=0 placement wrong order (introduced for #1017) ([#1054](https://github.com/gridstack/gridstack.js/issues/1054)).
3233

3334
## v0.5.3 (2019-11-20)
3435

src/gridstack.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -801,11 +801,12 @@
801801
this.container.children('.' + this.opts.itemClass + ':not(.' + this.opts.placeholderClass + ')')
802802
.each(function(index, el) {
803803
el = $(el);
804+
var x = parseInt(el.attr('data-gs-x'));
805+
var y = parseInt(el.attr('data-gs-y'));
804806
elements.push({
805807
el: el,
806-
// if x,y are missing (autoPosition) add them to end of list - keep their respective DOM order
807-
i: (parseInt(el.attr('data-gs-x')) || 100) +
808-
(parseInt(el.attr('data-gs-y')) || 100) * _this.opts.column
808+
// if x,y are missing (autoPosition) add them to end of list - but keep their respective DOM order
809+
i: (Number.isNaN(x) ? 1000 : x) + (Number.isNaN(y) ? 1000 : y) * _this.opts.column
809810
});
810811
});
811812
Utils.sortBy(elements, function(x) { return x.i; }).forEach(function(item) {

0 commit comments

Comments
 (0)