Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(angular): deprecate [(index)] and setIndex() #4951

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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