More frontend bugfixing

This commit is contained in:
Pax1601
2023-08-04 11:05:21 +02:00
parent 66f08e8fce
commit 2f839624a8
13 changed files with 263 additions and 6 deletions

View File

@@ -205,11 +205,13 @@ function setupEvents() {
document.querySelectorAll("[inject-svg]").forEach((el: Element) => {
var img = el as HTMLImageElement;
var isLoaded = img.complete && img.naturalHeight !== 0;
var isLoaded = img.complete;
if (isLoaded)
SVGInjector(img);
else
img.onload = () => SVGInjector(img);
img.addEventListener("load", () => {
SVGInjector(img);
});
})
}

View File

@@ -1,3 +1,4 @@
import { getMouseInfoPanel } from "..";
import { Panel } from "./panel";
export class LogPanel extends Panel {
@@ -23,8 +24,21 @@ export class LogPanel extends Panel {
if (scrollEl) {
scrollEl.addEventListener("scroll", () => {
this.#scrolledDown = Math.abs(scrollEl.scrollHeight - scrollEl.scrollTop - scrollEl.clientHeight) < 1
})
});
}
window.addEventListener("resize", () => {
this.#calculateHeight();
});
const mouseInfoPanel = getMouseInfoPanel();
new ResizeObserver(() => this.#calculateHeight()).observe(mouseInfoPanel.getElement())
}
show() {
super.show();
this.#calculateHeight();
}
appendLogs(logs: {[key: string]: string}) {
@@ -68,4 +82,9 @@ export class LogPanel extends Panel {
scrollEl.scrollTop = scrollEl.scrollHeight - scrollEl.clientHeight;
}
}
#calculateHeight() {
const mouseInfoPanel = getMouseInfoPanel();
this.getElement().style.height = `${mouseInfoPanel.getElement().offsetTop - this.getElement().offsetTop - 10}px`;
}
}

View File

@@ -36,6 +36,8 @@ export class UnitsManager {
document.addEventListener('importFromFile', () => this.importFromFile());
document.addEventListener('contactsUpdated', (e: CustomEvent) => {this.#requestDetectionUpdate = true});
document.addEventListener('commandModeOptionsChanged', () => {Object.values(this.#units).forEach((unit: Unit) => unit.updateVisibility())});
document.addEventListener('selectedUnitsChangeSpeed', (e: any) => {this.selectedUnitsChangeSpeed(e.detail.type)});
document.addEventListener('selectedUnitsChangeAltitude', (e: any) => {this.selectedUnitsChangeAltitude(e.detail.type)});
}
getSelectableAircraft() {