Skip to content

Commit 26dfceb

Browse files
committed
Do not keep a separate list array of dropzones
1 parent 01dcf1c commit 26dfceb

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

interact.js

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@
102102
},
103103

104104
interactables = [], // all set interactables
105-
dropzones = [], // all dropzone element interactables
106105

107106
activeDrops = {
108107
dropzones: [], // the dropzones that are mentioned below
@@ -1131,8 +1130,10 @@
11311130
element = element || target._element;
11321131

11331132
// collect all dropzones and their elements which qualify for a drop
1134-
for (i = 0; i < dropzones.length; i++) {
1135-
var current = dropzones[i];
1133+
for (i = 0; i < interactables.length; i++) {
1134+
if (!interactables[i].options.dropzone) { continue; }
1135+
1136+
var current = interactables[i];
11361137

11371138
// test the draggable element against the dropzone's accept setting
11381139
if ((isElement(current.options.accept) && current.options.accept !== element)
@@ -3043,7 +3044,7 @@
30433044
return delegateListener.call(this, event, true);
30443045
}
30453046

3046-
interactables.indexOfElement = dropzones.indexOfElement = function indexOfElement (element, context) {
3047+
interactables.indexOfElement = function indexOfElement (element, context) {
30473048
for (var i = 0; i < this.length; i++) {
30483049
var interactable = this[i];
30493050

@@ -3058,7 +3059,7 @@
30583059
return -1;
30593060
};
30603061

3061-
interactables.get = dropzones.get = function interactableGet (element, options) {
3062+
interactables.get = function interactableGet (element, options) {
30623063
return this[this.indexOfElement(element, options && options.context)];
30633064
};
30643065

@@ -3303,22 +3304,13 @@
33033304
}
33043305

33053306
this._dropElements = this.selector? null: [this._element];
3306-
dropzones.push(this);
33073307

33083308
return this;
33093309
}
33103310

33113311
if (isBool(options)) {
33123312
if (options) {
33133313
this._dropElements = this.selector? null: [this._element];
3314-
dropzones.push(this);
3315-
}
3316-
else {
3317-
var index = indexOf(dropzones, this);
3318-
3319-
if (index !== -1) {
3320-
dropzones.splice(index, 1);
3321-
}
33223314
}
33233315

33243316
this.options.dropzone = options;
@@ -4836,7 +4828,6 @@
48364828
Interactable : Interactable,
48374829
IOptions : IOptions,
48384830
interactables : interactables,
4839-
dropzones : dropzones,
48404831
pointerIsDown : pointerIsDown,
48414832
defaultOptions : defaultOptions,
48424833
defaultActionChecker : defaultActionChecker,
@@ -5109,9 +5100,9 @@
51095100
if (dragging) {
51105101
activeDrops.dropzones = activeDrops.elements = activeDrops.rects = null;
51115102

5112-
for (var i = 0; i < dropzones.length; i++) {
5113-
if (dropzones[i].selector) {
5114-
dropzones[i]._dropElements = null;
5103+
for (var i = 0; i < interactables.length; i++) {
5104+
if (interactables[i].dropzone && interactables[i].selector) {
5105+
interactables[i]._dropElements = null;
51155106
}
51165107
}
51175108
}

0 commit comments

Comments
 (0)