Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ac2043

Browse files
committed
improve y calc when dragging
1 parent 320c4e1 commit 2ac2043

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/gridstack.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@
395395
});
396396
el.data('_gridstack_node', node);
397397

398-
var cell_width, cell_height = this.opts.cell_height + this.opts.vertical_margin / 2;
398+
var cell_width, cell_height = this.opts.cell_height + this.opts.vertical_margin;
399399

400400
var on_start_moving = function (event, ui) {
401401
var o = $(this);
@@ -442,7 +442,7 @@
442442
stop: on_end_moving,
443443
drag: function (event, ui) {
444444
var x = Math.round(ui.position.left / cell_width),
445-
y = Math.floor(ui.position.top / cell_height);
445+
y = Math.floor((ui.position.top + cell_height/2) / cell_height);
446446
if (self.opts.height && !self.grid.can_move_node(node, x, y, node.width, node.height)) {
447447
return;
448448
}

0 commit comments

Comments
 (0)