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

Loading…
Cancel
Save