|
1209 | 1209 | var self = this; |
1210 | 1210 |
|
1211 | 1211 | var cellWidth; |
1212 | | - var cellHeight; |
| 1212 | + var cellFullHeight; // internal cellHeight + v-margin |
1213 | 1213 |
|
1214 | 1214 | var dragOrResize = function(event, ui) { |
1215 | 1215 | var x = Math.round(ui.position.left / cellWidth); |
1216 | | - var y = Math.floor((ui.position.top + cellHeight / 2) / cellHeight); |
| 1216 | + var y = Math.floor((ui.position.top + cellFullHeight / 2) / cellFullHeight); |
1217 | 1217 | var width; |
1218 | 1218 | var height; |
1219 | 1219 |
|
1220 | | - if (event.type !== 'drag') { |
1221 | | - width = Math.round(ui.size.width / cellWidth); |
1222 | | - height = Math.round(ui.size.height / cellHeight); |
1223 | | - } |
1224 | | - |
1225 | 1220 | if (event.type === 'drag') { |
1226 | 1221 | var distance = ui.position.top - node._prevYPix; |
1227 | 1222 | node._prevYPix = ui.position.top; |
|
1262 | 1257 | } |
1263 | 1258 | } |
1264 | 1259 | } else if (event.type === 'resize') { |
1265 | | - if (x < 0) { |
1266 | | - return; |
1267 | | - } |
| 1260 | + if (x < 0) return; |
| 1261 | + width = Math.round(ui.size.width / cellWidth); |
| 1262 | + height = Math.round((ui.size.height + self.verticalMargin()) / cellFullHeight); |
1268 | 1263 | } |
1269 | 1264 | // width and height are undefined if not resizing |
1270 | 1265 | var lastTriedWidth = width !== undefined ? width : node.lastTriedWidth; |
|
1292 | 1287 | self.engine.cleanNodes(); |
1293 | 1288 | self.engine.beginUpdate(node); |
1294 | 1289 | cellWidth = self.cellWidth(); |
1295 | | - var strictCellHeight = self.cellHeight(); |
1296 | | - // TODO: cellHeight = cellHeight() causes issue (i.e. remove strictCellHeight above) otherwise |
1297 | | - // when sizing up we jump almost right away to next size instead of half way there. Not sure |
1298 | | - // why as we don't use ceil() in many places but round() instead. |
1299 | | - cellHeight = (self.$el.height() + grid.verticalMargin()) / parseInt(self.$el.attr('data-gs-current-row')); |
| 1290 | + var strictCellHeight = self.cellHeight(); // heigh without v-margin |
| 1291 | + // compute height with v-margin (Note: we add 1 margin as last row is missing it) |
| 1292 | + cellFullHeight = (self.$el.height() + self.verticalMargin()) / parseInt(self.$el.attr('data-gs-current-row')); |
1300 | 1293 | self.placeholder |
1301 | 1294 | .attr('data-gs-x', o.attr('data-gs-x')) |
1302 | 1295 | .attr('data-gs-y', o.attr('data-gs-y')) |
|
0 commit comments