Use jQuery width for sprites temporarily

This commit is contained in:
aNNiMON 2024-03-16 23:29:05 +02:00
parent 6c1086d542
commit 4ca0629bf3

View File

@ -191,8 +191,7 @@ export class MainView implements ViewModel {
if (key in this.spriteInContainer) { if (key in this.spriteInContainer) {
img = this.spriteInContainer[key]; img = this.spriteInContainer[key];
} else { } else {
// TODO const height = Math.ceil(this.elBackground.getBoundingClientRect().height);
const height = this.elBackground.getBoundingClientRect().height;
img = document.createElement('img'); img = document.createElement('img');
img.className = 'sprite'; img.className = 'sprite';
img.style.height = height + 'px'; img.style.height = height + 'px';
@ -247,8 +246,8 @@ export class MainView implements ViewModel {
} }
private setSpritePosition(img: HTMLImageElement, position: string): void { private setSpritePosition(img: HTMLImageElement, position: string): void {
const width = this.elBackground.getBoundingClientRect().width; const width = Math.ceil(this.elBackground.getBoundingClientRect().width);
const imgWidth = img.offsetWidth; const imgWidth = $(img).width(); // TODO
if (TextUtils.isEmpty(position) || position === "center") { if (TextUtils.isEmpty(position) || position === "center") {
img.style.right = "auto"; img.style.right = "auto";
img.style.left = Math.floor(width / 2 - imgWidth / 2) + "px"; img.style.left = Math.floor(width / 2 - imgWidth / 2) + "px";