Skip to content

Commit

Permalink
fix(slides): convert loop attribute to a boolean and index to a numbe…
Browse files Browse the repository at this point in the history
…r before passing to slides

Not sure I like the index attribute though.

Fixes #5189
  • Loading branch information
brandyscarney committed Jan 25, 2016
1 parent 0b0500d commit de9a986
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
5 changes: 5 additions & 0 deletions ionic/components/slides/slides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,15 @@ export class Slides extends Ion {
}

this.showPager = isTrueProperty(this.pager);
this.loop = isTrueProperty(this.loop);

if (typeof(this.index) != 'undefined') {
this.index = parseInt(this.index);
}

var options = defaults({
loop: this.loop,
initialSlide: this.index,
pagination: '.swiper-pagination',
paginationClickable: true,
lazyLoading: true,
Expand Down
2 changes: 2 additions & 0 deletions ionic/components/slides/test/loop/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class MyApp {
class: "blue"
}
];

this.startingIndex = 2;
}

onSlideChanged(slider) {
Expand Down
26 changes: 21 additions & 5 deletions ionic/components/slides/test/loop/main.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
<ion-slides loop="true" id="loopSlider" (change)="onSlideChanged($event)" pager>
<ion-slide *ngFor="#slide of slides" [ngClass]="slide.class">
{{ slide.name }}
</ion-slide>
</ion-slides>
<div class="slides-div">
<ion-slides [index]="startingIndex" loop="true" id="loopSlider" (change)="onSlideChanged($event)" pager>
<ion-slide *ngFor="#slide of slides" [ngClass]="slide.class">
Loop {{ slide.name }}
</ion-slide>
</ion-slides>
</div>


<div class="slides-div">
<ion-slides loop="false" id="loopSlider" (change)="onSlideChanged($event)" pager>
<ion-slide *ngFor="#slide of slides" [ngClass]="slide.class">
Don't Loop {{ slide.name }}
</ion-slide>
</ion-slides>
</div>

<style>
.slides-div {
height: 50%;
border-bottom: 1px solid #ccc;
}

.yellow {
background-color: #fbeb14;
}
Expand Down

0 comments on commit de9a986

Please sign in to comment.