zooming of image is modified

This commit is contained in:
richard-loafle 2020-02-10 16:08:04 +09:00
parent 17f9af17aa
commit 5512723950
2 changed files with 11 additions and 8 deletions

View File

@ -171,14 +171,7 @@
*ngIf="fileDownloadUrl" *ngIf="fileDownloadUrl"
[src]="fileDownloadUrl" [src]="fileDownloadUrl"
[style.width]="'auto'" [style.width]="'auto'"
[style.height]=" [style.height]="getImageHeight(imageContainer.clientHeight)"
naturalHeight > imageContainer.clientHeight
? ((imageContainer.clientHeight - 20) / naturalHeight) *
(zoomRatio / 100) *
naturalHeight +
'px'
: naturalHeight + 'px'
"
(load)="onLoadFileDownloadUrl(downloadImage)" (load)="onLoadFileDownloadUrl(downloadImage)"
/> />
</div> </div>

View File

@ -82,4 +82,14 @@ export class ImageViewerComponent implements OnInit {
this.changeDetectorRef.detectChanges(); 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';
}
} }