Skip to content

Commit

Permalink
Fixed #9049 - Carousel does not respond to change to numVisible
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed Nov 26, 2020
1 parent 56b6e71 commit 34ba98d
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/app/components/carousel/carousel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, ElementRef, ViewChild, AfterContentInit, TemplateRef, ContentChildren, QueryList, NgModule, NgZone, EventEmitter, Output, ContentChild, ChangeDetectionStrategy, ViewEncapsulation, ChangeDetectorRef } from '@angular/core';
import { Component, Input, ElementRef, ViewChild, AfterContentInit, TemplateRef, ContentChildren, QueryList, NgModule, NgZone, EventEmitter, Output, ContentChild, ChangeDetectionStrategy, ViewEncapsulation, ChangeDetectorRef, SimpleChanges } from '@angular/core';
import { PrimeTemplate, SharedModule, Header, Footer } from 'primeng/api';
import { RippleModule } from 'primeng/ripple';
import { CommonModule } from '@angular/common';
Expand Down Expand Up @@ -111,9 +111,6 @@ export class Carousel implements AfterContentInit {
};
set value(val) {
this._value = val;
if (this.circular && this._value) {
this.setCloneItems();
}
}

@Input() circular:boolean = false;
Expand Down Expand Up @@ -196,6 +193,27 @@ export class Carousel implements AfterContentInit {
this.totalShiftedItems = this.page * this.numScroll * -1;
}

ngOnChanges(simpleChange: SimpleChanges) {
if (simpleChange.value) {
if (this.circular && this._value) {
this.setCloneItems();
}
}

if (simpleChange.numVisible && this.isCreated) {
if (this.responsiveOptions) {
this.defaultNumVisible = this.numVisible;
}

if (this.isCircular()) {
this.setCloneItems();
}

this.createStyle();
this.calculatePosition();
}
}

ngAfterContentInit() {
this.id = UniqueComponentId();
this.allowAutoplay = !!this.autoplayInterval;
Expand Down

0 comments on commit 34ba98d

Please sign in to comment.