Skip to content

Commit

Permalink
fix(sideMenu): exposeAside both left and right. Fixes #2328
Browse files Browse the repository at this point in the history
  • Loading branch information
mlynch committed Dec 7, 2015
1 parent 04ce589 commit a98f88b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
6 changes: 4 additions & 2 deletions js/angular/controller/sideMenuController.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,16 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $io
self.close();

isAsideExposed = shouldExposeAside;
if (self.left && self.left.isEnabled) {
if((self.left && self.left.isEnabled) && (self.right && self.right.isEnabled)) {
console.log('Setting left and right');
self.content.setMarginLeftAndRight(isAsideExposed ? self.left.width : 0, isAsideExposed ? self.right.width : 0);
} else if (self.left && self.left.isEnabled) {
// set the left marget width if it should be exposed
// otherwise set false so there's no left margin
self.content.setMarginLeft(isAsideExposed ? self.left.width : 0);
} else if (self.right && self.right.isEnabled) {
self.content.setMarginRight(isAsideExposed ? self.right.width : 0);
}

self.$scope.$emit('$ionicExposeAside', isAsideExposed);
};

Expand Down
18 changes: 18 additions & 0 deletions js/angular/directive/sideMenuContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,24 @@ function($timeout, $ionicGesture, $window) {
// reset incase left gets grabby
$element[0].style[ionic.CSS.TRANSFORM] = 'translate3d(0,0,0)';
}),
setMarginLeftAndRight: ionic.animationFrameThrottle(function(amountLeft, amountRight) {
amountLeft = amountLeft && parseInt(amountLeft, 10) || 0;
amountRight = amountRight && parseInt(amountRight, 10) || 0;

var amount = amountLeft + amountRight;

if(amount > 0) {
$element[0].style[ionic.CSS.TRANSFORM] = 'translate3d(' + amountLeft + 'px,0,0)';
$element[0].style.width = ($window.innerWidth - amount) + 'px';
content.offsetX = amountLeft;
} else {
$element[0].style[ionic.CSS.TRANSFORM] = 'translate3d(0,0,0)';
$element[0].style.width = '';
content.offsetX = 0;
}
// reset incase left gets grabby
//$element[0].style[ionic.CSS.TRANSFORM] = 'translate3d(0,0,0)';
}),
enableAnimation: function() {
$scope.animationEnabled = true;
$element[0].classList.add('menu-animated');
Expand Down
1 change: 1 addition & 0 deletions test/unit/angular/controller/sideMenuController.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('$ionicSideMenus controller', function() {
var content = new Controller({ el: document.createElement('div') });
content.setMarginLeft = function(){};
content.setMarginRight = function(){};
content.setMarginLeftAndRight = function(){};
ctrl.setContent(content);
});

Expand Down

0 comments on commit a98f88b

Please sign in to comment.