From 358bdc76805974d34e28214bdf48795597e80e82 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 8 Oct 2014 16:37:45 -0600 Subject: [PATCH] refactor(ionSlideBox): use default transitionDuration if not changing --- js/angular/controller/slideBoxController.js | 18 ++++++++++-------- js/angular/directive/slideBox.js | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/js/angular/controller/slideBoxController.js b/js/angular/controller/slideBoxController.js index b078aff3ba..6602e9c7ae 100644 --- a/js/angular/controller/slideBoxController.js +++ b/js/angular/controller/slideBoxController.js @@ -63,6 +63,7 @@ function(scope, element, $$ionicAttachDrag, $interval) { // If we only have two slides and loop is enabled, we cannot have a previous // because previous === next. In this case, return -1. if (self.loop() && self.count() === 2) { + console.log('lying about previous'); return -1; } return slideList.previous(index); @@ -187,16 +188,17 @@ function(scope, element, $$ionicAttachDrag, $interval) { if (Math.abs(percent) > 0.5 || velocity > SLIDE_SUCCESS_VELOCITY) { nextIndex = percent > 0 ? self.next() : self.previous(); } - var transitionDuration = Math.min( - slidesParent.prop('offsetWidth') / (3 * velocity), - SLIDE_TRANSITION_DURATION - ); // Select a new slide if it's avaiable - self.select( - self.isInRange(nextIndex) ? nextIndex : self.selected(), - transitionDuration - ); + if (self.isInRange(nextIndex)) { + var transitionDuration = Math.min( + slidesParent.prop('offsetWidth') / (3 * velocity), + SLIDE_TRANSITION_DURATION + ); + self.select(nextIndex, transitionDuration); + } else { + self.select(selectedIndex); + } } // *** diff --git a/js/angular/directive/slideBox.js b/js/angular/directive/slideBox.js index 29ca6727c0..f343725c44 100644 --- a/js/angular/directive/slideBox.js +++ b/js/angular/directive/slideBox.js @@ -45,7 +45,7 @@ function($ionicSlideBoxDelegate, $window) { return { restrict: 'E', controller: '$ionSlideBox', - require: ['ionSlideBox'], + require: 'ionSlideBox', transclude: true, scope: { selectedIndex: '=?selected',