mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-02-22 15:59:20 +00:00
cleanup pin ClickDetector resource when destroying handle
This commit is contained in:
parent
abd48cdc9e
commit
1518d87155
@ -36,11 +36,11 @@ export class HUDShapeStatisticsHandle {
|
|||||||
this.element.setAttribute("data-shape-key", shape);
|
this.element.setAttribute("data-shape-key", shape);
|
||||||
const pinButton = document.createElement("button");
|
const pinButton = document.createElement("button");
|
||||||
pinButton.classList.add("pin");
|
pinButton.classList.add("pin");
|
||||||
const pinDetector = new ClickDetector(pinButton, {
|
this.pinDetector = new ClickDetector(pinButton, {
|
||||||
consumeEvents: true,
|
consumeEvents: true,
|
||||||
preventDefault: true,
|
preventDefault: true,
|
||||||
});
|
});
|
||||||
pinDetector.click.add(() => {
|
this.pinDetector.click.add(() => {
|
||||||
if (this.root.hud.parts.pinnedShapes.isShapePinned(shape)) {
|
if (this.root.hud.parts.pinnedShapes.isShapePinned(shape)) {
|
||||||
this.root.hud.signals.shapeUnpinRequested.dispatch(shape);
|
this.root.hud.signals.shapeUnpinRequested.dispatch(shape);
|
||||||
} else {
|
} else {
|
||||||
@ -237,6 +237,11 @@ export class HUDShapeStatisticsHandle {
|
|||||||
delete this.graphCanvas;
|
delete this.graphCanvas;
|
||||||
delete this.graphContext;
|
delete this.graphContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.pinDetector) {
|
||||||
|
this.pinDetector.cleanup();
|
||||||
|
delete this.pinDetector;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user