From ca16af381ea265f4508ef46f7414af347ec43f38 Mon Sep 17 00:00:00 2001 From: Buck Ryan Date: Mon, 8 Dec 2014 12:01:34 -0500 Subject: [PATCH] Fixes the bias towards getting larger when resizing. Passing 'true' to the pixelsToRows and pixelsToColumns functions causes these functions to use Math.ceil to calculate how many rows or columns the item should occupy. This biases towards getting larger and makes resizing experience undesired. Similarly, 'false' to these functions uses Math.floor. This isn't as important for us since we do not allow resize handles on the left side of charts, but if we did the user would have similarly poor experiences. This also has the effect of fixing a bug when resizing off the grid. Before, if you resized an item all the way to the right of the grid, the item would move to the left and push other items down. Now, you cannot resize past the edge of the grid. --- src/angular-gridster.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/angular-gridster.js b/src/angular-gridster.js index e2b1dffe..4711dfa3 100644 --- a/src/angular-gridster.js +++ b/src/angular-gridster.js @@ -1157,10 +1157,10 @@ oldSizeX = item.sizeX, oldSizeY = item.sizeY, hasCallback = gridster.resizable && gridster.resizable.resize; - item.row = gridster.pixelsToRows(elmY, false); - item.col = gridster.pixelsToColumns(elmX, false); - item.sizeX = gridster.pixelsToColumns(elmW, true); - item.sizeY = gridster.pixelsToRows(elmH, true); + item.row = gridster.pixelsToRows(elmY); + item.col = gridster.pixelsToColumns(elmX); + item.sizeX = gridster.pixelsToColumns(elmW); + item.sizeY = gridster.pixelsToRows(elmH); if ( hasCallback || item.row !== oldRow || item.col !== oldCol || item.sizeX !== oldSizeX || item.sizeY !== oldSizeY