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

exposeAsideWhen directive bug fix #4163

Merged
merged 1 commit into from
Dec 6, 2015
Merged
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
18 changes: 9 additions & 9 deletions js/angular/directive/exposeAsideWhen.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* the most common use-case. However, for added flexibility, any valid media query could be added
* as the value, such as `(min-width:600px)` or even multiple queries such as
* `(min-width:750px) and (max-width:1200px)`.

* @usage
* ```html
* <ion-side-menus>
Expand All @@ -39,12 +38,21 @@
* For a complete side menu example, see the
* {@link ionic.directive:ionSideMenus} documentation.
*/

IonicModule.directive('exposeAsideWhen', ['$window', function($window) {
return {
restrict: 'A',
require: '^ionSideMenus',
link: function($scope, $element, $attr, sideMenuCtrl) {

// Setup a match media query listener that triggers a ui change only when a change
// in media matching status occurs
var mq = $attr.exposeAsideWhen == 'large' ? '(min-width:768px)' : $attr.exposeAsideWhen;
var mql = $window.matchMedia(mq);
mql.addListener(function() {
onResize();
});

function checkAsideExpose() {
var mq = $attr.exposeAsideWhen == 'large' ? '(min-width:768px)' : $attr.exposeAsideWhen;
sideMenuCtrl.exposeAside($window.matchMedia(mq).matches);
Expand All @@ -61,14 +69,6 @@ IonicModule.directive('exposeAsideWhen', ['$window', function($window) {
}, 300, false);

$scope.$evalAsync(checkAsideExpose);

ionic.on('resize', onResize, $window);

$scope.$on('$destroy', function() {
ionic.off('resize', onResize, $window);
});

}
};
}]);