Skip to content

Commit

Permalink
feat(slides): expose more options
Browse files Browse the repository at this point in the history
Closes #9988
Exposes slidesPerView and spaceBetween. Also documents how to change
unexposed options
  • Loading branch information
mhartington committed Jan 12, 2017
1 parent 7906e90 commit 351ea7b
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 8 deletions.
52 changes: 44 additions & 8 deletions src/components/slides/slides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,24 @@ import { ViewController } from '../../navigation/view-controller';
* }
* ```
*
* @advanced
* Slides can be customized quite a bit to create very unique slides.
* But exposing all the of the option underneath can make slides overwhelming.
* So Ionic only exposes the most common properties. If there is a property that
* you would like to customize though, you can change it's value like so.
*
* ```ts
* export class MySlides {
* @ViewChild(Slides) slider: Slides;
* ngAfterViewInit() {
* this.slider.freeMode = true;
* }
* }
*
* ```
*
* To see all the options, look at the [source for slides](https://github.com/driftyco/ionic/blob/master/src/components/slides/slides.ts#L144)
*
* @demo /docs/v2/demos/src/slides/
* @see {@link /docs/v2/components#slides Slides Component Docs}
*
Expand Down Expand Up @@ -291,14 +309,25 @@ export class Slides extends Ion {
roundLengths = false;

// Slides grid
/**
* @private
*/
spaceBetween = 0;
/**
* @private
*/
slidesPerView: number|string = 1;

@Input()
get spaceBetween() {
return this._spaceBetween;
}
set spaceBetween(val: any) {
this._spaceBetween = parseInt(val, 10);
}
private _spaceBetween = 0;

@Input()
get slidesPerView() {
return this._slidesPerView;
}
set slidesPerView(val: any) {
this._slidesPerView = parseInt(val, 10);
}
private _slidesPerView = 1;

/**
* @private
*/
Expand Down Expand Up @@ -470,11 +499,15 @@ export class Slides extends Ion {
paginationHide = false;

// Resistance
/** @private */
resistance = true;
/** @private */
resistanceRatio = 0.85;

// Progress
/** @private */
watchSlidesProgress = false;
/** @private */
watchSlidesVisibility = false;

// Clicks
Expand Down Expand Up @@ -512,6 +545,7 @@ export class Slides extends Ion {
noSwiping = true;

// Callbacks
/** @private */
runCallbacksOnInit = true;

// Keyboard
Expand Down Expand Up @@ -810,7 +844,9 @@ export class Slides extends Ion {
/** @internal */
_zoom: SlideZoom;

/** @private */
nextButton: HTMLElement;
/** @private */
prevButton: HTMLElement;


Expand Down
46 changes: 46 additions & 0 deletions src/components/slides/test/options/app-module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Component, ViewChild, NgModule } from '@angular/core';
import { IonicApp, IonicModule, Slides } from '../../../..';


@Component({
templateUrl: 'main.html'
})
export class E2EPage {
@ViewChild(Slides) slider: Slides;

onSlideWillChange(s: Slides) {
console.log(`onSlideWillChange: ${s}`);
}

onSlideDidChange(s: Slides) {
console.log(`onSlideDidChange: ${s}`);
}

onSlideDrag(s: Slides) {
console.log(`onSlideDrag: ${s}`);
}

}

@Component({
template: '<ion-nav [root]="root"></ion-nav>'
})
export class E2EApp {
root = E2EPage;
}

@NgModule({
declarations: [
E2EApp,
E2EPage
],
imports: [
IonicModule.forRoot(E2EApp)
],
bootstrap: [IonicApp],
entryComponents: [
E2EApp,
E2EPage
]
})
export class AppModule {}
36 changes: 36 additions & 0 deletions src/components/slides/test/options/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

<ion-slides style="background: black"
(ionSlideWillChange)="onSlideWillChange($event)"
(ionSlideDidChange)="onSlideDidChange($event)"
(ionSlideDrag)="onSlideDrag($event)"
pager="true"
effect="slide"
paginationType="progress"
slidesPerView="2"
spaceBetween="40">

<ion-slide style="background: red; color: white;">
<h1>Slide 1</h1>
</ion-slide>

<ion-slide style="background: white; color: blue;">
<h1>Slide 2</h1>
</ion-slide>

<ion-slide style="background: blue; color: white;">
<h1>Slide 3</h1>
</ion-slide>

<ion-slide style="background: purple; color: white;">
<h1>Slide 4</h1>
</ion-slide>

<ion-slide style="background: aqua; color: black;">
<h1>Slide 5</h1>
</ion-slide>

<ion-slide style="background: goldenrod; color: white;">
<h1>Slide 6</h1>
</ion-slide>

</ion-slides>

0 comments on commit 351ea7b

Please sign in to comment.