-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathswiper.js
executable file
·34 lines (30 loc) · 890 Bytes
/
swiper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
angular.module('swiper', [])
.directive('swiper', function ($parse) {
return {
scope: true,
link: function(scope, element, attrs) {
element.addClass('swipe');
var config = {};
if ( attrs.auto ) {
config.auto = parseInt(attrs.auto,10);
}
if ( attrs.startSlide ) {
config.startSlide = parseInt(attrs.startSlide,10);
}
if ( attrs.speed ) {
config.speed = parseInt(attrs.speed,10);
}
if ( attrs.onSlideEnd ) {
var onSlideEnd = $parse(attrs.onSlideEnd);
config.callback = function(e, index, slide) {
scope.$apply(function() {
onSlideEnd(scope, { index: index, slide: slide});
});
};
}
var swiperProperty = attrs.swiper || 'swiper';
var swiper = new Swipe(element[0], config);
scope[swiperProperty] = swiper;
}
};
});