Skip to content
Snippets Groups Projects
Commit 55af93d0 authored by netpro2k's avatar netpro2k
Browse files

Fix issue deleting objects in sticky-zones

parent 59ceecc5
No related branches found
No related tags found
No related merge requests found
...@@ -64,6 +64,12 @@ AFRAME.registerComponent("sticky-object", { ...@@ -64,6 +64,12 @@ AFRAME.registerComponent("sticky-object", {
_onGrab() { _onGrab() {
this.setLocked(false); this.setLocked(false);
},
remove() {
if (this.stuckTo) {
delete this.stuckTo.stuckObject;
}
} }
}); });
...@@ -90,12 +96,9 @@ AFRAME.registerComponent("sticky-object-zone", { ...@@ -90,12 +96,9 @@ AFRAME.registerComponent("sticky-object-zone", {
if (this.stuckObject) { if (this.stuckObject) {
e.detail.clearedEls.forEach(el => { e.detail.clearedEls.forEach(el => {
if (this.stuckObject && this.stuckObject.el === el) { if (this.stuckObject && this.stuckObject.el === el) {
// this condition will be false when dragging an object directly from one sticky zone to another this._unstickObject();
if (this.stuckObject.stuckTo === this) {
this._unstickObject();
}
delete this.stuckObject;
} }
delete this.stuckObject;
}); });
} }
}); });
...@@ -117,8 +120,11 @@ AFRAME.registerComponent("sticky-object-zone", { ...@@ -117,8 +120,11 @@ AFRAME.registerComponent("sticky-object-zone", {
}, },
_unstickObject() { _unstickObject() {
this.stuckObject.setLocked(false); // this condition will be false when dragging an object directly from one sticky zone to another
this.stuckObject.el.body.collisionResponse = true; if (this.stuckObject.stuckTo === this) {
delete this.stuckObject.stuckTo; this.stuckObject.setLocked(false);
this.stuckObject.el.body.collisionResponse = true;
delete this.stuckObject.stuckTo;
}
} }
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment