Skip to content

Commit 465d98c

Browse files
committed
Slidebox bouncing
1 parent 96ef1cc commit 465d98c

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

Diff for: js/angular/directive/slideBox.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ function($timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory, $ionicScroll
5656
disableScroll: '@',
5757
onSlideChanged: '&',
5858
activeSlide: '=?',
59-
hasBouncing: '@'
59+
bounce: '@'
6060
},
6161
controller: ['$scope', '$element', '$attrs', function($scope, $element, $attrs) {
6262
var _this = this;
6363

6464
var continuous = $scope.$eval($scope.doesContinue) === true;
65-
var bouncing = ($scope.$eval($scope.hasBouncing) !== false); //Default to true
65+
var bouncing = ($scope.$eval($scope.bounce) !== false); //Default to true
6666
var shouldAutoPlay = isDefined($attrs.autoPlay) ? !!$scope.autoPlay : false;
6767
var slideInterval = shouldAutoPlay ? $scope.$eval($scope.slideInterval) || 4000 : 0;
6868

@@ -142,7 +142,6 @@ function($timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory, $ionicScroll
142142
};
143143

144144
this.onPagerClick = function(index) {
145-
console.log('pagerClick', index);
146145
$scope.pagerClick({index: index});
147146
};
148147

Diff for: js/views/sliderView.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -379,16 +379,17 @@ ionic.views.Slider = ionic.views.View.inherit({
379379
translate(index, delta.x + slidePos[index], 0);
380380
translate(circle(index + 1), delta.x + slidePos[circle(index + 1)], 0);
381381

382-
} else{
383-
if(options.bouncing){
384-
delta.x =
385-
delta.x /
386-
( (!index && delta.x > 0 || // if first slide and sliding left
387-
index == slides.length - 1 && // or if last slide and sliding right
388-
delta.x < 0 // and if sliding at all
389-
) ?
390-
( Math.abs(delta.x) / width + 1 ) // determine resistance level
391-
: 1 ); // no resistance if false
382+
} else {
383+
// If the slider bounces, do the bounce!
384+
if(options.bouncing) {
385+
delta.x =
386+
delta.x /
387+
( (!index && delta.x > 0 || // if first slide and sliding left
388+
index == slides.length - 1 && // or if last slide and sliding right
389+
delta.x < 0 // and if sliding at all
390+
) ?
391+
( Math.abs(delta.x) / width + 1 ) // determine resistance level
392+
: 1 ); // no resistance if false
392393
} else {
393394
if(width * index - delta.x < 0) { //We are trying scroll past left boundary
394395
delta.x = Math.min(delta.x, width * index); //Set delta.x so we don't go past left screen

Diff for: test/html/slideBox.html

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
on-slide-changed="slideChanged(index)"
5656
show-pager="{{$root.showPager}}"
5757
pager-click="pagerClick(index)"
58-
does-continue="true"
5958
auto-play="false">
6059
<ion-slide ng-controller="FirstSlideCtrl">
6160
<h3>Thank you for choosing the Awesome App!</h3>

0 commit comments

Comments
 (0)