|
1536 | 1536 |
|
1537 | 1537 | this.$changed = this.$changed.add(this.$player); |
1538 | 1538 |
|
1539 | | - // move the cells down if there is an overlap and we are in static mode |
1540 | | - if (this.options.collision.wait_for_mouseup) { |
1541 | | - this.for_each_cell_occupied(this.placeholder_grid_data, function (tcol, trow) { |
1542 | | - if (this.is_widget(tcol, trow)) { |
1543 | | - this.move_widget_down(this.is_widget(tcol, trow), this.placeholder_grid_data.size_y); |
1544 | | - } |
1545 | | - }); |
| 1539 | + //If widget has new position, clean previous grid |
| 1540 | + if (this.placeholder_grid_data.el.coords().grid.col !== this.placeholder_grid_data.col || |
| 1541 | + this.placeholder_grid_data.el.coords().grid.row !== this.placeholder_grid_data.row) { |
| 1542 | + this.update_widget_position(this.placeholder_grid_data.el.coords().grid, false); |
| 1543 | + |
| 1544 | + // move the cells down if there is an overlap and we are in static mode |
| 1545 | + if (this.options.collision.wait_for_mouseup) { |
| 1546 | + this.for_each_cell_occupied(this.placeholder_grid_data, function (tcol, trow) { |
| 1547 | + if (this.is_widget(tcol, trow)) { |
| 1548 | + // get number of cells to move |
| 1549 | + var destinyRow = this.placeholder_grid_data.row + this.placeholder_grid_data.size_y; |
| 1550 | + var currentOverlappedRow = parseInt(this.gridmap[tcol][trow][0].getAttribute('data-row')); |
| 1551 | + var cellsToMove = destinyRow - currentOverlappedRow; |
| 1552 | + this.move_widget_down(this.is_widget(tcol, trow), cellsToMove); |
| 1553 | + } |
| 1554 | + }); |
| 1555 | + } |
1546 | 1556 | } |
1547 | 1557 |
|
1548 | 1558 | this.cells_occupied_by_player = this.get_cells_occupied(this.placeholder_grid_data); |
|
1872 | 1882 | fn.set_player = function (col, row, no_player) { |
1873 | 1883 | var self = this; |
1874 | 1884 | var swap = false; |
1875 | | - if (!no_player) { |
1876 | | - this.empty_cells_player_occupies(); |
1877 | | - } |
1878 | 1885 | var cell = !no_player ? self.colliders_data[0].el.data : {col: col}; |
1879 | 1886 | var to_col = cell.col; |
1880 | 1887 | var to_row = cell.row || row; |
|
0 commit comments