Skip to content

Commit db7f0ee

Browse files
committed
fix(slidebox): prevent scrolling while sliding
Closes #2814
1 parent 6a27fef commit db7f0ee

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

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

+18-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ IonicModule
4141
'$compile',
4242
'$ionicSlideBoxDelegate',
4343
'$ionicHistory',
44-
function($timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory) {
44+
'$ionicScrollDelegate',
45+
function($timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory, $ionicScrollDelegate) {
4546
return {
4647
restrict: 'E',
4748
replace: true,
@@ -81,9 +82,25 @@ function($timeout, $compile, $ionicSlideBoxDelegate, $ionicHistory) {
8182
$scope.activeSlide = slideIndex;
8283
// Try to trigger a digest
8384
$timeout(function() {});
85+
},
86+
onDrag: function() {
87+
freezeAllScrolls(true);
88+
},
89+
onDragEnd: function() {
90+
freezeAllScrolls(false);
8491
}
8592
});
8693

94+
function freezeAllScrolls(shouldFreeze) {
95+
if (shouldFreeze && !_this.isScrollFreeze) {
96+
$ionicScrollDelegate.freezeAllScrolls(shouldFreeze);
97+
98+
} else if (!shouldFreeze && _this.isScrollFreeze) {
99+
$ionicScrollDelegate.freezeAllScrolls(false);
100+
}
101+
_this.isScrollFreeze = shouldFreeze;
102+
}
103+
87104
slider.enableSlide($scope.$eval($attrs.disableScroll) !== true);
88105

89106
$scope.$watch('activeSlide', function(nv) {

Diff for: js/views/scrollView.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ ionic.views.Scroll = ionic.views.View.inherit({
692692

693693
//update scroll view
694694
self.resize();
695-
})
695+
});
696696
}
697697

698698
self.isShrunkForKeyboard = true;

Diff for: js/views/sliderView.js

+2
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ ionic.views.Slider = ionic.views.View.inherit({
361361
translate(index+1, delta.x + slidePos[index+1], 0);
362362
}
363363

364+
options.onDrag && options.onDrag();
364365
}
365366

366367
},
@@ -451,6 +452,7 @@ ionic.views.Slider = ionic.views.View.inherit({
451452
document.removeEventListener('mouseup', events, false);
452453
}
453454

455+
options.onDragEnd && options.onDragEnd();
454456
},
455457
transitionEnd: function(event) {
456458

0 commit comments

Comments
 (0)