Closed ryanwoodcox closed 7 years ago
closes #14
Hi, dynamic input data breaks carousel, so I reverted changes. Please let me know if I wrong, but after adding OnChanges, carousel not work properly (images sliding on hover, delay different for images)
Is that not something you can fix by reworking the styles? I've done a lot of reworking of the styles to meet my needs, so I am not experiencing this issue.
Moving carousel initialization from OnInit to OnChanges will not work, we should also reset timers and other data related to current carousel instance.
Here is solution works for me to change configs in run-time:
HTML: add *ngIf="enabled" to carousel component. Let enabled variable be true by default.
<carousel *ngIf="enabled" [sources]="imageSources" [config]="config"></carousel>
TS: add function that reset carousel with new config and/or images.
public enabled = true;
public changeConfig(): void {
this.enabled = false;
setTimeout(() => {
this.imageSources = [
// new images
]
this.config = {
// new config
};
this.enabled = true;
});
}
Implemented OnChanges to support re-initliazing the component when input properties change. Reference to issue: https://github.com/bonjurmrfirst/angular4-carousel/issues/14