Skip to content

Commit a98f88b

Browse files
committed
fix(sideMenu): exposeAside both left and right. Fixes #2328
1 parent 04ce589 commit a98f88b

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎js/angular/controller/sideMenuController.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,16 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $io
301301
self.close();
302302

303303
isAsideExposed = shouldExposeAside;
304-
if (self.left && self.left.isEnabled) {
304+
if((self.left && self.left.isEnabled) && (self.right && self.right.isEnabled)) {
305+
console.log('Setting left and right');
306+
self.content.setMarginLeftAndRight(isAsideExposed ? self.left.width : 0, isAsideExposed ? self.right.width : 0);
307+
} else if (self.left && self.left.isEnabled) {
305308
// set the left marget width if it should be exposed
306309
// otherwise set false so there's no left margin
307310
self.content.setMarginLeft(isAsideExposed ? self.left.width : 0);
308311
} else if (self.right && self.right.isEnabled) {
309312
self.content.setMarginRight(isAsideExposed ? self.right.width : 0);
310313
}
311-
312314
self.$scope.$emit('$ionicExposeAside', isAsideExposed);
313315
};
314316

‎js/angular/directive/sideMenuContent.js‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,24 @@ function($timeout, $ionicGesture, $window) {
167167
// reset incase left gets grabby
168168
$element[0].style[ionic.CSS.TRANSFORM] = 'translate3d(0,0,0)';
169169
}),
170+
setMarginLeftAndRight: ionic.animationFrameThrottle(function(amountLeft, amountRight) {
171+
amountLeft = amountLeft && parseInt(amountLeft, 10) || 0;
172+
amountRight = amountRight && parseInt(amountRight, 10) || 0;
173+
174+
var amount = amountLeft + amountRight;
175+
176+
if(amount > 0) {
177+
$element[0].style[ionic.CSS.TRANSFORM] = 'translate3d(' + amountLeft + 'px,0,0)';
178+
$element[0].style.width = ($window.innerWidth - amount) + 'px';
179+
content.offsetX = amountLeft;
180+
} else {
181+
$element[0].style[ionic.CSS.TRANSFORM] = 'translate3d(0,0,0)';
182+
$element[0].style.width = '';
183+
content.offsetX = 0;
184+
}
185+
// reset incase left gets grabby
186+
//$element[0].style[ionic.CSS.TRANSFORM] = 'translate3d(0,0,0)';
187+
}),
170188
enableAnimation: function() {
171189
$scope.animationEnabled = true;
172190
$element[0].classList.add('menu-animated');

‎test/unit/angular/controller/sideMenuController.unit.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ describe('$ionicSideMenus controller', function() {
5050
var content = new Controller({ el: document.createElement('div') });
5151
content.setMarginLeft = function(){};
5252
content.setMarginRight = function(){};
53+
content.setMarginLeftAndRight = function(){};
5354
ctrl.setContent(content);
5455
});
5556

0 commit comments

Comments
 (0)