Skip to content

Commit 7ac8b2d

Browse files
authored
Merge pull request #675 from vigor-vlad/trashzone_improvement
"trashzone" improvement
2 parents 4dd0a89 + 96355a9 commit 7ac8b2d

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/gridstack.jQueryUI.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,7 @@
7777

7878
JQueryUIGridStackDragDropPlugin.prototype.droppable = function(el, opts) {
7979
el = $(el);
80-
if (opts === 'disable' || opts === 'enable') {
81-
el.droppable(opts);
82-
} else {
83-
el.droppable({
84-
accept: opts.accept
85-
});
86-
}
80+
el.droppable(opts);
8781
return this;
8882
};
8983

src/gridstack.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,9 @@
623623
disableResize: opts.disableResize || false,
624624
rtl: 'auto',
625625
removable: false,
626+
removableOptions: _.defaults(opts.removableOptions || {}, {
627+
accept: '.' + opts.itemClass
628+
}),
626629
removeTimeout: 2000,
627630
verticalMarginUnit: 'px',
628631
cellHeightUnit: 'px',
@@ -770,9 +773,7 @@
770773
if (!self.opts.staticGrid && typeof self.opts.removable === 'string') {
771774
var trashZone = $(self.opts.removable);
772775
if (!this.dd.isDroppable(trashZone)) {
773-
this.dd.droppable(trashZone, {
774-
accept: '.' + self.opts.itemClass
775-
});
776+
this.dd.droppable(trashZone, self.opts.removableOptions);
776777
}
777778
this.dd
778779
.on(trashZone, 'dropover', function(event, ui) {
@@ -781,6 +782,7 @@
781782
if (node._grid !== self) {
782783
return;
783784
}
785+
el.data('inTrashZone', true);
784786
self._setupRemovingTimeout(el);
785787
})
786788
.on(trashZone, 'dropout', function(event, ui) {
@@ -789,6 +791,7 @@
789791
if (node._grid !== self) {
790792
return;
791793
}
794+
el.data('inTrashZone', false);
792795
self._clearRemovingTimeout(el);
793796
});
794797
}
@@ -1097,7 +1100,7 @@
10971100
}
10981101

10991102
if (event.type == 'drag') {
1100-
if (x < 0 || x >= self.grid.width || y < 0 || (!self.grid.float && y > self.grid.getGridHeight())) {
1103+
if (el.data('inTrashZone') || x < 0 || x >= self.grid.width || y < 0 || (!self.grid.float && y > self.grid.getGridHeight())) {
11011104
if (!node._temporaryRemoved) {
11021105
if (self.opts.removable === true) {
11031106
self._setupRemovingTimeout(el);

0 commit comments

Comments
 (0)