11/**
22 * Angular Carousel - Mobile friendly touch carousel for AngularJS
3- * @version v0.3.10 - 2015-04-16
3+ * @version v0.3.11 - 2015-06-08
44 * @link http://revolunet.github.com/angular-carousel
55 * @author Julien Bouquillon <[email protected] > 66 * @license MIT License, http://www.opensource.org/licenses/MIT
@@ -271,7 +271,8 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
271271 autoSlideDuration : 3 ,
272272 bufferSize : 5 ,
273273 /* in container % how much we need to drag to trigger the slide change */
274- moveTreshold : 0.1
274+ moveTreshold : 0.1 ,
275+ defaultIndex : 0
275276 } ;
276277
277278 // TODO
@@ -293,15 +294,14 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
293294 mouseUpBound = false ,
294295 locked = false ;
295296
296- if ( iAttributes . rnSwipeDisabled !== "true" ) { //rn-swipe-disabled =true will only disable swipe events
297- $swipe . bind ( iElement , {
297+ $swipe . bind ( iElement , {
298298 start : swipeStart ,
299299 move : swipeMove ,
300300 end : swipeEnd ,
301301 cancel : function ( event ) {
302302 swipeEnd ( { } , event ) ;
303303 }
304- } ) } ;
304+ } ) ;
305305
306306 function getSlidesDOM ( ) {
307307 return iElement [ 0 ] . querySelectorAll ( 'ul[rn-carousel] > li' ) ;
@@ -472,6 +472,11 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
472472 } , duration * 1000 ) ;
473473 } ;
474474 }
475+
476+ if ( iAttributes . rnCarouselDefaultIndex ) {
477+ var defaultIndexModel = $parse ( iAttributes . rnCarouselDefaultIndex ) ;
478+ options . defaultIndex = defaultIndexModel ( scope . $parent ) || 0 ;
479+ }
475480
476481 if ( iAttributes . rnCarouselIndex ) {
477482 var updateParentIndex = function ( value ) {
@@ -502,14 +507,20 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
502507 }
503508 } ) ;
504509 isIndexBound = true ;
510+
511+ if ( options . defaultIndex ) {
512+ goToSlide ( options . defaultIndex , {
513+ animate : ! init
514+ } ) ;
515+ }
505516 } else if ( ! isNaN ( iAttributes . rnCarouselIndex ) ) {
506517 /* if user just set an initial number, set it */
507518 goToSlide ( parseInt ( iAttributes . rnCarouselIndex , 10 ) , {
508519 animate : false
509520 } ) ;
510521 }
511522 } else {
512- goToSlide ( 0 , {
523+ goToSlide ( options . defaultIndex , {
513524 animate : ! init
514525 } ) ;
515526 init = false ;
0 commit comments