feat($ionicSideMenuDelegate): add isOpen() method

Closes #1074. Closes #1075.
This commit is contained in:
Robin van Baalen
2014-04-07 12:35:52 -07:00
committed by Andy Joslin
parent dfbb376552
commit 518e54ee86
3 changed files with 26 additions and 1 deletions

View File

@@ -117,7 +117,7 @@
},
isOpen: function() {
return this.getOpenRatio() == 1;
return this.getOpenAmount() !== 0;
},
/**

View File

@@ -85,6 +85,12 @@ angular.module('ionic.ui.sideMenu', ['ionic.service.gesture', 'ionic.service.vie
* opened/opening, and between 0 and -1 if right menu is opened/opening.
*/
'getOpenRatio',
/**
* @ngdoc method
* @name $ionicSideMenuDelegate#isOpen
* @returns {boolean} Whether either the left or right menu is currently opened.
*/
'isOpen',
/**
* @ngdoc method
* @name $ionicSideMenuDelegate#isOpenLeft

View File

@@ -104,6 +104,25 @@ describe('SideMenuController', function() {
expect(ctrl.getOpenPercentage()).toEqual(0);
});
it('should isOpen', function() {
expect(ctrl.isOpen()).toEqual(false);
ctrl.toggleLeft();
expect(ctrl.isOpen()).toEqual(true);
ctrl.toggleLeft();
expect(ctrl.isOpen()).toEqual(false);
ctrl.toggleLeft();
expect(ctrl.isOpen()).toEqual(true);
ctrl.toggleLeft();
expect(ctrl.isOpen()).toEqual(false);
ctrl.toggleRight();
expect(ctrl.isOpen()).toEqual(true);
ctrl.toggleRight();
expect(ctrl.isOpen()).toEqual(false);
ctrl.toggleRight();
expect(ctrl.isOpen()).toEqual(true);
});
it('should isOpenLeft', function() {
expect(ctrl.isOpenLeft()).toEqual(false);
ctrl.toggleLeft();