From 5512723950d61e01d779930b5b60395b458cf168 Mon Sep 17 00:00:00 2001 From: richard-loafle <44828666+richard-loafle@users.noreply.github.com> Date: Mon, 10 Feb 2020 16:08:04 +0900 Subject: [PATCH] zooming of image is modified --- .../components/file-viewer/image-viewer.component.html | 9 +-------- .../components/file-viewer/image-viewer.component.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.html b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.html index b79d0e73..103c7341 100644 --- a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.html +++ b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.html @@ -171,14 +171,7 @@ *ngIf="fileDownloadUrl" [src]="fileDownloadUrl" [style.width]="'auto'" - [style.height]=" - naturalHeight > imageContainer.clientHeight - ? ((imageContainer.clientHeight - 20) / naturalHeight) * - (zoomRatio / 100) * - naturalHeight + - 'px' - : naturalHeight + 'px' - " + [style.height]="getImageHeight(imageContainer.clientHeight)" (load)="onLoadFileDownloadUrl(downloadImage)" /> diff --git a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.ts b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.ts index be3ab5ce..d07e25cc 100644 --- a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.ts +++ b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.ts @@ -82,4 +82,14 @@ export class ImageViewerComponent implements OnInit { this.changeDetectorRef.detectChanges(); } + + getImageHeight(containerHeight: number): string { + const realContainerHeight = containerHeight - 20; + const oriHeight = + this.naturalHeight > realContainerHeight + ? realContainerHeight + : this.naturalHeight; + + return oriHeight * (this.zoomRatio / 100) + 'px'; + } }