forked from angular/material
-
Notifications
You must be signed in to change notification settings - Fork 2
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
f6c3b46
commit 550a200
Showing
3 changed files
with
207 additions
and
1 deletion.
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 is disabled for dragging. | ||
</p> | ||
<p> | ||
The left sidenav allows 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,36 @@ | ||
angular | ||
.module('sidenavDemo1', ['ngMaterial']) | ||
.controller('AppCtrl', function ($scope, $timeout, $mdSidenav, $log) { | ||
$scope.toggleLeft = buildToggler('left'); | ||
$scope.toggleRight = buildToggler('right'); | ||
$scope.isOpenRight = function(){ | ||
return $mdSidenav('right').isOpen(); | ||
}; | ||
|
||
function buildToggler(navID) { | ||
return function() { | ||
$mdSidenav(navID) | ||
.toggle() | ||
.then(function () { | ||
$log.debug("toggle " + navID + " is done"); | ||
}); | ||
} | ||
} | ||
}) | ||
.controller('LeftCtrl', function ($scope, $timeout, $mdSidenav, $log) { | ||
$scope.close = function () { | ||
$mdSidenav('left').close() | ||
.then(function () { | ||
$log.debug("close LEFT is done"); | ||
}); | ||
|
||
}; | ||
}) | ||
.controller('RightCtrl', function ($scope, $timeout, $mdSidenav, $log) { | ||
$scope.close = function () { | ||
$mdSidenav('right').close() | ||
.then(function () { | ||
$log.debug("close RIGHT is done"); | ||
}); | ||
}; | ||
}); |
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