1
1
/**
2
2
* Angular Carousel - Mobile friendly touch carousel for AngularJS
3
- * @version v0.3.10 - 2015-04-16
3
+ * @version v0.3.11 - 2015-06-08
4
4
* @link http://revolunet.github.com/angular-carousel
5
5
* @author Julien Bouquillon <[email protected] >
6
6
* @license MIT License, http://www.opensource.org/licenses/MIT
@@ -271,7 +271,8 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
271
271
autoSlideDuration : 3 ,
272
272
bufferSize : 5 ,
273
273
/* in container % how much we need to drag to trigger the slide change */
274
- moveTreshold : 0.1
274
+ moveTreshold : 0.1 ,
275
+ defaultIndex : 0
275
276
} ;
276
277
277
278
// TODO
@@ -293,15 +294,14 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
293
294
mouseUpBound = false ,
294
295
locked = false ;
295
296
296
- if ( iAttributes . rnSwipeDisabled !== "true" ) { //rn-swipe-disabled =true will only disable swipe events
297
- $swipe . bind ( iElement , {
297
+ $swipe . bind ( iElement , {
298
298
start : swipeStart ,
299
299
move : swipeMove ,
300
300
end : swipeEnd ,
301
301
cancel : function ( event ) {
302
302
swipeEnd ( { } , event ) ;
303
303
}
304
- } ) } ;
304
+ } ) ;
305
305
306
306
function getSlidesDOM ( ) {
307
307
return iElement [ 0 ] . querySelectorAll ( 'ul[rn-carousel] > li' ) ;
@@ -472,6 +472,11 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
472
472
} , duration * 1000 ) ;
473
473
} ;
474
474
}
475
+
476
+ if ( iAttributes . rnCarouselDefaultIndex ) {
477
+ var defaultIndexModel = $parse ( iAttributes . rnCarouselDefaultIndex ) ;
478
+ options . defaultIndex = defaultIndexModel ( scope . $parent ) || 0 ;
479
+ }
475
480
476
481
if ( iAttributes . rnCarouselIndex ) {
477
482
var updateParentIndex = function ( value ) {
@@ -502,14 +507,20 @@ angular.module('angular-carousel').run(['$templateCache', function($templateCach
502
507
}
503
508
} ) ;
504
509
isIndexBound = true ;
510
+
511
+ if ( options . defaultIndex ) {
512
+ goToSlide ( options . defaultIndex , {
513
+ animate : ! init
514
+ } ) ;
515
+ }
505
516
} else if ( ! isNaN ( iAttributes . rnCarouselIndex ) ) {
506
517
/* if user just set an initial number, set it */
507
518
goToSlide ( parseInt ( iAttributes . rnCarouselIndex , 10 ) , {
508
519
animate : false
509
520
} ) ;
510
521
}
511
522
} else {
512
- goToSlide ( 0 , {
523
+ goToSlide ( options . defaultIndex , {
513
524
animate : ! init
514
525
} ) ;
515
526
init = false ;
0 commit comments