Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'menu-left-open' and 'menu-right-open' classes #1072

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion js/controllers/sideMenuController.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,21 @@
},

/**
* Open the menu with a given percentage amount.
* Open the menu with a given percentage amount and add a corresponding class to the content element.
* @param {float} percentage The percentage (positive or negative for left/right) to open the menu.
*/
openPercentage: function(percentage) {
var p = percentage / 100;

// Add/remove class 'menu-left-open' or 'menu-right-open' on content element
if (this.content && this.content.el) {
if (percentage > 0 || percentage < 0) {
this.content.el.classList.add('menu-' + ((percentage > 0) ? 'left' : 'right') + '-open');
} else {
this.content.el.classList.remove('menu-' + ((this.getOpenPercentage() > 0) ? 'left' : 'right') + '-open');
}
}

if(this.left && percentage >= 0) {
this.openAmount(this.left.width * p);
} else if(this.right && percentage < 0) {
Expand Down
1 change: 1 addition & 0 deletions js/ext/angular/src/directive/ionicSideMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ angular.module('ionic.ui.sideMenu', ['ionic.service.gesture', 'ionic.service.vie
var releaseGesture = $ionicGesture.on('release', dragReleaseFn, $element);

sideMenuCtrl.setContent({
el: $element[0],
onDrag: function(e) {},
endDrag: function(e) {},
getTranslateX: function() {
Expand Down
4 changes: 4 additions & 0 deletions js/ext/angular/test/directive/ionicSideMenu.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ describe('Ionic Side Menu Directive', function () {
expect(sideMenuCtrl.left.width).toBe(222);
expect(sideMenuCtrl.left.el.style.width).toBe('222px');
});

it('should publish the content element to it\'s public API', function () {
expect(sideMenuCtrl.content.el).toBeTruthy();
});
});

describe('menuToggle directive', function() {
Expand Down