Skip to content

Commit

Permalink
fix(slidebox): prevent scrolling while sliding
Browse files Browse the repository at this point in the history
Closes #2814
  • Loading branch information
adamdbradley committed Apr 13, 2015
1 parent 6a27fef commit db7f0ee
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
19 changes: 18 additions & 1 deletion js/angular/directive/slideBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ IonicModule
'$compile',
'$ionicSlideBoxDelegate',
'$ionicHistory',
function($timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory) {
'$ionicScrollDelegate',
function($timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory, $ionicScrollDelegate) {
return {
restrict: 'E',
replace: true,
Expand Down Expand Up @@ -81,9 +82,25 @@ function($timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory) {
$scope.activeSlide = slideIndex;
// Try to trigger a digest
$timeout(function() {});
},
onDrag: function() {
freezeAllScrolls(true);
},
onDragEnd: function() {
freezeAllScrolls(false);
}
});

function freezeAllScrolls(shouldFreeze) {
if (shouldFreeze && !_this.isScrollFreeze) {
$ionicScrollDelegate.freezeAllScrolls(shouldFreeze);

} else if (!shouldFreeze && _this.isScrollFreeze) {
$ionicScrollDelegate.freezeAllScrolls(false);
}
_this.isScrollFreeze = shouldFreeze;
}

slider.enableSlide($scope.$eval($attrs.disableScroll) !== true);

$scope.$watch('activeSlide', function(nv) {
Expand Down
2 changes: 1 addition & 1 deletion js/views/scrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ ionic.views.Scroll = ionic.views.View.inherit({

//update scroll view
self.resize();
})
});
}

self.isShrunkForKeyboard = true;
Expand Down
2 changes: 2 additions & 0 deletions js/views/sliderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ ionic.views.Slider = ionic.views.View.inherit({
translate(index+1, delta.x + slidePos[index+1], 0);
}

options.onDrag && options.onDrag();
}

},
Expand Down Expand Up @@ -451,6 +452,7 @@ ionic.views.Slider = ionic.views.View.inherit({
document.removeEventListener('mouseup', events, false);
}

options.onDragEnd && options.onDragEnd();
},
transitionEnd: function(event) {

Expand Down

0 comments on commit db7f0ee

Please sign in to comment.