sebelga / ionic-advanced-carousel

Carousel directive for Ionic Frameworks that allows any custom template as an item.
http://sebelga.github.io/ionic-advanced-carousel/
GNU General Public License v2.0
42 stars 18 forks source link

ionic Advanced Carousel

Carousel directive for Ionic Frameworks that let you use any custom template as an item.

[WARNING]: this library is not maintained anymore.

You can still use it if it fits your needs but I won't be able to give support.

Demo

To be able to see the demo correctly you need to see the page in device mode / mobile emulation. Instructions for Chrome here and for Firefox here

To test the demo locally

cd demo
bower install
ionic serve

Usage

Directive parameters

Carousel options (with default value)

var options = {
    template      : null, // templateUrl in case you don't need to pass a directive but just a html view
    align         : 'left', // alignement of the carousel
    centerOnSelect: true, // center carousel when an item is selected
    trackBy       : '$index',  // indicate a track by property
    selectFirst   : true, // select first carousel item at start
    selectAtStart : {    // optional => Select at start the item with the property (string) with value passed
        property: null,
        value   : null
    },
    pullRefresh   : {  // optional => set active to true for pull refresh passing a callBack
        active  : false,
        callBack: angular.noop
    }
};

Events

After you make a change to the array provider, broadcast the 'a-carousel.arrayupdated' event passing the carousel id to update the carousel.

 $scope.$broadcast('a-carousel.arrayupdated', 'my-carousel-id');

At the end of a pull refresh callback

$scope.$broadcast('a-carousel.pullrefresh.done');

To desactive a carousel item.

var params {
    idContains:'carousel-', // this will unselect all carousel with an id that contains "carousel-" (ex: carousel-1, carousel-2, carousel-3)
    except:'carousel-1' // but will not touch at carousel-1
}
$scope.$broadcast('a-carousel.desactivateItem', params);