ng-image-fullscreen-viewer
ng-image-fullscreen-viewer copied to clipboard
Preloader not hiding when component changeDetection is ChangeDetectionStrategy.OnPush
Hi. I've encountered a little bug when using ng-image-fullscreen-viewer into a component with changeDetection set to ChangeDetectionStrategy.OnPush. When showing the viewer for the first time, the preloader never hides after 500ms because of change detection. The temporary fix for this was to execute the following code on the showViewer function:
public showLightbox(index: number): void {
this.selectedLightboxImageIndex = index;
this.lightboxVisible = true;
setTimeout(() => {
// Fix for preloader and ChangeDetectionStrategy.OnPush
this._changeDetector.detectChanges();
}, 750);
}
If you could also apply a class with display:none to the preloader, or incorporate ChangeDetectorRef and execute detectChanges or markForCheck would be great.
Agree, change detection handler is missing here.