From c4fee63b966307c22336b3a3cb01e6c9ceb99260 Mon Sep 17 00:00:00 2001 From: vieron Date: Wed, 3 Oct 2012 15:40:16 +0200 Subject: [PATCH] ability to specify a max row as limit in can_move_to method --- src/jquery.gridster.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/jquery.gridster.js b/src/jquery.gridster.js index e7f0aae1bf..83808236b5 100644 --- a/src/jquery.gridster.js +++ b/src/jquery.gridster.js @@ -1902,9 +1902,10 @@ * the widget. * @param {Object} col The col to check. * @param {Object} row The row to check. + * @param {Number} [max_row] The max row allowed. * @return {Boolean} Returns true if all cells are empty, else return false. */ - fn.can_move_to = function(widget_grid_data, col, row) { + fn.can_move_to = function(widget_grid_data, col, row, max_row) { var ga = this.gridmap; var $w = widget_grid_data.el; var future_wd = { @@ -1919,7 +1920,11 @@ var right_col = col + widget_grid_data.size_x - 1; if (right_col > this.cols) { return false; - }; + } + + if (max_row && max_row < row + widget_grid_data.size_y - 1) { + return false; + } this.for_each_cell_occupied(future_wd, function(tcol, trow) { var $tw = this.is_widget(tcol, trow);