https://github.com/ksachdeva/angular-swiper
Angular directive for nolimits4web/Swiper
https://github.com/ksachdeva/angular-swiper
Last synced: about 1 month ago
JSON representation
Angular directive for nolimits4web/Swiper
- Host: GitHub
- URL: https://github.com/ksachdeva/angular-swiper
- Owner: ksachdeva
- License: apache-2.0
- Created: 2015-03-22T17:53:17.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2019-04-04T07:08:28.000Z (almost 7 years ago)
- Last Synced: 2025-11-23T11:11:00.893Z (3 months ago)
- Language: HTML
- Size: 75.2 KB
- Stars: 196
- Watchers: 8
- Forks: 91
- Open Issues: 51
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/angular/bower-angular) and angular-swiper:
```html
<link rel="stylesheet" href="bower_components/swiper/dist/css/swiper.min.css">
<script src="../bower_components/swiper/dist/js/swiper.js">
```
And add `ksSwiper` as a dependency for your app:
```javascript
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.
```javascript
// 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](http://www.idangero.us/swiper/api/#.VZ03Je2qpBc) for more information about the type and description of parameters.
```html
...
```
### 3.5 Override any parameter
This allows you to pass a javascript object that will override any swiper parameter from the [Swiper API Documentation](http://www.idangero.us/swiper/api/#.VZ03Je2qpBc) 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
```html
```
Example Controller
```javascript
angular.module('swiperApp')
.controller('TestCtrl', function($scope){
$scope.swiper = {};
$scope.onReadySwiper = function (swiper) {
swiper.on('slideChangeStart', function () {
console.log('slideChangeStart');
});
};
});
```