Fix issue with image scaling not resetting with the next image

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 4a0b1eb2ae
commit e49d1a07af

@ -2,8 +2,8 @@ import {
Component,
ElementRef,
HostListener,
Input,
OnInit,
Input, OnChanges,
OnInit, SimpleChanges,
ViewChild
} from '@angular/core';
import {CdkDragMove} from "@angular/cdk/drag-drop";
@ -14,8 +14,7 @@ import {SafeResourceUrl} from "@angular/platform-browser";
templateUrl: './image-viewer.component.html',
styleUrls: ['./image-viewer.component.scss']
})
export class ImageViewerComponent {
export class ImageViewerComponent implements OnChanges {
@Input() imageUrl!: SafeResourceUrl | string;
public imageZoom = 1;
public imagePosition = {x: 0, y: 0};
@ -23,6 +22,13 @@ export class ImageViewerComponent {
constructor() { }
public ngOnChanges(changes: SimpleChanges): void {
if (changes["imageUrl"]) {
this.resetImage();
}
}
public resetImage() {
this.imageZoom = 1;
this.imagePosition = {x: 0, y: 0};

Loading…
Cancel
Save