<!DOCTYPE html>
<html>
<head>
<base href="." />
<script type="text/javascript" charset="utf-8">
window.AngularVersionForThisPlunker = 'latest'
</script>
<title>angular playground</title>
<link rel="stylesheet" href="style.css" />
<link data-require="bootstrap-css@3.3.6" data-semver="3.3.6" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css" />
<script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script>
<script src="https://unpkg.com/zone.js/dist/zone.js"></script>
<script src="https://unpkg.com/zone.js/dist/long-stack-trace-zone.js"></script>
<script src="https://unpkg.com/reflect-metadata@0.1.3/Reflect.js"></script>
<script src="https://unpkg.com/systemjs@0.19.31/dist/system.js"></script>
<script src="config.js"></script>
<script>
System.import('app')
.catch(console.error.bind(console));
</script>
</head>
<body>
<my-app>
loading...
</my-app>
</body>
</html>
/* Styles go here */
.heading{
margin-top:200px;
}
/*----------------------------------- Navigation starts ---------------------------------------*/
.openDrawer{
padding:1%;
color: #000;
position: fixed;
margin: 2%;
font-size: 2em;
cursor: pointer;
z-index: 2;
}
.navigation{
width: 20%;
position: fixed;
top: 0;
height: 100%;
background-color: #000;
z-index: 3;
}
.close-nav{
float: right;
font-size: 2em;
margin: 3%;
color: #fff;
cursor: pointer;
}
.navigation ul{
padding: 10%;
margin-right: 10%;
list-style-type: none;
height: 100%;
}
.navigation li{
height: 5%;
width: 100%;
margin-bottom: 10%;
padding: 5%;
border-bottom: solid 0.5px rgba(255, 255, 255, 0.11);
cursor: pointer;
color: #fff;
}
.navigation li:hover{
border-left: solid 5px rgb(167, 167, 167);
border-bottom: 0px;
color: rgb(167, 167, 167);
}
/*----------------------------------- Navigation ends ---------------------------------------*/
.overlay {
height: 100%;
width: 100%;
position: fixed;
z-index: 1;
left: 0;
top: 0;
background-color: rgba(0,0,0, 0.9);
overflow-x: hidden;
transition: 0.5s;
}
.resource-provider{
text-align:center;
font-weight:800;
}
### Angular Starter Plunker - Typescript
var angularVersion;
if(window.AngularVersionForThisPlunker === 'latest'){
angularVersion = ''; //picks up latest
}
else {
angularVersion = '@' + window.AngularVersionForThisPlunker;
}
System.config({
//use typescript for compilation
transpiler: 'typescript',
//typescript compiler options
typescriptOptions: {
emitDecoratorMetadata: true
},
paths: {
'npm:': 'https://unpkg.com/'
},
//map tells the System loader where to look for things
map: {
'app': './src',
'@angular/core': 'npm:@angular/core'+ angularVersion + '/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common' + angularVersion + '/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler' + angularVersion + '/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser' + angularVersion + '/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic' + angularVersion + '/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http' + angularVersion + '/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router' + angularVersion +'/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms' + angularVersion + '/bundles/forms.umd.js',
'@angular/animations': 'npm:@angular/animations' + angularVersion + '/bundles/animations.umd.js',
'@angular/platform-browser/animations': 'npm:@angular/platform-browser' + angularVersion + '/bundles/platform-browser-animations.umd.js',
'@angular/animations/browser': 'npm:@angular/animations' + angularVersion + '/bundles/animations-browser.umd.js',
'@angular/core/testing': 'npm:@angular/core' + angularVersion + '/bundles/core-testing.umd.js',
'@angular/common/testing': 'npm:@angular/common' + angularVersion + '/bundles/common-testing.umd.js',
'@angular/compiler/testing': 'npm:@angular/compiler' + angularVersion + '/bundles/compiler-testing.umd.js',
'@angular/platform-browser/testing': 'npm:@angular/platform-browser' + angularVersion + '/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic' + angularVersion + '/bundles/platform-browser-dynamic-testing.umd.js',
'@angular/http/testing': 'npm:@angular/http' + angularVersion + '/bundles/http-testing.umd.js',
'@angular/router/testing': 'npm:@angular/router' + angularVersion + '/bundles/router-testing.umd.js',
'tslib': 'npm:tslib@1.6.1',
'rxjs': 'npm:rxjs',
'typescript': 'npm:typescript@2.2.1/lib/typescript.js'
},
//packages defines our app package
packages: {
app: {
main: './main.ts',
defaultExtension: 'ts'
},
rxjs: {
defaultExtension: 'js'
}
}
});
//main entry point
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app';
platformBrowserDynamic().bootstrapModule(AppModule)
//our root app component
import {Component, NgModule, VERSION} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {trigger,state,style,animate,transition,keyframes} from '@angular/animations';
@Component({
selector: 'my-app',
template: `
<div class="openDrawer" (click)="navigationDrawer()">
<span class="glyphicon glyphicon-menu-hamburger"></span>
</div>
<div class="overlay" [@showOverlay]="showOverlay"></div>
<div class="page container">
<div class="row">
<div class="col-md-12">
<h2 class="text-center span6 heading">Navigation drawer using angular 2 animation</h2>
</div>
</div>
<br/>
<div class="resource-provider">Find more cool stuff at <a href="http://www.codershood.info/">www.codershood.info</a></div>
</div>
<div class="navigation" [@navigation]="navigation">
<div class="close-nav" (click)="navigationDrawer()">
<span class="glyphicon glyphicon-menu-left"></span>
</div>
<ul>
<li>Home</li>
<li>Posts</li>
<li>Ideas</li>
<li>Contacts</li>
<li>About</li>
</ul>
</div>
`,
animations:[
trigger('navigation', [
state('true' , style({ left:'-20%'})),
state('false', style({ left:'0%'})),
transition('0 => 1', animate('.2s')),
transition('1 => 0', animate('.2s'))
]),
trigger('showOverlay', [
state('true' , style({ opacity: 1,display:"block" })),
state('false', style({ opacity: 0,display:"none" })),
transition('0 => 1', animate('.2s')),
transition('1 => 0', animate('.5s'))
])
]
})
export class App {
/*---------------------- Navigation Drawer Animation Starts ----------------------*/
navigation:boolean = true;
showOverlay:boolean = false;
navigationDrawer(){
this.navigation = !this.navigation;
this.showOverlay = !this.showOverlay;
}
/*---------------------- Navigation Drawer Animation ends -----------------------*/
}
@NgModule({
imports: [ BrowserModule,BrowserAnimationsModule ],
declarations: [ App ],
bootstrap: [ App ]
})
export class AppModule {}