1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

cleanup pin ClickDetector resource when destroying handle

This commit is contained in:
David Burhans 2020-06-21 11:57:51 -05:00
parent abd48cdc9e
commit 1518d87155

View File

@ -36,11 +36,11 @@ export class HUDShapeStatisticsHandle {
this.element.setAttribute("data-shape-key", shape);
const pinButton = document.createElement("button");
pinButton.classList.add("pin");
const pinDetector = new ClickDetector(pinButton, {
this.pinDetector = new ClickDetector(pinButton, {
consumeEvents: true,
preventDefault: true,
});
pinDetector.click.add(() => {
this.pinDetector.click.add(() => {
if (this.root.hud.parts.pinnedShapes.isShapePinned(shape)) {
this.root.hud.signals.shapeUnpinRequested.dispatch(shape);
} else {
@ -237,6 +237,11 @@ export class HUDShapeStatisticsHandle {
delete this.graphCanvas;
delete this.graphContext;
}
if (this.pinDetector) {
this.pinDetector.cleanup();
delete this.pinDetector;
}
}
/**