diff --git a/js/angular/controller/sideMenuController.js b/js/angular/controller/sideMenuController.js index aa3bb31afbf..e147c6219d0 100644 --- a/js/angular/controller/sideMenuController.js +++ b/js/angular/controller/sideMenuController.js @@ -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); }; diff --git a/js/angular/directive/sideMenuContent.js b/js/angular/directive/sideMenuContent.js index ec706879ffa..38f8bb06b1b 100644 --- a/js/angular/directive/sideMenuContent.js +++ b/js/angular/directive/sideMenuContent.js @@ -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'); diff --git a/test/unit/angular/controller/sideMenuController.unit.js b/test/unit/angular/controller/sideMenuController.unit.js index 04f3941b8ef..7b0ab9799a7 100644 --- a/test/unit/angular/controller/sideMenuController.unit.js +++ b/test/unit/angular/controller/sideMenuController.unit.js @@ -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); });