Ionic Slide Box
ion-slide-box
The slide box is a component that contains a multi-page container, where each page can be switched by sliding or dragging:
Here is the effect diagram:
Usage
<ion-slide-box on-slide-changed="slideHasChanged($index)">
<ion-slide>
<div class="box blue"><h1>BLUE</h1></div>
</ion-slide>
<ion-slide>
<div class="box yellow"><h1>YELLOW</h1></div>
</ion-slide>
<ion-slide>
<div class="box pink"><h1>PINK</h1></div>
</ion-slide>
</ion-slide-box>
API
Attribute | Type | Details |
---|---|---|
delegate-handle (optional) | string | The handle used by $ionicSlideBoxDelegate to identify this slide box. |
does-continue (optional) | boolean | Whether the slide box should loop continuously. |
auto-play (optional) | boolean | Sets whether the slide box should play automatically. If does-continue is true, it defaults to true as well. |
slide-interval (optional) | number | How many milliseconds to wait before starting the slide (if continue is true). Defaults to 4000. |
show-pager (optional) | boolean | Whether to show the pager of the slide box. |
pager-click (optional) | expression | Expression to be triggered when a page is clicked (if show-pager is true). Passes an 'index' variable. |
on-slide-changed (optional) | expression | Expression to be triggered when the slide changes. Passes an 'index' variable. |
active-slide (optional) | expression | Bind the model to the current slide of the slide box. |
Example
HTML Code
<ion-slide-box active-slide="myActiveSlide">
<ion-slide>
<div class="box blue"><h1>BLUE</h1></div>
</ion-slide>
<ion-slide>
<div class="box yellow"><h1>YELLOW</h1></div>
</ion-slide>
<ion-slide>
<div class="box pink"><h1>PINK</h1></div>
</ion-slide>
</ion-slide-box>
CSS Code
.slider {
height: 100%;
}
.slider-slide {
color: #000;
background-color: #fff; text-align: center;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-weight: 300; }
.blue {
background-color: blue;
}
.yellow {
background-color: yellow;
}
.pink {
background-color: pink;
}
.box{
height:100%;
}
.box h1{
position:relative; top:50%; transform:translateY(-50%);
}
JavaScript Code
angular.module('ionicApp', ['ionic'])
.controller('SlideController', function($scope) {
$scope.myActiveSlide = 1;
})