ng-image-fullscreen-viewer icon indicating copy to clipboard operation
ng-image-fullscreen-viewer copied to clipboard

Preloader not hiding when component changeDetection is ChangeDetectionStrategy.OnPush

Open bogdandynamic opened this issue 3 years ago • 1 comments

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.

bogdandynamic avatar Feb 21 '22 14:02 bogdandynamic

Agree, change detection handler is missing here.

RobertSenkel avatar Jul 12 '22 13:07 RobertSenkel