mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
4
js/angular/controller/sideMenuController.js
vendored
4
js/angular/controller/sideMenuController.js
vendored
@@ -50,6 +50,7 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody) {
|
||||
* Toggle the left menu to open 100%
|
||||
*/
|
||||
self.toggleLeft = function(shouldOpen) {
|
||||
if(isAsideExposed) return;
|
||||
var openAmount = self.getOpenAmount();
|
||||
if (arguments.length === 0) {
|
||||
shouldOpen = openAmount <= 0;
|
||||
@@ -66,6 +67,7 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody) {
|
||||
* Toggle the right menu to open 100%
|
||||
*/
|
||||
self.toggleRight = function(shouldOpen) {
|
||||
if(isAsideExposed) return;
|
||||
var openAmount = self.getOpenAmount();
|
||||
if (arguments.length === 0) {
|
||||
shouldOpen = openAmount >= 0;
|
||||
@@ -82,7 +84,6 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody) {
|
||||
* Close all menus.
|
||||
*/
|
||||
self.close = function() {
|
||||
if(isAsideExposed) return;
|
||||
self.openPercentage(0);
|
||||
};
|
||||
|
||||
@@ -258,6 +259,7 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody) {
|
||||
};
|
||||
|
||||
self.exposeAside = function(shouldExposeAside) {
|
||||
self.close();
|
||||
isAsideExposed = shouldExposeAside;
|
||||
|
||||
// set the left marget width if it should be exposed
|
||||
|
||||
1
js/angular/directive/sideMenuContent.js
vendored
1
js/angular/directive/sideMenuContent.js
vendored
@@ -145,6 +145,7 @@ function($timeout, $ionicGesture, $window) {
|
||||
}),
|
||||
setMarginLeft: ionic.animationFrameThrottle(function(amount) {
|
||||
if(amount) {
|
||||
amount = parseInt(amount, 10);
|
||||
$element[0].style[ionic.CSS.TRANSFORM] = 'translate3d(' + amount + 'px,0,0)';
|
||||
$element[0].style.width = ($window.innerWidth - amount) + 'px';
|
||||
content.offsetX = amount;
|
||||
|
||||
@@ -47,7 +47,9 @@ describe('$ionicSideMenus controller', function() {
|
||||
el: document.createElement('div'),
|
||||
isEnabled: true
|
||||
});
|
||||
ctrl.setContent(new Controller({ el: document.createElement('div') }));
|
||||
var content = new Controller({ el: document.createElement('div') });
|
||||
content.setMarginLeft = function(){};
|
||||
ctrl.setContent(content);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -104,6 +106,34 @@ describe('$ionicSideMenus controller', function() {
|
||||
expect(ctrl.getOpenPercentage()).toEqual(0);
|
||||
});
|
||||
|
||||
it('should not toggle left with exposed aside', function() {
|
||||
expect(ctrl.getOpenPercentage()).toEqual(0);
|
||||
ctrl.exposeAside(true);
|
||||
ctrl.toggleLeft();
|
||||
expect(ctrl.getOpenPercentage()).toEqual(0);
|
||||
});
|
||||
|
||||
it('should not toggle right with exposed aside', function() {
|
||||
expect(ctrl.getOpenPercentage()).toEqual(0);
|
||||
ctrl.exposeAside(true);
|
||||
ctrl.toggleRight();
|
||||
expect(ctrl.getOpenPercentage()).toEqual(0);
|
||||
});
|
||||
|
||||
it('should close left menu on expose aside', function() {
|
||||
ctrl.toggleLeft();
|
||||
expect(ctrl.getOpenPercentage()).toEqual(100);
|
||||
ctrl.exposeAside(true);
|
||||
expect(ctrl.getOpenPercentage()).toEqual(0);
|
||||
});
|
||||
|
||||
it('should close right menu on expose aside', function() {
|
||||
ctrl.toggleRight();
|
||||
expect(ctrl.getOpenPercentage()).toEqual(-100);
|
||||
ctrl.exposeAside(true);
|
||||
expect(ctrl.getOpenPercentage()).toEqual(0);
|
||||
});
|
||||
|
||||
it('should toggle right', function() {
|
||||
ctrl.toggleRight();
|
||||
expect(ctrl.getOpenPercentage()).toEqual(-100);
|
||||
@@ -219,9 +249,6 @@ describe('$ionicSideMenus controller', function() {
|
||||
expect(ctrl.getOpenPercentage()).toEqual(-100);
|
||||
});
|
||||
|
||||
it('Should test content drag events', function() {
|
||||
});
|
||||
|
||||
it('should register with backButton on open and dereg on close', inject(function($ionicPlatform) {
|
||||
var openAmount = 0;
|
||||
var deregSpy = jasmine.createSpy('deregister');
|
||||
|
||||
Reference in New Issue
Block a user