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

Enable dragcontent to be right or left to handle RTL side menu support #315

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion js/angular/controller/sideMenuController.js
Original file line number Diff line number Diff line change
@@ -329,6 +329,10 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $io
// Handle a drag event
self._handleDrag = function(e) {
if (isAsideExposed || !$scope.dragContent) return;
//if dragContent is right
if ($scope.dragContent=='right' && !self.isOpenRight() && e.gesture.direction=='right')return;
//if dragContent is left
if ($scope.dragContent=='left' && !self.isOpenLeft() && e.gesture.direction=='left')return;

// If we don't have start coords, grab and store them
if (!startX) {
@@ -359,7 +363,7 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $io

self.canDragContent = function(canDrag) {
if (arguments.length) {
$scope.dragContent = !!canDrag;
$scope.dragContent = canDrag;
}
return $scope.dragContent;
};
16 changes: 11 additions & 5 deletions js/angular/directive/sideMenu.js
Original file line number Diff line number Diff line change
@@ -28,21 +28,28 @@ IonicModule
return {
restrict: 'E',
require: '^ionSideMenus',
scope: true,
scope: {side:'@?'},
compile: function(element, attr) {
angular.isUndefined(attr.isEnabled) && attr.$set('isEnabled', 'true');
angular.isUndefined(attr.width) && attr.$set('width', '275');

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

return function($scope, $element, $attr, sideMenuCtrl) {
$scope.side = $attr.side || 'left';

$scope.side = $scope.side || 'left';
var sideMenu = sideMenuCtrl[$scope.side] = new ionic.views.SideMenu({
width: attr.width,
el: $element[0],
isEnabled: true
});
$scope.$watch('side',function (value) {
element.removeClass('menu-right menu-left');
element.addClass('menu menu-' + $scope.side);
sideMenu = sideMenuCtrl[$scope.side] = new ionic.views.SideMenu({
width: attr.width,
el: $element[0],
isEnabled: true
});
})

$scope.$watch($attr.width, function(val) {
var numberVal = +val;
@@ -57,4 +64,3 @@ IonicModule
}
};
});

6 changes: 4 additions & 2 deletions js/angular/directive/sideMenuContent.js
Original file line number Diff line number Diff line change
@@ -36,7 +36,9 @@ function($timeout, $ionicGesture, $window) {
return {
restrict: 'EA', //DEPRECATED 'A'
require: '^ionSideMenus',
scope: true,
scope: {
dragContent:"@?"
},
compile: function(element, attr) {
element.addClass('menu-content pane');

@@ -46,7 +48,7 @@ function($timeout, $ionicGesture, $window) {
var primaryScrollAxis = null;

if (isDefined(attr.dragContent)) {
$scope.$watch(attr.dragContent, function(value) {
$scope.$watch('dragContent', function(value) {
sideMenuCtrl.canDragContent(value);
});
} else {
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -6,6 +6,9 @@
"repository": {
"url": "git://github.com/ionic-team/ionic.git"
},
"scripts":{
"gulp":"gulp"
},
"devDependencies": {
"canonical-path": "0.0.2",
"chalk": "^0.4.0",