Skip to content

Commit

Permalink
Merge pull request #13840 from mehmetcetin01140/issue-13816
Browse files Browse the repository at this point in the history
Issue 13816
  • Loading branch information
cetincakiroglu authored Oct 11, 2023
2 parents b66e4f6 + f106163 commit 0c70bf3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 28 deletions.
43 changes: 21 additions & 22 deletions src/app/components/carousel/carousel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ export class Carousel implements AfterContentInit {
}

ngOnChanges(simpleChange: SimpleChanges) {
if(isPlatformBrowser(this.platformId)) {
if (isPlatformBrowser(this.platformId)) {
if (simpleChange.value) {
if (this.circular && this._value) {
this.setCloneItems();
Expand All @@ -370,42 +370,41 @@ export class Carousel implements AfterContentInit {
if (this.responsiveOptions) {
this.defaultNumVisible = this.numVisible;
}

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

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

if (simpleChange.numScroll) {
if (this.responsiveOptions) {
this.defaultNumScroll = this.numScroll;
}
}
}

}
}

ngAfterContentInit() {
this.id = UniqueComponentId();
if(isPlatformBrowser(this.platformId)) {
if (isPlatformBrowser(this.platformId)) {
this.allowAutoplay = !!this.autoplayInterval;

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

if (this.responsiveOptions) {
this.defaultNumScroll = this._numScroll;
this.defaultNumVisible = this._numVisible;
}

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

if (this.responsiveOptions) {
this.bindDocumentListeners();
}
Expand Down Expand Up @@ -441,17 +440,17 @@ export class Carousel implements AfterContentInit {
}

ngAfterContentChecked() {
if(isPlatformBrowser(this.platformId)) {
if (isPlatformBrowser(this.platformId)) {
const isCircular = this.isCircular();
let totalShiftedItems = this.totalShiftedItems;

if (this.value && this.itemsContainer && (this.prevState.numScroll !== this._numScroll || this.prevState.numVisible !== this._numVisible || this.prevState.value.length !== this.value.length)) {
if (this.autoplayInterval) {
this.stopAutoplay(false);
}

this.remainingItems = (this.value.length - this._numVisible) % this._numScroll;

let page = this._page;
if (this.totalDots() !== 0 && page >= this.totalDots()) {
page = this.totalDots() - 1;
Expand All @@ -460,39 +459,39 @@ export class Carousel implements AfterContentInit {
page: this.page
});
}

totalShiftedItems = page * this._numScroll * -1;
if (isCircular) {
totalShiftedItems -= this._numVisible;
}

if (page === this.totalDots() - 1 && this.remainingItems > 0) {
totalShiftedItems += -1 * this.remainingItems + this._numScroll;
this.isRemainingItemsAdded = true;
} else {
this.isRemainingItemsAdded = false;
}

if (totalShiftedItems !== this.totalShiftedItems) {
this.totalShiftedItems = totalShiftedItems;
}

this._oldNumScroll = this._numScroll;
this.prevState.numScroll = this._numScroll;
this.prevState.numVisible = this._numVisible;
this.prevState.value = [...(this._value as any[])];

if (this.totalDots() > 0 && this.itemsContainer.nativeElement) {
this.itemsContainer.nativeElement.style.transform = this.isVertical() ? `translate3d(0, ${totalShiftedItems * (100 / this._numVisible)}%, 0)` : `translate3d(${totalShiftedItems * (100 / this._numVisible)}%, 0, 0)`;
}

this.isCreated = true;

if (this.autoplayInterval && this.isAutoplay()) {
this.startAutoplay();
}
}

if (isCircular) {
if (this.page === 0) {
totalShiftedItems = -1 * this._numVisible;
Expand All @@ -502,7 +501,7 @@ export class Carousel implements AfterContentInit {
this.isRemainingItemsAdded = true;
}
}

if (totalShiftedItems !== this.totalShiftedItems) {
this.totalShiftedItems = totalShiftedItems;
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/galleria/galleria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class Galleria implements OnChanges, OnDestroy {

maskVisible: boolean = false;

constructor(@Inject(DOCUMENT) private document: Document, @Inject(PLATFORM_ID) public platformId: any, public element: ElementRef, public cd: ChangeDetectorRef, public config: PrimeNGConfig) {}
constructor(@Inject(DOCUMENT) private document: Document, @Inject(PLATFORM_ID) public platformId: any, public element: ElementRef, public cd: ChangeDetectorRef, public config: PrimeNGConfig) {}

ngAfterContentInit() {
this.templates?.forEach((item) => {
Expand Down Expand Up @@ -516,13 +516,13 @@ export class GalleriaContent implements DoCheck {
}

startSlideShow() {
if(isPlatformBrowser(this.galleria.platformId)) {
if (isPlatformBrowser(this.galleria.platformId)) {
this.interval = setInterval(() => {
let activeIndex = this.galleria.circular && this.value.length - 1 === this.activeIndex ? 0 : this.activeIndex + 1;
this.onActiveIndexChange(activeIndex);
this.activeIndex = activeIndex;
}, this.galleria.transitionInterval);

this.slideShowActive = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/image/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { FocusTrapModule } from 'primeng/focustrap';
template: `
<span [ngClass]="containerClass()" [class]="styleClass" [ngStyle]="style">
<img [attr.src]="src" [attr.srcset]="srcSet" [attr.sizes]="sizes" [attr.alt]="alt" [attr.width]="width" [attr.height]="height" [ngStyle]="imageStyle" [class]="imageClass" (error)="imageError($event)" />
<button type="button" class="p-image-preview-indicator" (click)="onImageClick()" #previewButton [ngStyle]="{'height': height + 'px', 'width': width + 'px'}" style="border: 'none';">
<button type="button" class="p-image-preview-indicator" (click)="onImageClick()" #previewButton [ngStyle]="{ height: height + 'px', width: width + 'px' }" style="border: 'none';">
<ng-container *ngIf="indicatorTemplate; else defaultTemplate">
<ng-container *ngTemplateOutlet="indicatorTemplate"></ng-container>
</ng-container>
Expand Down
9 changes: 7 additions & 2 deletions src/app/components/multiselect/multiselect.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@
.p-multiselect-token-icon {
cursor: pointer;
}

.p-multiselect-token-label {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 100px;
}
.p-multiselect-items-wrapper {
overflow: auto;
}
Expand Down Expand Up @@ -108,4 +113,4 @@
.p-multiselect-clearable {
position: relative;
}
}
}

0 comments on commit 0c70bf3

Please sign in to comment.