Skip to content

Commit

Permalink
fix(gallery): exclude browser APIs from SSR in thumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
daelmaak committed Nov 11, 2024
1 parent 47e3e19 commit e69eb50
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion libs/gallery/src/lib/components/thumbs/thumbs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export class ThumbsComponent implements OnChanges, OnDestroy {
};

private observeArrows() {
if (this.thumbsEmpty) return;
if (this.thumbsEmpty || !isBrowser) return;

if (!this.arrowObserver) {
this.arrowObserver = new IntersectionObserver(this.onArrowsObserved, {
Expand Down
20 changes: 11 additions & 9 deletions libs/gallery/src/lib/components/viewer/viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,20 @@ export class ViewerComponent implements OnChanges, OnInit, AfterViewInit {
}

ngOnInit() {
if (isBrowser) {
this.handleResizes();
if (!isBrowser) {
return;
}

if (this.mouseGestures) {
this.handleMouseSlides();
}
this.handleResizes();

if (this.touchGestures) {
this.handleTouchSlides();
}
this._destroyRef.onDestroy(() => this.fringeObserver?.disconnect());
if (this.mouseGestures) {
this.handleMouseSlides();
}

if (this.touchGestures) {
this.handleTouchSlides();
}
this._destroyRef.onDestroy(() => this.fringeObserver?.disconnect());
}

ngAfterViewInit() {
Expand Down

0 comments on commit e69eb50

Please sign in to comment.