1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2024-10-27 20:34:29 +00:00

Fix pinned shapes not being removable

This commit is contained in:
tobspr 2020-10-07 18:05:11 +02:00
parent 7dccc1a844
commit f3dcdeb2b8
2 changed files with 8 additions and 17 deletions

View File

@ -17,30 +17,20 @@
grid-template-rows: 1fr 1fr; grid-template-rows: 1fr 1fr;
@include S(margin-bottom, 4px); @include S(margin-bottom, 4px);
color: #333438; color: #333438;
// text-shadow: #{D(1px)} #{D(1px)} 0 rgba(0, 10, 20, 0.2);
&.unpinable { &.removable {
> canvas {
cursor: pointer; cursor: pointer;
pointer-events: all; pointer-events: all;
} }
}
> canvas { > canvas {
@include S(width, 25px); @include S(width, 25px);
@include S(height, 25px); @include S(height, 25px);
grid-column: 1 / 2; grid-column: 1 / 2;
grid-row: 1 / 3; grid-row: 1 / 3;
pointer-events: all; pointer-events: none;
transition: transform 0.1s ease-in-out;
transform-origin: D(2px) center;
will-change: transform;
position: relative;
z-index: 20; z-index: 20;
&:hover { position: relative;
transform: scale(2);
z-index: 21;
}
} }
> .amountLabel, > .amountLabel,

View File

@ -217,11 +217,11 @@ export class HUDPinnedShapes extends BaseHUDPart {
let detector = null; let detector = null;
if (canUnpin) { if (canUnpin) {
element.classList.add("unpinable"); element.classList.add("removable");
detector = new ClickDetector(element, { detector = new ClickDetector(element, {
consumeEvents: true, consumeEvents: true,
preventDefault: true, preventDefault: true,
targetOnly: true, targetOnly: false,
}); });
detector.click.add(() => this.unpinShape(key)); detector.click.add(() => this.unpinShape(key));
} else { } else {
@ -294,6 +294,7 @@ export class HUDPinnedShapes extends BaseHUDPart {
* @param {string} key * @param {string} key
*/ */
unpinShape(key) { unpinShape(key) {
console.log("unpin", key);
arrayDeleteValue(this.pinnedShapes, key); arrayDeleteValue(this.pinnedShapes, key);
this.rerenderFull(); this.rerenderFull();
} }