Skip to content

Commit a0d60d5

Browse files
author
Adam Bradley
committed
fix(sideMenu): Fix flashing when closing right side menu, closes #556
1 parent 4d36671 commit a0d60d5

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

js/controllers/sideMenuController.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
this.right = options.right;
1616
this.content = options.content;
1717
this.dragThresholdX = options.dragThresholdX || 10;
18-
18+
1919
this._rightShowing = false;
2020
this._leftShowing = false;
2121
this._isDragging = false;
@@ -32,7 +32,7 @@
3232
},
3333
/**
3434
* Set the content view controller if not passed in the constructor options.
35-
*
35+
*
3636
* @param {object} content
3737
*/
3838
setContent: function(content) {
@@ -147,17 +147,19 @@
147147
if((this._leftShowing && amount > maxLeft) || (this._rightShowing && amount < -maxRight)) {
148148
return;
149149
}
150-
150+
151151
this.content.setTranslateX(amount);
152152

153153
if(amount >= 0) {
154154
this._leftShowing = true;
155155
this._rightShowing = false;
156156

157-
// Push the z-index of the right menu down
158-
this.right && this.right.pushDown && this.right.pushDown();
159-
// Bring the z-index of the left menu up
160-
this.left && this.left.bringUp && this.left.bringUp();
157+
if(amount > 0) {
158+
// Push the z-index of the right menu down
159+
this.right && this.right.pushDown && this.right.pushDown();
160+
// Bring the z-index of the left menu up
161+
this.left && this.left.bringUp && this.left.bringUp();
162+
}
161163
} else {
162164
this._rightShowing = true;
163165
this._leftShowing = false;
@@ -171,7 +173,7 @@
171173

172174
/**
173175
* Given an event object, find the final resting position of this side
174-
* menu. For example, if the user "throws" the content to the right and
176+
* menu. For example, if the user "throws" the content to the right and
175177
* releases the touch, the left menu should snap open (animated, of course).
176178
*
177179
* @param {Event} e the gesture event to use for snapping
@@ -192,7 +194,7 @@
192194
var velocityX = e.gesture.velocityX;
193195
var direction = e.gesture.direction;
194196

195-
// Less than half, going left
197+
// Less than half, going left
196198
//if(ratio > 0 && ratio < 0.5 && direction == 'left' && velocityX < velocityThreshold) {
197199
//this.openPercentage(0);
198200
//}
@@ -216,17 +218,17 @@
216218
else if(ratio < 0.5 && direction == 'right' && velocityX < velocityThreshold) {
217219
this.openPercentage(-100);
218220
}
219-
221+
220222
// Going right, more than half, or quickly (snap open)
221223
else if(direction == 'right' && ratio >= 0 && (ratio >= 0.5 || velocityX > velocityThreshold)) {
222224
this.openPercentage(100);
223225
}
224-
226+
225227
// Going left, more than half, or quickly (span open)
226228
else if(direction == 'left' && ratio <= 0 && (ratio <= -0.5 || velocityX > velocityThreshold)) {
227229
this.openPercentage(-100);
228230
}
229-
231+
230232
// Snap back for safety
231233
else {
232234
this.openPercentage(0);

js/ext/angular/test/sideMenu.html

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212

1313
<div ng-controller="MenuCtrl">
1414
<ion-side-menus>
15-
<ion-pane ion-side-menu-content drag-content="$root.$draggy">
15+
<ion-pane ion-side-menu-content>
1616
<header class="bar bar-header bar-assertive">
17-
<button class="button button-icon" ng-click="openLeft()"><i class="icon ion-navicon"></i></button>
17+
<button class="button button-icon ion-navicon" ng-click="openLeft()"></button>
1818
<h1 class="title">Slide me</h1>
19+
<button class="button button-icon ion-navicon" ng-click="openRight()"></button>
1920
</header>
2021
<ion-content has-header="true">
2122
<ion-toggle ng-model="$root.$draggy">Hello</ion-toggle>
@@ -63,6 +64,9 @@ <h1 class="title">Right</h1>
6364
$scope.openLeft = function() {
6465
$ionicSideMenuDelegate.toggleLeft($scope);
6566
};
67+
$scope.openRight = function() {
68+
$ionicSideMenuDelegate.toggleRight($scope);
69+
};
6670
})
6771
.controller('LeftCtrl', function($scope) {
6872
$scope.value = true;

0 commit comments

Comments
 (0)