Skip to content

Commit

Permalink
Merge pull request #43 from M0nter0/master
Browse files Browse the repository at this point in the history
fix bug with sticky position widgets
  • Loading branch information
David S Morse committed Feb 26, 2016
2 parents bb529d4 + 44ce33a commit e7d7b55
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/jquery.gridster.js
Original file line number Diff line number Diff line change
Expand Up @@ -1536,13 +1536,23 @@

this.$changed = this.$changed.add(this.$player);

// move the cells down if there is an overlap and we are in static mode
if (this.options.collision.wait_for_mouseup) {
this.for_each_cell_occupied(this.placeholder_grid_data, function (tcol, trow) {
if (this.is_widget(tcol, trow)) {
this.move_widget_down(this.is_widget(tcol, trow), this.placeholder_grid_data.size_y);
}
});
//If widget has new position, clean previous grid
if (this.placeholder_grid_data.el.coords().grid.col !== this.placeholder_grid_data.col ||
this.placeholder_grid_data.el.coords().grid.row !== this.placeholder_grid_data.row) {
this.update_widget_position(this.placeholder_grid_data.el.coords().grid, false);

// move the cells down if there is an overlap and we are in static mode
if (this.options.collision.wait_for_mouseup) {
this.for_each_cell_occupied(this.placeholder_grid_data, function (tcol, trow) {
if (this.is_widget(tcol, trow)) {
// get number of cells to move
var destinyRow = this.placeholder_grid_data.row + this.placeholder_grid_data.size_y;
var currentOverlappedRow = parseInt(this.gridmap[tcol][trow][0].getAttribute('data-row'));
var cellsToMove = destinyRow - currentOverlappedRow;
this.move_widget_down(this.is_widget(tcol, trow), cellsToMove);
}
});
}
}

this.cells_occupied_by_player = this.get_cells_occupied(this.placeholder_grid_data);
Expand Down Expand Up @@ -1872,9 +1882,6 @@
fn.set_player = function (col, row, no_player) {
var self = this;
var swap = false;
if (!no_player) {
this.empty_cells_player_occupies();
}
var cell = !no_player ? self.colliders_data[0].el.data : {col: col};
var to_col = cell.col;
var to_row = cell.row || row;
Expand Down

0 comments on commit e7d7b55

Please sign in to comment.