diff --git a/js/angular/controller/sideMenuController.js b/js/angular/controller/sideMenuController.js index 217c60d9c0..1af15577f1 100644 --- a/js/angular/controller/sideMenuController.js +++ b/js/angular/controller/sideMenuController.js @@ -50,6 +50,7 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody) { * Toggle the left menu to open 100% */ self.toggleLeft = function(shouldOpen) { + if(isAsideExposed) return; var openAmount = self.getOpenAmount(); if (arguments.length === 0) { shouldOpen = openAmount <= 0; @@ -66,6 +67,7 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody) { * Toggle the right menu to open 100% */ self.toggleRight = function(shouldOpen) { + if(isAsideExposed) return; var openAmount = self.getOpenAmount(); if (arguments.length === 0) { shouldOpen = openAmount >= 0; @@ -82,7 +84,6 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody) { * Close all menus. */ self.close = function() { - if(isAsideExposed) return; self.openPercentage(0); }; @@ -258,6 +259,7 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody) { }; self.exposeAside = function(shouldExposeAside) { + self.close(); isAsideExposed = shouldExposeAside; // set the left marget width if it should be exposed diff --git a/js/angular/directive/sideMenuContent.js b/js/angular/directive/sideMenuContent.js index f6efa69b70..73c0cebbd2 100644 --- a/js/angular/directive/sideMenuContent.js +++ b/js/angular/directive/sideMenuContent.js @@ -145,6 +145,7 @@ function($timeout, $ionicGesture, $window) { }), setMarginLeft: ionic.animationFrameThrottle(function(amount) { if(amount) { + amount = parseInt(amount, 10); $element[0].style[ionic.CSS.TRANSFORM] = 'translate3d(' + amount + 'px,0,0)'; $element[0].style.width = ($window.innerWidth - amount) + 'px'; content.offsetX = amount; diff --git a/test/unit/angular/controller/sideMenuController.unit.js b/test/unit/angular/controller/sideMenuController.unit.js index 9ec6706b24..a277ce42ac 100644 --- a/test/unit/angular/controller/sideMenuController.unit.js +++ b/test/unit/angular/controller/sideMenuController.unit.js @@ -47,7 +47,9 @@ describe('$ionicSideMenus controller', function() { el: document.createElement('div'), isEnabled: true }); - ctrl.setContent(new Controller({ el: document.createElement('div') })); + var content = new Controller({ el: document.createElement('div') }); + content.setMarginLeft = function(){}; + ctrl.setContent(content); }); }); @@ -104,6 +106,34 @@ describe('$ionicSideMenus controller', function() { expect(ctrl.getOpenPercentage()).toEqual(0); }); + it('should not toggle left with exposed aside', function() { + expect(ctrl.getOpenPercentage()).toEqual(0); + ctrl.exposeAside(true); + ctrl.toggleLeft(); + expect(ctrl.getOpenPercentage()).toEqual(0); + }); + + it('should not toggle right with exposed aside', function() { + expect(ctrl.getOpenPercentage()).toEqual(0); + ctrl.exposeAside(true); + ctrl.toggleRight(); + expect(ctrl.getOpenPercentage()).toEqual(0); + }); + + it('should close left menu on expose aside', function() { + ctrl.toggleLeft(); + expect(ctrl.getOpenPercentage()).toEqual(100); + ctrl.exposeAside(true); + expect(ctrl.getOpenPercentage()).toEqual(0); + }); + + it('should close right menu on expose aside', function() { + ctrl.toggleRight(); + expect(ctrl.getOpenPercentage()).toEqual(-100); + ctrl.exposeAside(true); + expect(ctrl.getOpenPercentage()).toEqual(0); + }); + it('should toggle right', function() { ctrl.toggleRight(); expect(ctrl.getOpenPercentage()).toEqual(-100); @@ -219,9 +249,6 @@ describe('$ionicSideMenus controller', function() { expect(ctrl.getOpenPercentage()).toEqual(-100); }); - it('Should test content drag events', function() { - }); - it('should register with backButton on open and dereg on close', inject(function($ionicPlatform) { var openAmount = 0; var deregSpy = jasmine.createSpy('deregister');