Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preloader not hiding when component changeDetection is ChangeDetectionStrategy.OnPush #34

Open
bogdandynamic opened this issue Feb 21, 2022 · 1 comment
Assignees

Comments

@bogdandynamic
Copy link

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.

@RobertSenkel
Copy link

Agree, change detection handler is missing here.

@sanjayV sanjayV self-assigned this Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants