Skip to content

Commit

Permalink
fix: display first product image after switching products on product …
Browse files Browse the repository at this point in the history
…detail page (#1474)
  • Loading branch information
SGrueber authored Aug 11, 2023
1 parent 23f7585 commit 96737be
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/app/pages/product/product-images/product-images.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core';
import { Observable } from 'rxjs';
import { map, shareReplay } from 'rxjs/operators';
import { distinctUntilKeyChanged, map, shareReplay, tap } from 'rxjs/operators';
import SwiperCore, { Navigation } from 'swiper';
import { SwiperComponent } from 'swiper/angular';

import { ProductContextFacade } from 'ish-core/facades/product-context.facade';
import { ProductView } from 'ish-core/models/product-view/product-view.model';
import { ProductHelper } from 'ish-core/models/product/product.model';
import { whenTruthy } from 'ish-core/utils/operators';
import { ModalDialogComponent } from 'ish-shared/components/common/modal-dialog/modal-dialog.component';

SwiperCore.use([Navigation]);
Expand Down Expand Up @@ -36,7 +37,16 @@ export class ProductImagesComponent implements OnInit {
constructor(private context: ProductContextFacade) {}

ngOnInit() {
this.product$ = this.context.select('product');
this.product$ = this.context.select('product').pipe(
whenTruthy(),
distinctUntilKeyChanged('sku'),
tap(() => {
if (this.carousel?.swiperRef?.activeIndex) {
this.setActiveSlide(0);
}
}),
shareReplay(1)
);
this.zoomImageIds$ = this.getImageViewIDs$('ZOOM').pipe(shareReplay(1));
}

Expand Down

0 comments on commit 96737be

Please sign in to comment.