mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat($ionicSideMenuDelegate): add isOpen() method
Closes #1074. Closes #1075.
This commit is contained in:
committed by
Andy Joslin
parent
dfbb376552
commit
518e54ee86
@@ -117,7 +117,7 @@
|
||||
},
|
||||
|
||||
isOpen: function() {
|
||||
return this.getOpenRatio() == 1;
|
||||
return this.getOpenAmount() !== 0;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user