diff --git a/js/models/Lattice.js b/js/models/Lattice.js index b3d9e3b19f6bbe28787c985cebd057f92589dcce..7137f180f75893b6f9ab3f6e022257d10dbd2e4b 100644 --- a/js/models/Lattice.js +++ b/js/models/Lattice.js @@ -66,22 +66,6 @@ Lattice = Backbone.Model.extend({ window.three.render(); }, - _checkForMatrixExpansion: function(cells, indices){ - - var lastMax = this.get("cellsMax"); - var lastMin = this.get("cellsMin"); - var newMax = this._updateCellsMax(indices, lastMax); - var newMin = this._updateCellsMin(indices, lastMin); - if (newMax) { - this._expandCellsArray(cells, this._subtract(newMax, lastMax), false); - this.set("cellsMax", newMax); - } - if (newMin) { - this._expandCellsArray(cells, this._subtract(lastMin, newMin), true); - this.set("cellsMin", newMin); - } - }, - removeCell: function(cell){ if (!cell) return; var index = this._subtract(cell.indices, this.get("cellsMin")); @@ -112,6 +96,22 @@ Lattice = Backbone.Model.extend({ ///////////////////////////////CELLS ARRAY////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////// + _checkForMatrixExpansion: function(cells, indices){ + + var lastMax = this.get("cellsMax"); + var lastMin = this.get("cellsMin"); + var newMax = this._updateCellsMax(indices, lastMax); + var newMin = this._updateCellsMin(indices, lastMin); + if (newMax) { + this._expandCellsArray(cells, this._subtract(newMax, lastMax), false); + this.set("cellsMax", newMax); + } + if (newMin) { + this._expandCellsArray(cells, this._subtract(lastMin, newMin), true); + this.set("cellsMin", newMin); + } + }, + _expandCellsArray: function(cells, expansion, fromFront){ _.each(_.keys(expansion), function(key){