feat: manhwa scroll

This commit is contained in:
2024-07-07 23:23:40 +03:00
parent 29fb7fd04d
commit e6da8b17a7
7 changed files with 46 additions and 7 deletions

View File

@@ -22,7 +22,9 @@ export class ScaleImageComponent implements AfterViewInit, OnDestroy {
if (this.resizeSubscription) this.resizeSubscription.unsubscribe();
}
onImageLoad() {}
onImageLoad() {
this.scaleImage();
}
private setupResizeListener() {
this.resizeSubscription = fromEvent(window, "resize")
@@ -53,8 +55,13 @@ export class ScaleImageComponent implements AfterViewInit, OnDestroy {
newWidth = Math.min(newWidth, img.naturalWidth);
newHeight = Math.min(newHeight, img.naturalHeight);
img.style.width = `${newWidth}px`;
img.style.height = `${newHeight}px`;
if (img.naturalHeight / img.naturalWidth >= 5) {
img.style.width = "100%";
img.style.height = "auto";
} else {
img.style.width = `${newWidth}px`;
img.style.height = `${newHeight}px`;
}
}
}
}