Skip to content

Commit

Permalink
fix: use carousel select method to set active slide (#508)
Browse files Browse the repository at this point in the history
Closes #507
  • Loading branch information
dhhyi committed Jan 26, 2021
1 parent 1f45118 commit 2302a53
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -22,6 +22,7 @@
<div class="col-12 col-lg-9 product-detail-img clearfix">
<div class="product-image-container">
<ngb-carousel
#carousel
[activeId]="activeSlide"
(slide)="setActiveSlide($event.current)"
[showNavigationArrows]="getImageViewIDsExcludePrimary(product, 'L').length > 0"
Expand Down
@@ -1,4 +1,5 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input, ViewChild } from '@angular/core';
import { NgbCarousel } from '@ng-bootstrap/ng-bootstrap';

import { Product, ProductHelper } from 'ish-core/models/product/product.model';

Expand All @@ -22,6 +23,8 @@ export class ProductImagesComponent {
*/
@Input() product: Product;

@ViewChild('carousel') carousel: NgbCarousel;

activeSlide = '0';

getImageViewIDsExcludePrimary = ProductHelper.getImageViewIDsExcludePrimary;
Expand All @@ -32,6 +35,8 @@ export class ProductImagesComponent {
*/
setActiveSlide(slideIndex: number | string) {
this.activeSlide = slideIndex?.toString();

this.carousel.select(this.activeSlide);
}

/**
Expand Down

0 comments on commit 2302a53

Please sign in to comment.