From cc2087a466f21d9804436291dc0fcc2b64a410f4 Mon Sep 17 00:00:00 2001 From: richard-loafle <44828666+richard-loafle@users.noreply.github.com> Date: Wed, 29 Jan 2020 17:17:04 +0900 Subject: [PATCH] image viewer is modified --- .../file-viewer/image-viewer.component.html | 12 +++++- .../file-viewer/image-viewer.component.scss | 8 +++- .../file-viewer/image-viewer.component.ts | 42 ++++++++++++++++++- 3 files changed, 57 insertions(+), 5 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 c9cc1cff..a80ee104 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 @@ -26,6 +26,7 @@ matTooltip="{{ 'common.messages.zoomReset' | translate }}" matTooltipPosition="below" aria-label="" + (click)="onClickZoomReset()" > @@ -51,6 +52,7 @@ matTooltip="{{ 'common.messages.zoomOut' | translate }}" matTooltipPosition="below" aria-label="" + (click)="onClickZoomOut()" > - + diff --git a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.scss b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.scss index 95bf77b0..64080f7f 100644 --- a/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.scss +++ b/projects/ucap-webmessenger-ui/src/lib/components/file-viewer/image-viewer.component.scss @@ -39,11 +39,15 @@ height: calc(100% - 60px); .ucap-image-viewer-image-wrapper { + position: relative; + width: 100%; height: 100%; - padding: 20px; background-color: rgba(0, 0, 0, 0.7); + overflow: auto; + img { - height: inherit; + position: absolute; + max-width: none !important; } } } 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 7a0a24d8..2ab1e41c 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 @@ -1,4 +1,12 @@ -import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { + Component, + OnInit, + Input, + Output, + EventEmitter, + ElementRef, + ViewChild +} from '@angular/core'; import { ucapAnimations } from '../../animations'; import { FileEventJson } from '@ucap-webmessenger/protocol-event'; import { FileDownloadItem } from '@ucap-webmessenger/api'; @@ -24,9 +32,17 @@ export class ImageViewerComponent implements OnInit { fileDownloadItem: FileDownloadItem; + naturalWidth = 0; + naturalHeight = 0; + + zoomRatio = 100; + constructor() {} - ngOnInit() {} + ngOnInit() { + this.naturalWidth = this.fileInfo.imageWidth; + this.naturalHeight = this.fileInfo.imageHeight; + } onClickDownload(): void { this.fileDownloadItem = new FileDownloadItem(); @@ -36,4 +52,26 @@ export class ImageViewerComponent implements OnInit { onClickClose(): void { this.closed.emit(); } + + onLoadFileDownloadUrl(img: HTMLImageElement) { + console.log('onLoadFileDownloadUrl', img.naturalWidth, img.naturalHeight); + this.naturalWidth = img.naturalWidth; + this.naturalHeight = img.naturalHeight; + } + + onClickZoomOut() { + if (60 >= this.zoomRatio) { + return; + } + this.zoomRatio -= 10; + } + onClickZoomIn() { + if (180 <= this.zoomRatio) { + return; + } + this.zoomRatio += 10; + } + onClickZoomReset() { + this.zoomRatio = 100; + } }