Skip to content

Commit

Permalink
fix(angular): deprecate [(index)] and setIndex() (#4951)
Browse files Browse the repository at this point in the history
  • Loading branch information
vltansky authored Sep 13, 2021
1 parent 6c0a3e5 commit 7ee3d58
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 0 additions & 6 deletions playground/angular/src/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ <h3>Custom pagination</h3>
[breakpoints]="breakpoints"
[scrollbar]="scrollbar"
[loop]="true"
[(index)]="indexNumber"
[pagination]="{ el: '.swiper-pagination.pagination-test' }"
>
<ng-container *ngIf="show">
Expand All @@ -134,11 +133,6 @@ <h3>Custom pagination</h3>
<button (click)="toggleScrollbar()">Toggle scrollbar</button>
<button (click)="breakpointChange()">Breakpoint change</button>
<button (click)="show = !show">Toggle show</button>
<button (click)="indexNumber = 0">0</button>
<button (click)="indexNumber = 3">3</button>
<button (click)="indexNumber = 5">5</button>
<button (click)="indexNumber = 6">6</button>
{{ indexNumber }}

<swiper [config]="exampleConfig">
<ng-template swiperSlide>Best slide ever 2</ng-template>
Expand Down
1 change: 0 additions & 1 deletion playground/angular/src/app/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export class HomePage {
this.controlledSwiper = swiper;
}

indexNumber = 1;
exampleConfig = { slidesPerView: 3 };
slidesPerView: number = 4;
pagination: any = false;
Expand Down
6 changes: 5 additions & 1 deletion src/angular/src/swiper.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export class SwiperComponent implements OnInit {

@Input()
set index(index: number) {
console.warn('`[(index)]` prop is deprecated and will be removed in upcoming versions');
this.setIndex(index);
}
@Input()
Expand Down Expand Up @@ -821,8 +822,11 @@ export class SwiperComponent implements OnInit {
} else {
this.swiperRef.params[_key] = value;
}
this.setIndex(2);
}

/**
* @deprecated will be removed in upcoming versions
*/
setIndex(index: number, speed?: number, silent?: boolean): void {
if (!this.isSwiperActive) {
this.initialSlide = index;
Expand Down

0 comments on commit 7ee3d58

Please sign in to comment.