Skip to content

Commit

Permalink
feat($ionicSideMenuDelegate): add isOpen() method
Browse files Browse the repository at this point in the history
Closes #1074. Closes #1075.
  • Loading branch information
rvanbaalen authored and ajoslin committed Apr 7, 2014
1 parent dfbb376 commit 518e54e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/controllers/sideMenuController.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
},

isOpen: function() {
return this.getOpenRatio() == 1;
return this.getOpenAmount() !== 0;
},

/**
Expand Down
6 changes: 6 additions & 0 deletions js/ext/angular/src/directive/ionicSideMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions test/unit/controllers/sideMenuController.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 518e54e

Please sign in to comment.