-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(splitView): expose side menu on large viewport
Ability to keep a left menu exposed on larger viewports, such as a landscape tablet. Added the `expose-aside-menu` attribute directive.
- Loading branch information
1 parent
853fad1
commit b69aa54
Showing
11 changed files
with
216 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* @ngdoc directive | ||
* @name exposeAsideWhen | ||
* @module ionic | ||
* @restrict A | ||
* @parent ionic.directive:ionSideMenus | ||
* | ||
* @description | ||
* It is common for a tablet application to hide a menu when in portrait mode, but to show the | ||
* same menu on the left side when the tablet is in landscape mode. The `exposeAsideWhen` attribute | ||
* directive can be used to accomplish a similar interface. | ||
* | ||
* By default, side menus are hidden underneath its side menu content, and can be opened by either | ||
* swiping the content left or right, or toggling a button to show the side menu. However, by adding the | ||
* `exposeAsideWhen` attribute directive to an {@link ionic.directive:ionSideMenu} element directive, | ||
* a side menu can be given instructions on "when" the menu should be exposed (always viewable). For | ||
* example, the `expose-aside-when="large"` attribute will keep the side menu hidden when the viewport's | ||
* width is less than `768px`, but when the viewport's width is `768px` or greater, the menu will then | ||
* always be shown and can no longer be opened or closed like it could when it was hidden for smaller | ||
* viewports. | ||
* | ||
* Using `large` as the attribute's value is a shortcut value to `(min-width:768px)` since it is | ||
* 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> | ||
* <!-- Center content --> | ||
* <ion-side-menu-content> | ||
* </ion-side-menu-content> | ||
* | ||
* <!-- Left menu --> | ||
* <ion-side-menu expose-aside-when="large"> | ||
* </ion-side-menu> | ||
* </ion-side-menus> | ||
* ``` | ||
* 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) { | ||
|
||
function checkAsideExpose() { | ||
var mq = $attr.exposeAsideWhen == 'large' ? '(min-width:768px)' : $attr.exposeAsideWhen; | ||
sideMenuCtrl.exposeAside( $window.matchMedia(mq).matches ); | ||
sideMenuCtrl.activeAsideResizing(false); | ||
} | ||
|
||
function onResize() { | ||
sideMenuCtrl.activeAsideResizing(true); | ||
debouncedCheck(); | ||
} | ||
|
||
var debouncedCheck = ionic.debounce(function() { | ||
$scope.$apply(function(){ | ||
checkAsideExpose(); | ||
}); | ||
}, 300, false); | ||
|
||
checkAsideExpose(); | ||
|
||
ionic.on('resize', onResize, $window); | ||
|
||
$scope.$on('$destroy', function(){ | ||
ionic.off('resize', onResize, $window); | ||
}); | ||
|
||
} | ||
}; | ||
}]); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ | |
"list", | ||
"badge", | ||
"slide-box", | ||
"split-pane", | ||
|
||
// Forms | ||
"form", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.