ngu-carousel icon indicating copy to clipboard operation
ngu-carousel copied to clipboard

How to add new values to grid ngu-carousel or change values to existing?

Open maxkarpovets opened this issue 6 years ago • 6 comments

How to add new values to grid ngu-carousel or change values to existing?

  this.carouselConfig = {
      grid: { xs: 2, sm: 3, md: 4, lg: 5, all: 0 },
      ...
  }

I want to apply different values for laptops with resolution 1280x800 and 1440x900 and for bigger screens.

maxkarpovets avatar Dec 21 '18 10:12 maxkarpovets

@maxkarpovets currently it is not possible. In next version you can able to changes the size dynamically according to your needs

Thanks

sheikalthaf avatar Dec 22 '18 04:12 sheikalthaf

When the next version will be available?

maxkarpovets avatar Dec 24 '18 08:12 maxkarpovets

+1

lynx-r avatar Dec 29 '18 07:12 lynx-r

+1 Hello there, This is not possible to do yet, right?

arielin82 avatar Jul 19 '19 14:07 arielin82

+1

SerhiiTsybulskyi avatar Aug 01 '19 20:08 SerhiiTsybulskyi

I manage to "refresh" it with this workaround. using an ngFor that resets the dom element, every time the queryPlans list (its an @Input) changes, I update the reset array. and this makes the ngFor run again. <ngu-carousel #mpPlanCarousel *ngFor="let r of reset" [inputs]="carouselConfig" [dataSource]="sortedPlanCategories">

  ngOnChanges(changes: SimpleChanges): void {
    // Workaround to create a new Carousel, because ngu-carousel doesn't support to change the columns dynamically.
    if (changes.queryPlans && !changes.queryPlans.firstChange) {
      this.setCarouselConfig();
      this.reset[0] = {};
      this.initSortedPlanCategories();
    }
  }

  ngOnInit(): void  {

    this.reset[0] = {};  // change flag to force new carousel creation.

    this.setCarouselConfig();
  }

  setCarouselConfig(): void {
    // Sets carousel config with the right columns to be displayed according to the amount of plans
    // TODO: get the length of columns from the length of categories in the Ecosystem for Default Campaign
    // and other campaigns
    let columns = 3;  // Default length of columns from the length of categories
    if (this.clearanceSale) {
      columns = 2;
    } else if (this.queryPlans && this.queryPlans.length > 0) {
      columns = this.queryPlans.length;
    }
    this.carouselConfig = {
      grid: { xs: 1, sm: 1, md: columns, lg: columns, all: 0 },
      slide: 1,
      speed: 400,
      point: {
        visible: true
      },
      load: 2,
      loop: true,
      touch: true
    };
  }

arielin82 avatar Aug 02 '19 14:08 arielin82