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

Skip to content

Commit 5f2e795

Browse files
committed
Correctly sort nodes by using the total width instead of individual node width (becomes a problem with nodes of variable width).
1 parent 310c854 commit 5f2e795

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/gridstack.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,12 @@
429429

430430
if (this.opts.auto) {
431431
var elements = [];
432+
var _this = this;
432433
this.container.children('.' + this.opts.item_class).each(function (index, el) {
433434
el = $(el);
434435
elements.push({
435436
el: el,
436-
i: parseInt(el.attr('data-gs-x')) + parseInt(el.attr('data-gs-y')) * parseInt(el.attr('data-gs-width'))
437+
i: parseInt(el.attr('data-gs-x')) + parseInt(el.attr('data-gs-y')) * _this.opts.width // Use opts.width as weight for Y
437438
});
438439
});
439440
_.chain(elements).sortBy(function (x) { return x.i; }).each(function (i) {

0 commit comments

Comments
 (0)