From 1b13617df2ce53235bdf3a1e38f1555f529663c3 Mon Sep 17 00:00:00 2001 From: Ates Goral Date: Wed, 14 Aug 2013 16:32:17 -0400 Subject: [PATCH] fix(gridster): Orphan preview holder when dragging is interrupted After beginning a drag, if the mouse button is released outside of the screen, and if a subsequent drag operation is begun on another widget (while the previous widget still follows the mouse around), Draggable will trigger a new drag start event, causing Gridster to leave the current widget + its preview holder aside and start dragging the new widget. This will lead to an orphan preview holder to be left on the screen. A quick solution is to ignore drag start without receiving a drag stop. --- src/jquery.gridster.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/jquery.gridster.js b/src/jquery.gridster.js index 9cc0a651a..26788bf86 100644 --- a/src/jquery.gridster.js +++ b/src/jquery.gridster.js @@ -647,6 +647,13 @@ offset_left: this.options.widget_margins[0], container_width: this.container_width, start: function(event, ui) { + // Ignore drag start if mouse was released outside screen on a previous drag + if (self.dragging) { + return; + } + + self.dragging = true; + self.$widgets.filter('.player-revert') .removeClass('player-revert'); @@ -659,6 +666,7 @@ self.$el.trigger('gridster:dragstart'); }, stop: function(event, ui) { + self.dragging = false; self.on_stop_drag.call(self, event, ui); self.$el.trigger('gridster:dragstop'); },