fix space thingy
This commit is contained in:
parent
497dc9d57e
commit
d7abdf752c
|
|
@ -25,6 +25,8 @@ export class FolkSpaceProjector extends FolkBaseSet {
|
||||||
override firstUpdated(changedProperties: PropertyValues<this>): void {
|
override firstUpdated(changedProperties: PropertyValues<this>): void {
|
||||||
super.firstUpdated(changedProperties);
|
super.firstUpdated(changedProperties);
|
||||||
|
|
||||||
|
this.#spreadsheet.style.setProperty('--cell-width', '50px');
|
||||||
|
|
||||||
this.#shape.appendChild(this.#spreadsheet);
|
this.#shape.appendChild(this.#spreadsheet);
|
||||||
|
|
||||||
this.renderRoot.append(this.#shape);
|
this.renderRoot.append(this.#shape);
|
||||||
|
|
@ -40,39 +42,43 @@ export class FolkSpaceProjector extends FolkBaseSet {
|
||||||
this.#spreadsheet.removeEventListener('propagate', this.#onPropagate);
|
this.#spreadsheet.removeEventListener('propagate', this.#onPropagate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#lock = false;
|
||||||
|
|
||||||
#onPropagate = (event: Event) => {
|
#onPropagate = (event: Event) => {
|
||||||
|
if (this.#lock) return;
|
||||||
|
|
||||||
const cell = event.target as FolkSpreadSheetCell;
|
const cell = event.target as FolkSpreadSheetCell;
|
||||||
|
|
||||||
const shape = this.sourceElements
|
const shape = this.sourceElements
|
||||||
.values()
|
.values()
|
||||||
.drop(cell.row)
|
.drop(cell.row - 1)
|
||||||
.find(() => true);
|
.find(() => true);
|
||||||
|
|
||||||
if (!(shape instanceof FolkShape)) return;
|
if (!(shape instanceof FolkShape)) return;
|
||||||
|
|
||||||
// infinite event loop
|
// beware of infinite event loop
|
||||||
// switch (cell.column) {
|
switch (cell.column) {
|
||||||
// case 'A': {
|
case 'A': {
|
||||||
// shape.x = cell.value;
|
shape.x = cell.value;
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// case 'B': {
|
case 'B': {
|
||||||
// shape.y = cell.value;
|
shape.y = cell.value;
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// case 'C': {
|
case 'C': {
|
||||||
// shape.width = cell.value;
|
shape.width = cell.value;
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// case 'D': {
|
case 'D': {
|
||||||
// shape.height = cell.value;
|
shape.height = cell.value;
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// case 'E': {
|
case 'E': {
|
||||||
// shape.rotation = cell.value;
|
shape.rotation = (cell.value * Math.PI) / 180;
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
override update(changedProperties: PropertyValues<this>): void {
|
override update(changedProperties: PropertyValues<this>): void {
|
||||||
|
|
@ -85,6 +91,7 @@ export class FolkSpaceProjector extends FolkBaseSet {
|
||||||
|
|
||||||
if (this.sourcesMap.size !== this.sourceElements.size) return;
|
if (this.sourcesMap.size !== this.sourceElements.size) return;
|
||||||
|
|
||||||
|
this.#lock = true;
|
||||||
const rects = this.sourceRects;
|
const rects = this.sourceRects;
|
||||||
for (let i = 0; i < rects.length; i += 1) {
|
for (let i = 0; i < rects.length; i += 1) {
|
||||||
const row = i + 1;
|
const row = i + 1;
|
||||||
|
|
@ -103,5 +110,8 @@ export class FolkSpaceProjector extends FolkBaseSet {
|
||||||
this.#spreadsheet.getCell('D', row)!.expression = Math.round(rect.height);
|
this.#spreadsheet.getCell('D', row)!.expression = Math.round(rect.height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Promise.resolve().then(() => {
|
||||||
|
this.#lock = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue