|
15 | 15 | this.right = options.right;
|
16 | 16 | this.content = options.content;
|
17 | 17 | this.dragThresholdX = options.dragThresholdX || 10;
|
18 |
| - |
| 18 | + |
19 | 19 | this._rightShowing = false;
|
20 | 20 | this._leftShowing = false;
|
21 | 21 | this._isDragging = false;
|
|
32 | 32 | },
|
33 | 33 | /**
|
34 | 34 | * Set the content view controller if not passed in the constructor options.
|
35 |
| - * |
| 35 | + * |
36 | 36 | * @param {object} content
|
37 | 37 | */
|
38 | 38 | setContent: function(content) {
|
|
147 | 147 | if((this._leftShowing && amount > maxLeft) || (this._rightShowing && amount < -maxRight)) {
|
148 | 148 | return;
|
149 | 149 | }
|
150 |
| - |
| 150 | + |
151 | 151 | this.content.setTranslateX(amount);
|
152 | 152 |
|
153 | 153 | if(amount >= 0) {
|
154 | 154 | this._leftShowing = true;
|
155 | 155 | this._rightShowing = false;
|
156 | 156 |
|
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 | + } |
161 | 163 | } else {
|
162 | 164 | this._rightShowing = true;
|
163 | 165 | this._leftShowing = false;
|
|
171 | 173 |
|
172 | 174 | /**
|
173 | 175 | * 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 |
175 | 177 | * releases the touch, the left menu should snap open (animated, of course).
|
176 | 178 | *
|
177 | 179 | * @param {Event} e the gesture event to use for snapping
|
|
192 | 194 | var velocityX = e.gesture.velocityX;
|
193 | 195 | var direction = e.gesture.direction;
|
194 | 196 |
|
195 |
| - // Less than half, going left |
| 197 | + // Less than half, going left |
196 | 198 | //if(ratio > 0 && ratio < 0.5 && direction == 'left' && velocityX < velocityThreshold) {
|
197 | 199 | //this.openPercentage(0);
|
198 | 200 | //}
|
|
216 | 218 | else if(ratio < 0.5 && direction == 'right' && velocityX < velocityThreshold) {
|
217 | 219 | this.openPercentage(-100);
|
218 | 220 | }
|
219 |
| - |
| 221 | + |
220 | 222 | // Going right, more than half, or quickly (snap open)
|
221 | 223 | else if(direction == 'right' && ratio >= 0 && (ratio >= 0.5 || velocityX > velocityThreshold)) {
|
222 | 224 | this.openPercentage(100);
|
223 | 225 | }
|
224 |
| - |
| 226 | + |
225 | 227 | // Going left, more than half, or quickly (span open)
|
226 | 228 | else if(direction == 'left' && ratio <= 0 && (ratio <= -0.5 || velocityX > velocityThreshold)) {
|
227 | 229 | this.openPercentage(-100);
|
228 | 230 | }
|
229 |
| - |
| 231 | + |
230 | 232 | // Snap back for safety
|
231 | 233 | else {
|
232 | 234 | this.openPercentage(0);
|
|
0 commit comments