Skip to content

Commit

Permalink
Fixed #10594 - Thumbnails are not displayed correctly on Galleria if …
Browse files Browse the repository at this point in the history
…numVisible is greater than the length of value
  • Loading branch information
mertsincan committed Sep 8, 2021
1 parent c099cf5 commit e8d4c10
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/app/components/galleria/galleria.css
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@

.p-galleria-thumbnail-items-container {
overflow: hidden;
width: 100%;
}

.p-galleria-thumbnail-items {
Expand Down
12 changes: 9 additions & 3 deletions src/app/components/galleria/galleria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import { RippleModule } from 'primeng/ripple';
template: `
<div *ngIf="fullScreen;else windowed">
<div *ngIf="visible" #mask [ngClass]="{'p-galleria-mask p-component-overlay':true, 'p-galleria-visible': this.visible}" [class]="maskClass">
<p-galleriaContent [value]="value" [activeIndex]="activeIndex" (maskHide)="onMaskHide()" (activeItemChange)="onActiveItemChange($event)" [ngStyle]="containerStyle"></p-galleriaContent>
<p-galleriaContent [value]="value" [activeIndex]="activeIndex" [numVisible]="numVisible" (maskHide)="onMaskHide()" (activeItemChange)="onActiveItemChange($event)" [ngStyle]="containerStyle"></p-galleriaContent>
</div>
</div>
<ng-template #windowed>
<p-galleriaContent [value]="value" [activeIndex]="activeIndex" (activeItemChange)="onActiveItemChange($event)"></p-galleriaContent>
<p-galleriaContent [value]="value" [activeIndex]="activeIndex" [numVisible]="numVisible" (activeItemChange)="onActiveItemChange($event)"></p-galleriaContent>
</ng-template>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down Expand Up @@ -145,6 +145,10 @@ export class Galleria implements OnChanges, OnDestroy {
}
}
}

if (simpleChanges.value && simpleChanges.value.currentValue?.length < this.numVisible) {
this.numVisible = simpleChanges.value.currentValue.length;
}
}

onMaskHide() {
Expand Down Expand Up @@ -189,7 +193,7 @@ export class Galleria implements OnChanges, OnDestroy {
(startSlideShow)="startSlideShow()" (stopSlideShow)="stopSlideShow()"></p-galleriaItem>
<p-galleriaThumbnails *ngIf="galleria.showThumbnails" [containerId]="id" [value]="value" (onActiveIndexChange)="onActiveIndexChange($event)" [activeIndex]="activeIndex" [templates]="galleria.templates"
[numVisible]="galleria.numVisible" [responsiveOptions]="galleria.responsiveOptions" [circular]="galleria.circular"
[numVisible]="numVisible" [responsiveOptions]="galleria.responsiveOptions" [circular]="galleria.circular"
[isVertical]="isVertical()" [contentHeight]="galleria.verticalThumbnailViewPortHeight" [showThumbnailNavigators]="galleria.showThumbnailNavigators"
[slideShowActive]="slideShowActive" (stopSlideShow)="stopSlideShow()"></p-galleriaThumbnails>
</div>
Expand All @@ -212,6 +216,8 @@ export class GalleriaContent {

@Input() value: any[] = [];

@Input() numVisible: number;

@Output() maskHide: EventEmitter<any> = new EventEmitter();

@Output() activeItemChange: EventEmitter<any> = new EventEmitter();
Expand Down

0 comments on commit e8d4c10

Please sign in to comment.