Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7b90af2 commit ba208c2Copy full SHA for ba208c2
src/gridstack.js
@@ -3,6 +3,12 @@
3
var Utils = {
4
is_intercepted: function (a, b) {
5
return !(a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y);
6
+ },
7
+
8
+ sort: function (nodes, dir, width) {
9
+ width = width || _.chain(nodes).map(function (node) { return node.x + node.width; }).max().value();
10
+ dir = dir != -1 ? 1 : -1;
11
+ return _.sortBy(nodes, function (n) { return dir * (n.x + n.y * width); });
12
}
13
};
14
@@ -32,8 +38,7 @@
32
38
33
39
34
40
GridStackEngine.prototype._sort_nodes = function (dir) {
35
- dir = dir != -1 ? 1 : -1;
36
- this.nodes = _.sortBy(this.nodes, function (n) { return dir * (n.x + n.y * this.width); }, this);
41
+ this.nodes = Utils.sort(this.nodes, dir, this.width);
37
42
43
44
GridStackEngine.prototype._pack_nodes = function () {
0 commit comments