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

Commit 33594ad

Browse files
feat(sideMenuContent): adding close-menu-on-tap attribute
1 parent fc404f9 commit 33594ad

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

js/angular/controller/sideMenuController.js

+8
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,14 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $io
378378
return self.edgeThresholdEnabled;
379379
};
380380

381+
$scope.closeMenuOnTap = true;
382+
self.closeMenuOnTap = function(closeMenu) {
383+
if (arguments.length) {
384+
$scope.closeMenuOnTap = !!closeMenu;
385+
}
386+
return $scope.closeMenuOnTap;
387+
};
388+
381389
self.isDraggableTarget = function(e) {
382390
//Only restrict edge when sidemenu is closed and restriction is enabled
383391
var shouldOnlyAllowEdgeDrag = self.edgeThresholdEnabled && !self.isOpen();

js/angular/directive/sideMenuContent.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
* ```html
1414
* <ion-side-menu-content
1515
* edge-drag-threshold="true"
16-
* drag-content="true">
16+
* drag-content="true"
17+
* close-menu-on-tap="true">
1718
* </ion-side-menu-content>
1819
* ```
1920
* For a complete side menu example, see the
@@ -24,6 +25,7 @@
2425
* - If a non-zero number is given, that many pixels is used as the maximum allowed distance from the edge that starts dragging the side menu.
2526
* - If true is given, the default number of pixels (25) is used as the maximum allowed distance.
2627
* - If false or 0 is given, the edge drag threshold is disabled, and dragging from anywhere on the content is allowed.
28+
* @param {boolean=} close-menu-on-tap Whether the content tap should close side menus. Default true.
2729
*
2830
*/
2931
IonicModule
@@ -59,9 +61,15 @@ function($timeout, $ionicGesture, $window) {
5961
});
6062
}
6163

64+
if (isDefined(attr.closeMenuOnTap)) {
65+
$scope.$watch(attr.closeMenuOnTap, function(value) {
66+
sideMenuCtrl.closeMenuOnTap(value);
67+
});
68+
}
69+
6270
// Listen for taps on the content to close the menu
6371
function onContentTap(gestureEvt) {
64-
if (sideMenuCtrl.getOpenAmount() !== 0) {
72+
if (sideMenuCtrl.closeMenuOnTap() && sideMenuCtrl.getOpenAmount() !== 0) {
6573
sideMenuCtrl.close();
6674
gestureEvt.gesture.srcEvent.preventDefault();
6775
startCoord = null;

0 commit comments

Comments
 (0)