Increase max zoom level

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/15/head
trivernis 3 years ago
parent af5c5a59dc
commit 6c483b326c
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,9 +1,9 @@
<div (mouseenter)="this.mouseInImageView = true" (mouseleave)="this.mouseInImageView = false" <div (mouseenter)="this.mouseInImageView = true" (mouseleave)="this.mouseInImageView = false"
class="image-full-view-inner"> class="image-full-view-inner">
<div class="zoom-slider"> <div class="zoom-slider">
<mat-slider (input)="this.imageZoom=$event.value ?? 1" [value]="this.imageZoom" max="4" <mat-slider (input)="this.imageZoom=$event.value ?? 1" [max]="this.maxZoom" [min]="this.minZoom"
min="0.5" step="0.1" vertical></mat-slider> [value]="this.imageZoom" step="0.1" vertical></mat-slider>
<button (click)="this.resetImage()" mat-icon-button> <button (click)="this.resetImage()" class="reset-image-zoom-button" mat-icon-button>
<ng-icon name="mat-refresh"></ng-icon> <ng-icon name="mat-refresh"></ng-icon>
</button> </button>
</div> </div>

@ -23,15 +23,14 @@
opacity: 0.5; opacity: 0.5;
padding: 1em 0.5em; padding: 1em 0.5em;
transition-duration: 0.2s; transition-duration: 0.2s;
}
.zoom-slider:hover { &:hover {
opacity: 1; opacity: 1;
background-color: rgba(0, 0, 0, 0.3); background-color: rgba(0, 0, 0, 0.3);
border-radius: 1em; border-radius: 1em;
}
} }
.image-full-view-inner { .image-full-view-inner {
height: 100%; height: 100%;
width: 100%; width: 100%;
@ -42,3 +41,8 @@
.hidden { .hidden {
display: none; display: none;
} }
.reset-image-zoom-button {
height: 3em;
margin: auto
}

@ -9,6 +9,9 @@ import {SafeResourceUrl} from "@angular/platform-browser";
}) })
export class ImageViewerComponent implements OnChanges { export class ImageViewerComponent implements OnChanges {
@Input() imageUrl!: SafeResourceUrl | string; @Input() imageUrl!: SafeResourceUrl | string;
@Input() maxZoom = 10;
@Input() minZoom = 0.5;
public imageZoom = 1; public imageZoom = 1;
public imagePosition = { x: 0, y: 0 }; public imagePosition = { x: 0, y: 0 };
public mouseInImageView = false; public mouseInImageView = false;
@ -52,13 +55,13 @@ export class ImageViewerComponent implements OnChanges {
if (delta > 0) { if (delta > 0) {
this.imageZoom += 0.2; this.imageZoom += 0.2;
if (this.imageZoom > 4) { if (this.imageZoom > this.maxZoom) {
this.imageZoom = 4; this.imageZoom = this.maxZoom;
} }
} else if (delta < 0) { } else if (delta < 0) {
this.imageZoom -= 0.2; this.imageZoom -= 0.2;
if (this.imageZoom < 0.5) { if (this.imageZoom < this.minZoom) {
this.imageZoom = 0.5; this.imageZoom = this.minZoom;
} }
} }
} }

Loading…
Cancel
Save