mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-10 14:11:42 +00:00
[ACS-9763] Ensure that canvas is updated after image is loaded and spinner is hidden
This commit is contained in:
@@ -101,6 +101,14 @@ describe('Test Img viewer component ', () => {
|
|||||||
fixture.componentInstance.ngAfterViewInit();
|
fixture.componentInstance.ngAfterViewInit();
|
||||||
expect(component.cropper).toBeDefined();
|
expect(component.cropper).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should update canvas container after image is loaded', fakeAsync(() => {
|
||||||
|
spyOn(component, 'updateCanvasContainer');
|
||||||
|
component.imageLoaded.emit();
|
||||||
|
tick(200);
|
||||||
|
|
||||||
|
expect(component.updateCanvasContainer).toHaveBeenCalled();
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Blob', () => {
|
describe('Blob', () => {
|
||||||
|
@@ -19,9 +19,11 @@ import { NgIf } from '@angular/common';
|
|||||||
import {
|
import {
|
||||||
AfterViewInit,
|
AfterViewInit,
|
||||||
Component,
|
Component,
|
||||||
|
DestroyRef,
|
||||||
ElementRef,
|
ElementRef,
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
HostListener,
|
HostListener,
|
||||||
|
inject,
|
||||||
Input,
|
Input,
|
||||||
OnChanges,
|
OnChanges,
|
||||||
OnDestroy,
|
OnDestroy,
|
||||||
@@ -37,6 +39,7 @@ import Cropper from 'cropperjs';
|
|||||||
import { AppConfigService } from '../../../app-config';
|
import { AppConfigService } from '../../../app-config';
|
||||||
import { UrlService } from '../../../common';
|
import { UrlService } from '../../../common';
|
||||||
import { ToolbarComponent } from '../../../toolbar';
|
import { ToolbarComponent } from '../../../toolbar';
|
||||||
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-img-viewer',
|
selector: 'adf-img-viewer',
|
||||||
@@ -125,6 +128,8 @@ export class ImgViewerComponent implements AfterViewInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
|
|
||||||
scale: number = 1.0;
|
scale: number = 1.0;
|
||||||
cropper: Cropper;
|
cropper: Cropper;
|
||||||
isEditing: boolean = false;
|
isEditing: boolean = false;
|
||||||
@@ -156,6 +161,13 @@ export class ImgViewerComponent implements AfterViewInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
|
this.imageLoaded.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
||||||
|
// Ensure the canvas container is updated after the image is loaded and spinner is hidden
|
||||||
|
setTimeout(() => {
|
||||||
|
this.updateCanvasContainer();
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
|
||||||
this.cropper = new Cropper(this.imageElement.nativeElement, {
|
this.cropper = new Cropper(this.imageElement.nativeElement, {
|
||||||
autoCrop: false,
|
autoCrop: false,
|
||||||
checkOrientation: false,
|
checkOrientation: false,
|
||||||
@@ -165,10 +177,7 @@ export class ImgViewerComponent implements AfterViewInit, OnChanges, OnDestroy {
|
|||||||
zoomOnWheel: true,
|
zoomOnWheel: true,
|
||||||
toggleDragModeOnDblclick: false,
|
toggleDragModeOnDblclick: false,
|
||||||
viewMode: 1,
|
viewMode: 1,
|
||||||
checkCrossOrigin: false,
|
checkCrossOrigin: false
|
||||||
ready: () => {
|
|
||||||
this.updateCanvasContainer();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user