I have an application that has an array (selectedTiles). Each Tile in the array has 2 properties that dictate the location of that tile on the page layout (Col(umn) and Row).
<div gridster>
<ul>
<li gridster-item="item" ng-repeat="tile in selectedTiles"></li>
</ul>
</div>
Problem Behavior: When I move a tile (Ex: say swap two tiles), the 'tile.col' and 'tile.row' properties change its values for each tile to correspond to the new grid position. However the order of the indexed array stays the same. This makes the keyboard navigation unordered if it were moving to the next tile by the next index position.
*Goal Behavior Therefore, I need to create a new array that pushes each tile in SelectedTiles into a new array that takes the tile.col and tile.row properties and sorts them, like so:
$scope.selectedTiles = [
{ row: 0, col: 0 },
{ row: 0, col: 1 },
{ row: 0, col: 2 },
{ row: 0, col: 3 }.
{ row: 1, col: 0 },
{ row: 1, col: 1 },
{ row: 1, col: 2 },
{ row: 1, col: 3 },
{ row: 2, col: 0 },
{ row: 2, col: 1 },
{ row: 2, col: 2 },
{ row: 2, col: 3 }
];
That way the index order follows a pattern of having the top-most left tile as the index[0] and bottom-most right tile as the last index in the array everytime a tile is moved.
I haven no idea how to do this