Merge pull request #301 from hexagonhexagon/fix-double-waypoint-bug

Fix duplicate waypoints with the same shape key displaying wrong
This commit is contained in:
tobspr 2020-06-27 08:51:15 +02:00 committed by GitHub
commit 7b813ece0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -153,7 +153,16 @@ export class HUDWaypoints extends BaseHUDPart {
if (ShapeDefinition.isValidShortKey(label)) {
const canvas = this.getWaypointCanvas(waypoint);
element.appendChild(canvas);
/**
* Create a clone of the cached canvas, as calling appendElement when a canvas is
* already in the document will move the existing canvas to the new position.
*/
const [newCanvas, context] = makeOffscreenBuffer(48, 48, {
smooth: true,
label: canvas.label + "-waypoint-" + i,
});
context.drawImage(canvas, 0, 0);
element.appendChild(newCanvas);
element.classList.add("shapeIcon");
} else {
element.innerText = label;