Skip to content

Commit ca16af3

Browse files
author
Buck Ryan
committed
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.
1 parent 7b3aead commit ca16af3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/angular-gridster.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1157,10 +1157,10 @@
11571157
oldSizeX = item.sizeX,
11581158
oldSizeY = item.sizeY,
11591159
hasCallback = gridster.resizable && gridster.resizable.resize;
1160-
item.row = gridster.pixelsToRows(elmY, false);
1161-
item.col = gridster.pixelsToColumns(elmX, false);
1162-
item.sizeX = gridster.pixelsToColumns(elmW, true);
1163-
item.sizeY = gridster.pixelsToRows(elmH, true);
1160+
item.row = gridster.pixelsToRows(elmY);
1161+
item.col = gridster.pixelsToColumns(elmX);
1162+
item.sizeX = gridster.pixelsToColumns(elmW);
1163+
item.sizeY = gridster.pixelsToRows(elmH);
11641164

11651165
if (
11661166
hasCallback || item.row !== oldRow || item.col !== oldCol || item.sizeX !== oldSizeX || item.sizeY !== oldSizeY

0 commit comments

Comments
 (0)