From 48e7f219afdddf7b35850db3acc582807d2d8926 Mon Sep 17 00:00:00 2001 From: abrbhat Date: Sat, 26 Dec 2015 16:42:24 +0530 Subject: [PATCH] added currentSlide to scope models --- dist/angular-swiper.js | 2 +- src/angular-swiper.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dist/angular-swiper.js b/dist/angular-swiper.js index 9d086c4..9e95566 100644 --- a/dist/angular-swiper.js +++ b/dist/angular-swiper.js @@ -1 +1 @@ -!function(e,i,r){"use strict";function t(){for(var e=[],i="0123456789abcdef",r=0;36>r;r++)e[r]=i.substr(Math.floor(16*Math.random()),1);e[14]="4",e[19]=i.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-";var t=e.join("");return t}function a(){return{restrict:"E",transclude:!0,scope:{onReady:"&",slidesPerView:"=",slidesPerColumn:"=",spaceBetween:"=",parallax:"=",parallaxTransition:"@",paginationIsActive:"=",paginationClickable:"=",showNavButtons:"=",showScrollBar:"=",loop:"=",autoplay:"=",initialSlide:"=",containerCls:"@",wrapperCls:"@",paginationCls:"@",slideCls:"@",direction:"@",swiper:"=",overrideParameters:"="},controller:["$scope","$element","$timeout",function(e,r,a){var n=t();e.swiper_uuid=n;var s={slidesPerView:e.slidesPerView||1,slidesPerColumn:e.slidesPerColumn||1,spaceBetween:e.spaceBetween||0,direction:e.direction||"horizontal",loop:e.loop||!1,initialSlide:e.initialSlide||0,showNavButtons:!1};i.isUndefined(e.autoplay)||"number"!=typeof e.autoplay||(s=i.extend({},s,{autoplay:e.autoplay})),e.paginationIsActive===!0&&(s=i.extend({},s,{paginationClickable:e.paginationClickable||!0,pagination:"#paginator-"+e.swiper_uuid})),e.showNavButtons===!0&&(s.nextButton="#nextButton-"+e.swiper_uuid,s.prevButton="#prevButton-"+e.swiper_uuid),e.showScrollBar===!0&&(s.scrollbar="#scrollBar-"+e.swiper_uuid),e.overrideParameters&&(s=i.extend({},s,e.overrideParameters)),a(function(){var t=null;i.isObject(e.swiper)?(e.swiper=new Swiper(r[0].firstChild,s),t=e.swiper):t=new Swiper(r[0].firstChild,s),i.isUndefined(e.onReady)||e.onReady({swiper:t})})}],link:function(e,r){var t=e.swiper_uuid,a="paginator-"+t,n="prevButton-"+t,s="nextButton-"+t,o="scrollBar-"+t,l=r[0];i.element(l.querySelector(".swiper-pagination")).attr("id",a),i.element(l.querySelector(".swiper-button-next")).attr("id",s),i.element(l.querySelector(".swiper-button-prev")).attr("id",n),i.element(r[0].querySelector(".swiper-scrollbar")).attr("id",o)},template:'
'}}function n(){return{restrict:"E",require:"^ksSwiperContainer",transclude:!0,template:'
',replace:!0}}i.module("ksSwiper",[]).directive("ksSwiperContainer",a).directive("ksSwiperSlide",n)}(window,angular,void 0); \ No newline at end of file +!function(e,i,r){"use strict";function t(){for(var e=[],i="0123456789abcdef",r=0;36>r;r++)e[r]=i.substr(Math.floor(16*Math.random()),1);e[14]="4",e[19]=i.substr(3&e[19]|8,1),e[8]=e[13]=e[18]=e[23]="-";var t=e.join("");return t}function n(){return{restrict:"E",transclude:!0,scope:{onReady:"&",slidesPerView:"=",slidesPerColumn:"=",spaceBetween:"=",parallax:"=",parallaxTransition:"@",paginationIsActive:"=",paginationClickable:"=",showNavButtons:"=",showScrollBar:"=",loop:"=",autoplay:"=",initialSlide:"=",containerCls:"@",wrapperCls:"@",paginationCls:"@",slideCls:"@",direction:"@",swiper:"=",overrideParameters:"=",currentSlide:"="},controller:["$scope","$element","$timeout",function(e,r,n){var a=t();e.swiper_uuid=a;var s={slidesPerView:e.slidesPerView||1,slidesPerColumn:e.slidesPerColumn||1,spaceBetween:e.spaceBetween||0,direction:e.direction||"horizontal",loop:e.loop||!1,initialSlide:e.initialSlide||0,showNavButtons:!1};i.isUndefined(e.autoplay)||"number"!=typeof e.autoplay||(s=i.extend({},s,{autoplay:e.autoplay})),e.paginationIsActive===!0&&(s=i.extend({},s,{paginationClickable:e.paginationClickable||!0,pagination:"#paginator-"+e.swiper_uuid})),e.showNavButtons===!0&&(s.nextButton="#nextButton-"+e.swiper_uuid,s.prevButton="#prevButton-"+e.swiper_uuid),e.showScrollBar===!0&&(s.scrollbar="#scrollBar-"+e.swiper_uuid),e.overrideParameters&&(s=i.extend({},s,e.overrideParameters)),n(function(){var t=null;i.isObject(e.swiper)?(e.swiper=new Swiper(r[0].firstChild,s),t=e.swiper):t=new Swiper(r[0].firstChild,s),i.isUndefined(e.currentSlide)||t.on("transitionEnd",function(){e.currentSlide=Math.abs(t.progress)}),i.isUndefined(e.onReady)||e.onReady({swiper:t})})}],link:function(e,r){var t=e.swiper_uuid,n="paginator-"+t,a="prevButton-"+t,s="nextButton-"+t,o="scrollBar-"+t,l=r[0];i.element(l.querySelector(".swiper-pagination")).attr("id",n),i.element(l.querySelector(".swiper-button-next")).attr("id",s),i.element(l.querySelector(".swiper-button-prev")).attr("id",a),i.element(r[0].querySelector(".swiper-scrollbar")).attr("id",o)},template:'
'}}function a(){return{restrict:"E",require:"^ksSwiperContainer",transclude:!0,template:'
',replace:!0}}i.module("ksSwiper",[]).directive("ksSwiperContainer",n).directive("ksSwiperSlide",a)}(window,angular,void 0); \ No newline at end of file diff --git a/src/angular-swiper.js b/src/angular-swiper.js index e57492e..1f242ff 100644 --- a/src/angular-swiper.js +++ b/src/angular-swiper.js @@ -46,7 +46,8 @@ slideCls: '@', direction: '@', swiper: '=', - overrideParameters: '=' + overrideParameters: '=', + currentSlide: '=' }, controller: function($scope, $element, $timeout) { var uuid = createUUID(); @@ -100,6 +101,12 @@ swiper = new Swiper($element[0].firstChild, params); } + if(!angular.isUndefined($scope.currentSlide)){ + swiper.on('transitionEnd', function(){ + $scope.currentSlide = Math.abs(swiper.progress); + }); + } + //If specified, calls this function when the swiper object is available if (!angular.isUndefined($scope.onReady)) { $scope.onReady({ @@ -155,4 +162,4 @@ }; } -})(window, angular, undefined); \ No newline at end of file +})(window, angular, undefined);