gridstack 8.2.3 → 8.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/angular/projects/lib/package.json +1 -1
  2. package/angular/projects/lib/src/lib/base-widget.ts +1 -1
  3. package/angular/projects/lib/src/lib/gridstack-item.component.ts +1 -1
  4. package/angular/projects/lib/src/lib/gridstack.component.ts +1 -1
  5. package/angular/projects/lib/src/lib/gridstack.module.ts +1 -1
  6. package/dist/angular/esm2020/lib/base-widget.mjs +2 -2
  7. package/dist/angular/esm2020/lib/gridstack-item.component.mjs +2 -2
  8. package/dist/angular/esm2020/lib/gridstack.component.mjs +2 -2
  9. package/dist/angular/esm2020/lib/gridstack.module.mjs +2 -2
  10. package/dist/angular/fesm2015/gridstack-angular.mjs +4 -4
  11. package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
  12. package/dist/angular/fesm2020/gridstack-angular.mjs +4 -4
  13. package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
  14. package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
  15. package/dist/angular/lib/gridstack.component.d.ts +1 -1
  16. package/dist/angular/package.json +1 -1
  17. package/dist/angular/src/base-widget.ts +1 -1
  18. package/dist/angular/src/gridstack-item.component.ts +1 -1
  19. package/dist/angular/src/gridstack.component.ts +1 -1
  20. package/dist/angular/src/gridstack.module.ts +1 -1
  21. package/dist/dd-base-impl.d.ts +1 -1
  22. package/dist/dd-base-impl.js +1 -1
  23. package/dist/dd-base-impl.js.map +1 -1
  24. package/dist/dd-draggable.d.ts +1 -1
  25. package/dist/dd-draggable.js +1 -1
  26. package/dist/dd-draggable.js.map +1 -1
  27. package/dist/dd-droppable.d.ts +1 -1
  28. package/dist/dd-droppable.js +1 -1
  29. package/dist/dd-droppable.js.map +1 -1
  30. package/dist/dd-element.d.ts +1 -1
  31. package/dist/dd-element.js +1 -1
  32. package/dist/dd-element.js.map +1 -1
  33. package/dist/dd-gridstack.d.ts +1 -1
  34. package/dist/dd-gridstack.js +1 -1
  35. package/dist/dd-gridstack.js.map +1 -1
  36. package/dist/dd-manager.d.ts +1 -1
  37. package/dist/dd-manager.js +1 -1
  38. package/dist/dd-manager.js.map +1 -1
  39. package/dist/dd-resizable-handle.d.ts +1 -1
  40. package/dist/dd-resizable-handle.js +1 -1
  41. package/dist/dd-resizable-handle.js.map +1 -1
  42. package/dist/dd-resizable.d.ts +1 -1
  43. package/dist/dd-resizable.js +1 -1
  44. package/dist/dd-resizable.js.map +1 -1
  45. package/dist/dd-touch.d.ts +1 -1
  46. package/dist/dd-touch.js +1 -1
  47. package/dist/dd-touch.js.map +1 -1
  48. package/dist/es5/dd-base-impl.d.ts +1 -1
  49. package/dist/es5/dd-base-impl.js +1 -1
  50. package/dist/es5/dd-base-impl.js.map +1 -1
  51. package/dist/es5/dd-draggable.d.ts +1 -1
  52. package/dist/es5/dd-draggable.js +1 -1
  53. package/dist/es5/dd-draggable.js.map +1 -1
  54. package/dist/es5/dd-droppable.d.ts +1 -1
  55. package/dist/es5/dd-droppable.js +1 -1
  56. package/dist/es5/dd-droppable.js.map +1 -1
  57. package/dist/es5/dd-element.d.ts +1 -1
  58. package/dist/es5/dd-element.js +1 -1
  59. package/dist/es5/dd-element.js.map +1 -1
  60. package/dist/es5/dd-gridstack.d.ts +1 -1
  61. package/dist/es5/dd-gridstack.js +1 -1
  62. package/dist/es5/dd-gridstack.js.map +1 -1
  63. package/dist/es5/dd-manager.d.ts +1 -1
  64. package/dist/es5/dd-manager.js +1 -1
  65. package/dist/es5/dd-manager.js.map +1 -1
  66. package/dist/es5/dd-resizable-handle.d.ts +1 -1
  67. package/dist/es5/dd-resizable-handle.js +1 -1
  68. package/dist/es5/dd-resizable-handle.js.map +1 -1
  69. package/dist/es5/dd-resizable.d.ts +1 -1
  70. package/dist/es5/dd-resizable.js +1 -1
  71. package/dist/es5/dd-resizable.js.map +1 -1
  72. package/dist/es5/dd-touch.d.ts +1 -1
  73. package/dist/es5/dd-touch.js +1 -1
  74. package/dist/es5/dd-touch.js.map +1 -1
  75. package/dist/es5/gridstack-all.js +1 -1
  76. package/dist/es5/gridstack-all.js.LICENSE.txt +1 -1
  77. package/dist/es5/gridstack-all.js.map +1 -1
  78. package/dist/es5/gridstack-engine.d.ts +9 -8
  79. package/dist/es5/gridstack-engine.js +115 -73
  80. package/dist/es5/gridstack-engine.js.map +1 -1
  81. package/dist/es5/gridstack-poly.js +1 -1
  82. package/dist/es5/gridstack.d.ts +11 -5
  83. package/dist/es5/gridstack.js +15 -7
  84. package/dist/es5/gridstack.js.map +1 -1
  85. package/dist/es5/types.d.ts +11 -4
  86. package/dist/es5/types.js +1 -1
  87. package/dist/es5/types.js.map +1 -1
  88. package/dist/es5/utils.d.ts +2 -2
  89. package/dist/es5/utils.js +2 -1
  90. package/dist/es5/utils.js.map +1 -1
  91. package/dist/gridstack-all.js +1 -1
  92. package/dist/gridstack-all.js.LICENSE.txt +1 -1
  93. package/dist/gridstack-all.js.map +1 -1
  94. package/dist/gridstack-engine.d.ts +9 -8
  95. package/dist/gridstack-engine.js +110 -73
  96. package/dist/gridstack-engine.js.map +1 -1
  97. package/dist/gridstack.css +1 -1
  98. package/dist/gridstack.d.ts +11 -5
  99. package/dist/gridstack.js +13 -7
  100. package/dist/gridstack.js.map +1 -1
  101. package/dist/src/gridstack.scss +1 -1
  102. package/dist/types.d.ts +11 -4
  103. package/dist/types.js +1 -1
  104. package/dist/types.js.map +1 -1
  105. package/dist/utils.d.ts +2 -2
  106. package/dist/utils.js +2 -2
  107. package/dist/utils.js.map +1 -1
  108. package/doc/CHANGES.md +4 -0
  109. package/doc/README.md +16 -7
  110. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  /**
2
- * gridstack-engine.ts 8.2.3
2
+ * gridstack-engine.ts 8.3.0
3
3
  * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
4
4
  */
