angular-swiper

by ksachdeva

ksachdeva / angular-swiper

Angular directive for nolimits4web/Swiper

198 Stars 100 Forks Last release: over 4 years ago (v0.4.0) Apache License 2.0 61 Commits 3 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

angular-swiper

Directive that wraps nolimits4web/swiper library for AngularJS. License: Apache

1 Installation

bower install angular-swiper

2 Development

npm install -g gulp
npm install
bower install

3 Usage

3.1 Requirements

Add

s to your 
html
files for angular and angular-swiper:
    

<script src="../bower_components/swiper/dist/js/swiper.js"></script>
<script src="../bower_components/angular/angular.js"></script>
<script src="../dist/angular-swiper.js"></script>

And add

ksSwiper
as a dependency for your app:
angular.module('myApp', ['ksSwiper', ...]);

3.2 Sample Markup

Example:

html

    
        
    

3.3 Directive default values

If no attributes are given, an object with the following values will be used to initiate the swiper. It is possible to use the directive without specifying attributes.

// directive defaults
var params = {
    slidesPerView: $scope.slidesPerView || 1,
    slidesPerColumn: $scope.slidesPerColumn || 1,
    spaceBetween: $scope.spaceBetween || 0,
    direction: $scope.direction || 'horizontal',
    loop: $scope.loop || false,
    initialSlide: $scope.initialSlide || 0,
    showNavButtons: false
};

3.4 Possible Attributes

The following attributes can be used with this directive. Please see the Swiper API Documentation for more information about the type and description of parameters.

    ...

3.5 Override any parameter

This allows you to pass a javascript object that will override any swiper parameter from the Swiper API Documentation that is used initialize swiper.

Example:

html

    
      
    

3.6 Two-Way Binding of Swiper

In some situations it might be useful to access the actual swiper instance. Passing the parent scope will linked it to the model in the directive's isolated scope which is used for the swiper instance.

It can also be used to slideTo(index, speed, runCallbacks), slidePrev(runCallbacks, speed), slideNext(runCallbacks, speed) or for callback functions.

Example Template:

html

Example Controller ```javascript angular.module('swiperApp') .controller('TestCtrl', function($scope){

$scope.swiper = {};

$scope.next = function(){ $scope.swiper.slideNext(); };

}); ```

3.7 Accessing swiper object after it's created

In some situations, like when you wanna listen to swiper events, is useful to know when the swiper object is created (that occurs after all slides are created).

For that purpose is available the on-ready attribute. You can specify a function to be called when the swiper object is created. In the function you can manipulate the swiperobject, and for example, bind an event. The function must has a paramteter called swiper, refering to swiper object.

Example template

Example Controller ```javascript angular.module('swiperApp') .controller('TestCtrl', function($scope){

$scope.swiper = {};

$scope.onReadySwiper = function (swiper) {

swiper.on('slideChangeStart', function () {

console.log('slideChangeStart');

}); };

}); ```

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.