From 5f2e795677e7621ea02dfa2a43921c0840f5ac4f Mon Sep 17 00:00:00 2001 From: Matt Widmann Date: Tue, 14 Apr 2015 16:19:03 -0400 Subject: [PATCH] Correctly sort nodes by using the total width instead of individual node width (becomes a problem with nodes of variable width). --- src/gridstack.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gridstack.js b/src/gridstack.js index 88f960436..d9bc60022 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -429,11 +429,12 @@ if (this.opts.auto) { var elements = []; + var _this = this; this.container.children('.' + this.opts.item_class).each(function (index, el) { el = $(el); elements.push({ el: el, - i: parseInt(el.attr('data-gs-x')) + parseInt(el.attr('data-gs-y')) * parseInt(el.attr('data-gs-width')) + i: parseInt(el.attr('data-gs-x')) + parseInt(el.attr('data-gs-y')) * _this.opts.width // Use opts.width as weight for Y }); }); _.chain(elements).sortBy(function (x) { return x.i; }).each(function (i) {