A Pen by Erik Martino Hansen on CodePen.
Created
February 6, 2016 19:17
-
-
Save xylifyx2/aa2e7a2798828c65ff71 to your computer and use it in GitHub Desktop.
Basic Usage
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
<div ng-controller="AppCtrl" layout="column" style="height:500px;" ng-cloak="" class="sidenavdemoBasicUsage" ng-app="MyApp"> | |
<section layout="row" flex=""> | |
<md-sidenav class="md-sidenav-left md-whiteframe-z2" md-component-id="left" md-is-locked-open="$mdMedia('gt-md')"> | |
<md-toolbar class="md-theme-indigo"> | |
<h1 class="md-toolbar-tools">Sidenav Left</h1> | |
</md-toolbar> | |
<md-content layout-padding="" ng-controller="LeftCtrl"> | |
<md-button ng-click="close()" class="md-primary" hide-gt-md=""> | |
Close Sidenav Left | |
</md-button> | |
<p hide-md="" show-gt-md=""> | |
This sidenav is locked open on your device. To go back to the default behavior, narrow your display. | |
</p> | |
</md-content> | |
</md-sidenav> | |
<md-content flex="" layout-padding=""> | |
<div layout="column" layout-fill="" layout-align="top center"> | |
<p> | |
The left sidenav will 'lock open' on a medium (>=960px wide) device. | |
</p> | |
<p> | |
The right sidenav will focus on a specific child element. | |
</p> | |
<div> | |
<md-button ng-click="toggleLeft()" class="md-primary" hide-gt-md=""> | |
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-toolbar class="md-theme-light"> | |
<h1 class="md-toolbar-tools">Sidenav Right</h1> | |
</md-toolbar> | |
<md-content ng-controller="RightCtrl" layout-padding=""> | |
<form> | |
<md-input-container> | |
<label for="testInput">Test input</label> | |
<input type="text" id="testInput" ng-model="data" md-autofocus=""> | |
</md-input-container> | |
</form> | |
<md-button ng-click="close()" class="md-primary"> | |
Close Sidenav Right | |
</md-button> | |
</md-content> | |
</md-sidenav> | |
</section> | |
</div> | |
<!-- | |
Copyright 2016 Google Inc. All Rights Reserved. | |
Use of this source code is governed by an MIT-style license that can be in foundin the LICENSE file at http://material.angularjs.org/license. | |
--> |
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
angular | |
.module('MyApp', ['ngMaterial', 'ngMessages', 'material.svgAssetsCache']) | |
.controller('AppCtrl', function($scope, $timeout, $mdSidenav, $log) { | |
$scope.toggleLeft = buildDelayedToggler('left'); | |
$scope.toggleRight = buildToggler('right'); | |
$scope.isOpenRight = function() { | |
return $mdSidenav('right').isOpen(); | |
}; | |
/** | |
* Supplies a function that will continue to operate until the | |
* time is up. | |
*/ | |
function debounce(func, wait, context) { | |
var timer; | |
return function debounced() { | |
var context = $scope, | |
args = Array.prototype.slice.call(arguments); | |
$timeout.cancel(timer); | |
timer = $timeout(function() { | |
timer = undefined; | |
func.apply(context, args); | |
}, wait || 10); | |
}; | |
} | |
/** | |
* Build handler to open/close a SideNav; when animation finishes | |
* report completion in console | |
*/ | |
function buildDelayedToggler(navID) { | |
return debounce(function() { | |
$mdSidenav(navID) | |
.toggle() | |
.then(function() { | |
$log.debug("toggle " + navID + " is done"); | |
}); | |
}, 200); | |
} | |
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"); | |
}); | |
}; | |
}); | |
/** | |
Copyright 2016 Google Inc. All Rights Reserved. | |
Use of this source code is governed by an MIT-style license that can be in foundin the LICENSE file at http://material.angularjs.org/license. | |
**/ |
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
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script> | |
<script src="http://ngmaterial.assets.s3.amazonaws.com/svg-assets-cache.js"></script> | |
<script src="https://cdn.gitcdn.xyz/cdn/angular/bower-material/v1.0.5/angular-material.js"></script> |
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
/* | |
Copyright 2016 Google Inc. All Rights Reserved. | |
Use of this source code is governed by an MIT-style license that can be in foundin the LICENSE file at http://material.angularjs.org/license. | |
*/ |
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
<link href="https://cdn.gitcdn.xyz/cdn/angular/bower-material/v1.0.5/angular-material.css" rel="stylesheet" /> | |
<link href="https://material.angularjs.org/1.0.5/docs.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment