forked from angular/material
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sidenav): add gestures to sidenav to allow dragging the sidenav
Fixes angular#1591 Fixes angular#35
- Loading branch information
1 parent
e519c1b
commit 863fb62
Showing
4 changed files
with
201 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
|
||
<div ng-controller="AppCtrl" layout="column" style="height:500px;" ng-cloak> | ||
|
||
<section layout="row" flex> | ||
|
||
<md-sidenav class="md-sidenav-left md-whiteframe-z2" md-component-id="left"> | ||
|
||
<md-toolbar class="md-theme-light"> | ||
<h1 class="md-toolbar-tools">Drag Enabled</h1> | ||
</md-toolbar> | ||
<md-content ng-controller="LeftCtrl" layout-padding> | ||
<p> | ||
This sidenav is able to be dragged. Through the drag gesture, it's possible to close the sidenav. | ||
</p> | ||
<md-button ng-click="close()" class="md-primary"> | ||
Close Sidenav Left | ||
</md-button> | ||
</md-content> | ||
|
||
</md-sidenav> | ||
|
||
<md-content flex layout-padding> | ||
|
||
<div layout="column" layout-fill layout-align="top center"> | ||
<p> | ||
You can simply close a sidenav by using a gesture. Simply drag the sidenav to close it. | ||
</p> | ||
<p> | ||
The right sidenav allows dragging. | ||
</p> | ||
<p> | ||
The left sidenav is disabled for dragging. | ||
</p> | ||
|
||
<div> | ||
<md-button ng-click="toggleLeft()" | ||
class="md-primary"> | ||
Toggle left | ||
</md-button> | ||
</div> | ||
|
||
<div> | ||
<md-button ng-click="toggleRight()" | ||
ng-hide="isOpenRight()" | ||
class="md-primary"> | ||
Toggle right | ||
</md-button> | ||
</div> | ||
</div> | ||
|
||
<div flex></div> | ||
|
||
</md-content> | ||
|
||
<md-sidenav class="md-sidenav-right md-whiteframe-z2" md-component-id="right" md-disable-drag="true"> | ||
|
||
<md-toolbar class="md-theme-indigo"> | ||
<h1 class="md-toolbar-tools">Drag Disabled</h1> | ||
</md-toolbar> | ||
<md-content layout-padding ng-controller="RightCtrl"> | ||
<md-button ng-click="close()" class="md-primary"> | ||
Close Sidenav Right | ||
</md-button> | ||
<p> | ||
This sidenav disables the dragging gesture. It can be closed through the buttons. | ||
</p> | ||
</md-content> | ||
|
||
</md-sidenav> | ||
|
||
</section> | ||
|
||
</div> |
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,27 @@ | ||
angular | ||
.module('sidenavDemo2', ['ngMaterial']) | ||
.controller('AppCtrl', function ($scope, $timeout, $mdSidenav) { | ||
$scope.toggleLeft = buildToggler('left'); | ||
$scope.toggleRight = buildToggler('right'); | ||
|
||
$scope.isOpenRight = function(){ | ||
return $mdSidenav('right').isOpen(); | ||
}; | ||
|
||
function buildToggler(navID) { | ||
return function() { | ||
$mdSidenav(navID).toggle() | ||
} | ||
} | ||
}) | ||
.controller('LeftCtrl', function ($scope, $timeout, $mdSidenav) { | ||
$scope.close = function () { | ||
$mdSidenav('left').close(); | ||
|
||
}; | ||
}) | ||
.controller('RightCtrl', function ($scope, $timeout, $mdSidenav) { | ||
$scope.close = function () { | ||
$mdSidenav('right').close(); | ||
}; | ||
}); |
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