5
- import { GridStackNode, GridStackPosition, GridStackMoveOpts, SaveFcn } from './types';
5
+ import { GridStackNode, GridStackPosition, GridStackMoveOpts, SaveFcn, CompactOptions } from './types';
6
6
  /** callback to update the DOM attributes since this class is generic (no HTML or other info) for items that changed - see _notify() */
7
7
  type OnChangeCB = (nodes: GridStackNode[]) => void;
8
8
  /** options used during creation - similar to GridStackOptions */
@@ -27,7 +27,7 @@ export declare class GridStackEngine {
27
27
  removedNodes: GridStackNode[];
28
28
  batchMode: boolean;
29
29
  constructor(opts?: GridStackEngineOptions);
30
- batchUpdate(flag?: boolean): GridStackEngine;
30
+ batchUpdate(flag?: boolean, doPack?: boolean): GridStackEngine;
31
31
  protected _useEntireRowArea(node: GridStackNode, nn: GridStackPosition): boolean;
32
32
  /** return the nodes that intercept the given node. Optionally a different area can be used, as well as a second node to skip */
33
33
  collide(skip: GridStackNode, area?: GridStackNode, skip2?: GridStackNode): GridStackNode;
@@ -40,14 +40,14 @@ export declare class GridStackEngine {
40
40
  /** called to possibly swap between 2 nodes (same size or column, not locked, touching), returning true if successful */
41
41
  swap(a: GridStackNode, b: GridStackNode): boolean;
42
42
  isAreaEmpty(x: number, y: number, w: number, h: number): boolean;
43
- /** re-layout grid items to reclaim any empty space */
44
- compact(): GridStackEngine;
43
+ /** re-layout grid items to reclaim any empty space - optionally keeping the sort order exactly the same ('list' mode) vs truly finding an empty spaces */
44
+ compact(layout?: CompactOptions, doSort?: boolean): GridStackEngine;
45
45
  /** enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html) */
46
46
  set float(val: boolean);
47
47
  /** float getter method */
48
48
  get float(): boolean;
49
49
  /** sort the nodes array from first to last, or reverse. Called during collision/placement to force an order */
50
- sortNodes(dir?: -1 | 1): GridStackEngine;
50
+ sortNodes(dir?: 1 | -1, column?: number): GridStackEngine;
51
51
  /**
52
52
  * given a random node, makes sure it's coordinates/values are valid in the current grid
53
53
  * @param node to adjust
@@ -60,10 +60,11 @@ export declare class GridStackEngine {
60
60
  getDirtyNodes(verify?: boolean): GridStackNode[];
61
61
  /** find the first available empty spot for the given node width/height, updating the x,y attributes. return true if found.
62
62
  * optionally you can pass your own existing node list and column count, otherwise defaults to that engine data.
63
+ * Optionally pass a widget to start search AFTER, meaning the order will remain the same but possibly have empty slots we skipped
63
64
  */
64
- findEmptyPosition(node: GridStackNode, nodeList?: GridStackNode[], column?: number): boolean;
65
+ findEmptyPosition(node: GridStackNode, nodeList?: GridStackNode[], column?: number, after?: GridStackNode): boolean;
65
66
  /** call to add the given node to our list, fixing collision and re-packing */
66
- addNode(node: GridStackNode, triggerAddEvent?: boolean): GridStackNode;
67
+ addNode(node: GridStackNode, triggerAddEvent?: boolean, after?: GridStackNode): GridStackNode;
67
68
  removeNode(node: GridStackNode, removeDOM?: boolean, triggerEvent?: boolean): GridStackEngine;
68
69
  removeAll(removeDOM?: boolean): GridStackEngine;
69
70
  /** checks if item can be moved (layout constrain) vs moveNode(), returning true if was able to move.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * gridstack-engine.ts 8.2.3
3
+ * gridstack-engine.ts 8.3.0
4
4
  * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
5
5
  */
6
6
  var __assign = (this && this.__assign) || function () {
@@ -34,8 +34,9 @@ var GridStackEngine = exports.GridStackEngine = /** @class */ (function () {
34
34
  this.nodes = opts.nodes || [];
35
35
  this.onChange = opts.onChange;
36
36
  }
37
- GridStackEngine.prototype.batchUpdate = function (flag) {
37
+ GridStackEngine.prototype.batchUpdate = function (flag, doPack) {
38
38
  if (flag === void 0) { flag = true; }
39
+ if (doPack === void 0) { doPack = true; }
39
40
  if (!!this.batchMode === flag)
40
41
  return this;
41
42
  this.batchMode = flag;
@@ -47,7 +48,9 @@ var GridStackEngine = exports.GridStackEngine = /** @class */ (function () {
47
48
  else {
48
49
  this._float = this._prevFloat;
49
50
  delete this._prevFloat;
50
- this._packNodes()._notify();
51
+ if (doPack)
52
+ this._packNodes();
53
+ this._notify();
51
54
  }
52
55
  return this;
53
56
  };
@@ -254,23 +257,37 @@ var GridStackEngine = exports.GridStackEngine = /** @class */ (function () {
254
257
  var nn = { x: x || 0, y: y || 0, w: w || 1, h: h || 1 };
255
258
  return !this.collide(nn);
256
259
  };
257
- /** re-layout grid items to reclaim any empty space */
258
- GridStackEngine.prototype.compact = function () {
260
+ /** re-layout grid items to reclaim any empty space - optionally keeping the sort order exactly the same ('list' mode) vs truly finding an empty spaces */
261
+ GridStackEngine.prototype.compact = function (layout, doSort) {
259
262
  var _this = this;
263
+ if (layout === void 0) { layout = 'compact'; }
264
+ if (doSort === void 0) { doSort = true; }
260
265
  if (this.nodes.length === 0)
261
266
  return this;
262
- this.batchUpdate()
263
- .sortNodes();
267
+ if (doSort)
268
+ this.sortNodes();
269
+ var wasBatch = this.batchMode;
270
+ if (!wasBatch)
271
+ this.batchUpdate();
272
+ var wasColumnResize = this._inColumnResize;
273
+ if (!wasColumnResize)
274
+ this._inColumnResize = true; // faster addNode()
264
275
  var copyNodes = this.nodes;
265
276
  this.nodes = []; // pretend we have no nodes to conflict layout to start with...
266
- copyNodes.forEach(function (node) {
267
- if (!node.locked) {
268
- node.autoPosition = true;
277
+ copyNodes.forEach(function (n, index, list) {
278
+ var after;
279
+ if (!n.locked) {
280
+ n.autoPosition = true;
281
+ if (layout === 'list' && index)
282
+ after = list[index - 1];
269
283
  }
270
- _this.addNode(node, false); // 'false' for add event trigger
271
- node._dirty = true; // will force attr update
284
+ _this.addNode(n, false, after); // 'false' for add event trigger
272
285
  });
273
- return this.batchUpdate(false);
286
+ if (!wasColumnResize)
287
+ delete this._inColumnResize;
288
+ if (!wasBatch)
289
+ this.batchUpdate(false);
290
+ return this;
274
291
  };
275
292
  Object.defineProperty(GridStackEngine.prototype, "float", {
276
293
  /** float getter method */
@@ -288,8 +305,10 @@ var GridStackEngine = exports.GridStackEngine = /** @class */ (function () {
288
305
  configurable: true
289
306
  });
290
307
  /** sort the nodes array from first to last, or reverse. Called during collision/placement to force an order */
291
- GridStackEngine.prototype.sortNodes = function (dir) {
292
- this.nodes = utils_1.Utils.sort(this.nodes, dir, this.column);
308
+ GridStackEngine.prototype.sortNodes = function (dir, column) {
309
+ if (dir === void 0) { dir = 1; }
310
+ if (column === void 0) { column = this.column; }
311
+ this.nodes = utils_1.Utils.sort(this.nodes, dir, column);
293
312
  return this;
294
313
  };
295
314
  /** @internal called to top gravity pack the items back OR revert back to original Y positions when floating */
@@ -509,11 +528,12 @@ var GridStackEngine = exports.GridStackEngine = /** @class */ (function () {
509
528
  };
510
529
  /** find the first available empty spot for the given node width/height, updating the x,y attributes. return true if found.
511
530
  * optionally you can pass your own existing node list and column count, otherwise defaults to that engine data.
531
+ * Optionally pass a widget to start search AFTER, meaning the order will remain the same but possibly have empty slots we skipped
512
532
  */
513
- GridStackEngine.prototype.findEmptyPosition = function (node, nodeList, column) {
533
+ GridStackEngine.prototype.findEmptyPosition = function (node, nodeList, column, after) {
514
534
  if (nodeList === void 0) { nodeList = this.nodes; }
515
535
  if (column === void 0) { column = this.column; }
516
- nodeList = utils_1.Utils.sort(nodeList, -1, column);
536
+ var start = after ? after.y * column + (after.x + after.w) : 0;
517
537
  var found = false;
518
538
  var _loop_1 = function (i) {
519
539
  var x = i % column;
@@ -523,19 +543,21 @@ var GridStackEngine = exports.GridStackEngine = /** @class */ (function () {
523
543
  }
524
544
  var box = { x: x, y: y, w: node.w, h: node.h };
525
545
  if (!nodeList.find(function (n) { return utils_1.Utils.isIntercepted(box, n); })) {
546
+ if (node.x !== x || node.y !== y)
547
+ node._dirty = true;
526
548
  node.x = x;
527
549
  node.y = y;
528
550
  delete node.autoPosition;
529
551
  found = true;
530
552
  }
531
553
  };
532
- for (var i = 0; !found; ++i) {
554
+ for (var i = start; !found; ++i) {
533
555
  _loop_1(i);
534
556
  }
535
557
  return found;
536
558
  };
537
559
  /** call to add the given node to our list, fixing collision and re-packing */
538
- GridStackEngine.prototype.addNode = function (node, triggerAddEvent) {
560
+ GridStackEngine.prototype.addNode = function (node, triggerAddEvent, after) {
539
561
  if (triggerAddEvent === void 0) { triggerAddEvent = false; }
540
562
  var dup = this.nodes.find(function (n) { return n._id === node._id; });
541
563
  if (dup)
@@ -544,14 +566,17 @@ var GridStackEngine = exports.GridStackEngine = /** @class */ (function () {
544
566
  node = this._inColumnResize ? this.nodeBoundFix(node) : this.prepareNode(node);
545
567
  delete node._temporaryRemoved;
546
568
  delete node._removeDOM;
547
- if (node.autoPosition && this.findEmptyPosition(node)) {
569
+ var skipCollision;
570
+ if (node.autoPosition && this.findEmptyPosition(node, this.nodes, this.column, after)) {
548
571
  delete node.autoPosition; // found our slot
572
+ skipCollision = true;
549
573
  }
550
574
  this.nodes.push(node);
551
575
  if (triggerAddEvent) {
552
576
  this.addedNodes.push(node);
553
577
  }
554
- this._fixCollisions(node);
578
+ if (!skipCollision)
579
+ this._fixCollisions(node);
555
580
  if (!this.batchMode) {
556
581
  this._packNodes()._notify();
557
582
  }
@@ -848,17 +873,23 @@ var GridStackEngine = exports.GridStackEngine = /** @class */ (function () {
848
873
  * @param layout specify the type of re-layout that will happen (position, size, etc...).
849
874
  * Note: items will never be outside of the current column boundaries. default (moveScale). Ignored for 1 column
850
875
  */
851
- GridStackEngine.prototype.updateNodeWidths = function (prevColumn, column, nodes, layout) {
876
+ GridStackEngine.prototype.columnChanged = function (prevColumn, column, nodes, layout) {
852
877
  var _this = this;
853
878
  var _a;
854
879
  if (layout === void 0) { layout = 'moveScale'; }
855
880
  if (!this.nodes.length || !column || prevColumn === column)
856
881
  return this;
857
- // cache the current layout in case they want to go back (like 12 -> 1 -> 12) as it requires original data
858
- this.cacheLayout(this.nodes, prevColumn);
882
+ // simpler shortcuts layouts
883
+ var doCompact = layout === 'compact' || layout === 'list';
884
+ if (doCompact) {
885
+ this.sortNodes(1, prevColumn); // sort with original layout once and only once (new column will affect order otherwise)
886
+ }
887
+ // cache the current layout in case they want to go back (like 12 -> 1 -> 12) as it requires original data IFF we're sizing down (see below)
888
+ if (column < prevColumn)
889
+ this.cacheLayout(this.nodes, prevColumn);
859
890
  this.batchUpdate(); // do this EARLY as it will call saveInitial() so we can detect where we started for _dirty and collision
860
891
  var newNodes = [];
861
- // if we're going to 1 column and using DOM order rather than default sorting, then generate that layout
892
+ // if we're going to 1 column and using DOM order (item passed in) rather than default sorting, then generate that layout
862
893
  var domOrder = false;
863
894
  if (column === 1 && (nodes === null || nodes === void 0 ? void 0 : nodes.length)) {
864
895
  domOrder = true;
@@ -873,13 +904,12 @@ var GridStackEngine = exports.GridStackEngine = /** @class */ (function () {
873
904
  nodes = [];
874
905
  }
875
906
  else {
876
- nodes = utils_1.Utils.sort(this.nodes, -1, prevColumn); // current column reverse sorting so we can insert last to front (limit collision)
907
+ nodes = doCompact ? this.nodes : utils_1.Utils.sort(this.nodes, -1, prevColumn); // current column reverse sorting so we can insert last to front (limit collision)
877
908
  }
878
909
  // see if we have cached previous layout IFF we are going up in size (restore) otherwise always
879
910
  // generate next size down from where we are (looks more natural as you gradually size down).
880
- var cacheNodes = [];
881
- if (column > prevColumn) {
882
- cacheNodes = this._layouts[column] || [];
911
+ if (column > prevColumn && this._layouts) {
912
+ var cacheNodes = this._layouts[column] || [];
883
913
  // ...if not, start with the largest layout (if not already there) as down-scaling is more accurate
884
914
  // by pretending we came from that larger column by assigning those values as starting point
885
915
  var lastIndex = this._layouts.length - 1;
@@ -889,59 +919,71 @@ var GridStackEngine = exports.GridStackEngine = /** @class */ (function () {
889
919
  var n = nodes.find(function (n) { return n._id === cacheNode._id; });
890
920
  if (n) {
891
921
  // still current, use cache info positions
892
- n.x = cacheNode.x;
893
- n.y = cacheNode.y;
922
+ if (!doCompact) {
923
+ n.x = cacheNode.x;
924
+ n.y = cacheNode.y;
925
+ }
894
926
  n.w = cacheNode.w;
895
927
  }
896
928
  });
897
929
  }
930
+ // if we found cache re-use those nodes that are still current
931
+ cacheNodes.forEach(function (cacheNode) {
932
+ var j = nodes.findIndex(function (n) { return n._id === cacheNode._id; });
933
+ if (j !== -1) {
934
+ // still current, use cache info positions
935
+ if (doCompact) {
936
+ nodes[j].w = cacheNode.w; // only w is used, and don't trim the list
937
+ return;
938
+ }
939
+ if (cacheNode.autoPosition || isNaN(cacheNode.x) || isNaN(cacheNode.y)) {
940
+ _this.findEmptyPosition(cacheNode, newNodes);
941
+ }
942
+ if (!cacheNode.autoPosition) {
943
+ nodes[j].x = cacheNode.x;
944
+ nodes[j].y = cacheNode.y;
945
+ nodes[j].w = cacheNode.w;
946
+ newNodes.push(nodes[j]);
947
+ }
948
+ nodes.splice(j, 1);
949
+ }
950
+ });
951
+ }
952
+ // much simpler layout that just compacts
953
+ if (doCompact) {
954
+ this.compact(layout, false);
898
955
  }
899
- // if we found cache re-use those nodes that are still current
900
- cacheNodes.forEach(function (cacheNode) {
901
- var j = nodes.findIndex(function (n) { return n._id === cacheNode._id; });
902
- if (j !== -1) {
903
- // still current, use cache info positions
904
- if (cacheNode.autoPosition || isNaN(cacheNode.x) || isNaN(cacheNode.y)) {
905
- _this.findEmptyPosition(cacheNode, newNodes);
956
+ else {
957
+ // ...and add any extra non-cached ones
958
+ if (nodes.length) {
959
+ if (typeof layout === 'function') {
960
+ layout(column, prevColumn, newNodes, nodes);
906
961
  }
907
- if (!cacheNode.autoPosition) {
908
- nodes[j].x = cacheNode.x;
909
- nodes[j].y = cacheNode.y;
910
- nodes[j].w = cacheNode.w;
911
- newNodes.push(nodes[j]);
962
+ else if (!domOrder) {
963
+ var ratio_2 = (doCompact || layout === 'none') ? 1 : column / prevColumn;
964
+ var move_1 = (layout === 'move' || layout === 'moveScale');
965
+ var scale_1 = (layout === 'scale' || layout === 'moveScale');
966
+ nodes.forEach(function (node) {
967
+ // NOTE: x + w could be outside of the grid, but addNode() below will handle that
968
+ node.x = (column === 1 ? 0 : (move_1 ? Math.round(node.x * ratio_2) : Math.min(node.x, column - 1)));
969
+ node.w = ((column === 1 || prevColumn === 1) ? 1 : scale_1 ? (Math.round(node.w * ratio_2) || 1) : (Math.min(node.w, column)));
970
+ newNodes.push(node);
971
+ });
972
+ nodes = [];
912
973
  }
913
- nodes.splice(j, 1);
914
- }
915
- });
916
- // ...and add any extra non-cached ones
917
- if (nodes.length) {
918
- if (typeof layout === 'function') {
919
- layout(column, prevColumn, newNodes, nodes);
920
- }
921
- else if (!domOrder) {
922
- var ratio_2 = column / prevColumn;
923
- var move_1 = (layout === 'move' || layout === 'moveScale');
924
- var scale_1 = (layout === 'scale' || layout === 'moveScale');
925
- nodes.forEach(function (node) {
926
- // NOTE: x + w could be outside of the grid, but addNode() below will handle that
927
- node.x = (column === 1 ? 0 : (move_1 ? Math.round(node.x * ratio_2) : Math.min(node.x, column - 1)));
928
- node.w = ((column === 1 || prevColumn === 1) ? 1 :
929
- scale_1 ? (Math.round(node.w * ratio_2) || 1) : (Math.min(node.w, column)));
930
- newNodes.push(node);
931
- });
932
- nodes = [];
933
974
  }
975
+ // finally re-layout them in reverse order (to get correct placement)
976
+ if (!domOrder)
977
+ newNodes = utils_1.Utils.sort(newNodes, -1, column);
978
+ this._inColumnResize = true; // prevent cache update
979
+ this.nodes = []; // pretend we have no nodes to start with (add() will use same structures) to simplify layout
980
+ newNodes.forEach(function (node) {
981
+ _this.addNode(node, false); // 'false' for add event trigger
982
+ delete node._orig; // make sure the commit doesn't try to restore things back to original
983
+ });
934
984
  }
935
- // finally re-layout them in reverse order (to get correct placement)
936
- if (!domOrder)
937
- newNodes = utils_1.Utils.sort(newNodes, -1, column);
938
- this._inColumnResize = true; // prevent cache update
939
- this.nodes = []; // pretend we have no nodes to start with (add() will use same structures) to simplify layout
940
- newNodes.forEach(function (node) {
941
- _this.addNode(node, false); // 'false' for add event trigger
942
- delete node._orig; // make sure the commit doesn't try to restore things back to original
943
- });
944
- this.batchUpdate(false);
985
+ this.nodes.forEach(function (n) { return delete n._orig; }); // clear _orig before batch=false so it doesn't handle float=true restore
986
+ this.batchUpdate(false, !doCompact);
945
987
  delete this._inColumnResize;
946
988
  return this;
947
989
  };