ivylaboratory / angular-carousel

A simple solution for horizontal scrolling images with lazy loading
Apache License 2.0
150 stars 92 forks source link

Reload method for carrousel #52

Open monxas opened 3 years ago

monxas commented 3 years ago

Right now we don't have an easy way to reload the carrousel and it would be an easy workaorund for many issues people might have.

For example, if you have a list of items and the list is dynamic it'll break.

An way to fix this in a generic way that I didn't fin how to do is to add a reload method to reload the carrousel whenever the new item is added.

dren0r123 commented 3 years ago

I find a workaround like import { CarouselComponent } from 'angular-responsive-carousel'; @ViewChild('sliderCarousel') sliderCarousel: CarouselComponent;

and call after adding new element to image array this.sliderCarousel.onWindowResize({})

Muhabdhadi commented 3 years ago

I found a solution similar to @dren0r123 solution .. by add this.sliderCarousel.detectDomChanges(); intead of
this.sliderCarousel.onWindowResize({}) .

I find a workaround like import { CarouselComponent } from 'angular-responsive-carousel'; @ViewChild('sliderCarousel') sliderCarousel: CarouselComponent;

and call after adding new element to image array this.sliderCarousel.detectDomChanges();

drozhzhin-n-e commented 3 years ago

The latest version has a resize() method, try using it. It will update the data inside the carousel.

https://github.com/ivylaboratory/angular-carousel/blob/master/projects/angular-responsive-carousel/src/lib/carousel.component.ts#L295