Skip to content
This repository was archived by the owner on May 4, 2022. It is now read-only.

Commit efef23a

Browse files
feat(sidemenu): adding display-type attribute to ion-side-menu directive
1 parent fc404f9 commit efef23a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

js/angular/directive/sideMenu.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
* <ion-side-menu
1414
* side="left"
1515
* width="myWidthValue + 20"
16-
* is-enabled="shouldLeftSideMenuBeEnabled()">
16+
* is-enabled="shouldLeftSideMenuBeEnabled()"
17+
* display-type="push">
1718
* </ion-side-menu>
1819
* ```
1920
* For a complete side menu example, see the
@@ -22,6 +23,7 @@
2223
* @param {string} side Which side the side menu is currently on. Allowed values: 'left' or 'right'.
2324
* @param {boolean=} is-enabled Whether this side menu is enabled.
2425
* @param {number=} width How many pixels wide the side menu should be. Defaults to 275.
26+
* @param {string} display-type Which type of display the menu should have. Allowed values: 'push' or 'overlay'. Defaults to 'push'.
2527
*/
2628
IonicModule
2729
.directive('ionSideMenu', function() {
@@ -32,6 +34,7 @@ IonicModule
3234
compile: function(element, attr) {
3335
angular.isUndefined(attr.isEnabled) && attr.$set('isEnabled', 'true');
3436
angular.isUndefined(attr.width) && attr.$set('width', '275');
37+
angular.isUndefined(attr.displayType) && attr.$set('displayType', 'push');
3538

3639
element.addClass('menu menu-' + attr.side);
3740

@@ -41,7 +44,8 @@ IonicModule
4144
var sideMenu = sideMenuCtrl[$scope.side] = new ionic.views.SideMenu({
4245
width: attr.width,
4346
el: $element[0],
44-
isEnabled: true
47+
isEnabled: true,
48+
displayType: attr.displayType
4549
});
4650

4751
$scope.$watch($attr.width, function(val) {
@@ -53,8 +57,12 @@ IonicModule
5357
$scope.$watch($attr.isEnabled, function(val) {
5458
sideMenu.setIsEnabled(!!val);
5559
});
60+
$scope.$watch($attr.displayType, function(val) {
61+
if (val == 'push' || val == 'overlay') {
62+
sideMenu.setDisplayType(val);
63+
}
64+
});
5665
};
5766
}
5867
};
5968
});
60-

js/views/sideMenuView.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
this.el = opts.el;
1212
this.isEnabled = (typeof opts.isEnabled === 'undefined') ? true : opts.isEnabled;
1313
this.setWidth(opts.width);
14+
this.displayType = (typeof opts.displayType === 'undefined') ? 'push' : opts.displayType;
1415
},
1516
getFullWidth: function() {
1617
return this.width;
@@ -31,6 +32,9 @@
3132
if(this.el.style.zIndex !== '-1') {
3233
this.el.style.zIndex = '-1';
3334
}
35+
},
36+
setDisplayType: function(displayType) {
37+
this.displayType = displayType;
3438
}
3539
});
3640

0 commit comments

Comments
 (0)