From d57dff7db3841ca5c0be42478b31eeb929743d5d Mon Sep 17 00:00:00 2001 From: Sebastiaan la Fleur Date: Wed, 17 Aug 2016 11:59:17 +0200 Subject: [PATCH] Now use top and bottom of widget instead of just center height when calculating remove. Fixes the removal of widgets when top leaves grid --- src/gridstack.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gridstack.js b/src/gridstack.js index 0e6a74b..923b23e 100644 --- a/src/gridstack.js +++ b/src/gridstack.js @@ -986,6 +986,8 @@ var dragOrResize = function(event, ui) { var x = Math.round(ui.position.left / cellWidth); var y = Math.floor((ui.position.top + cellHeight / 2) / cellHeight); + var yTop = Math.floor(ui.position.top / cellHeight); + var yBottom = Math.floor((ui.position.top + cellHeight) / cellHeight); var width; var height; @@ -995,7 +997,7 @@ } if (event.type == 'drag') { - if (x < 0 || x >= self.grid.width || y < 0) { + if (x < 0 || x >= self.grid.width || yTop < 0 || yBottom > self.grid.height) { if (self.opts.removable === true) { self._setupRemovingTimeout(el); }