Skip to content

Commit

Permalink
feat: sub navigation animations
Browse files Browse the repository at this point in the history
  • Loading branch information
tomastrajan committed Jul 25, 2017
1 parent 285ef5d commit be7a040
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 28 deletions.
Empty file modified CHANGELOG.md
100755 → 100644
Empty file.
Empty file modified package.json
100755 → 100644
Empty file.
12 changes: 7 additions & 5 deletions src/app/core/animations/router.transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,30 @@ import {
stagger
} from '@angular/animations';

export const ANIMATE_ON_ROUTE_ENTER = 'route-enter-staggered';

export const routerTransition = trigger('routerTransition', [
transition('* <=> *', [
query(':enter, :leave',
style({ position: 'fixed', width: '100%' }),
{ optional: true }),
query(':enter .route-enter-staggered',
query(':enter .' + ANIMATE_ON_ROUTE_ENTER,
style({ opacity: 0 }),
{ optional: true }),
group([
query(':enter', [
style({ transform: 'translateY(-5%)', opacity: 0 }),
style({ transform: 'translateY(-3%)', opacity: 0 }),
animate('0.5s 0.5s ease-in-out',
style({ transform: 'translateY(0%)', opacity: 1 }))
], { optional: true }),
query(':leave', [
style({ transform: 'translateY(0%)', opacity: 1 }),
animate('0.2s ease-in-out',
style({ transform: 'translateY(-5%)', opacity: 0 }))
style({ transform: 'translateY(-3%)', opacity: 0 }))
], { optional: true })
]),
query(':enter .route-enter-staggered', stagger(100, [
style({ transform: 'translateY(10%)', opacity: 0 }),
query(':enter .' + ANIMATE_ON_ROUTE_ENTER, stagger(100, [
style({ transform: 'translateY(15%)', opacity: 0 }),
animate('0.5s ease-in-out',
style({ transform: 'translateY(0%)', opacity: 1 })),
]), { optional: true }),
Expand Down
4 changes: 3 additions & 1 deletion src/app/examples/examples/examples.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
{{e.label}}
</a>
</nav>
<router-outlet></router-outlet>
<div [@routerTransition]="o.isActivated && o.activatedRoute.routeConfig.path">
<router-outlet #o="outlet"></router-outlet>
</div>
5 changes: 4 additions & 1 deletion src/app/examples/examples/examples.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Component, OnInit } from '@angular/core';

import { routerTransition } from '@app/core';

@Component({
selector: 'anms-examples',
templateUrl: './examples.component.html',
styleUrls: ['./examples.component.scss']
styleUrls: ['./examples.component.scss'],
animations: [routerTransition]
})
export class ExamplesComponent implements OnInit {

Expand Down
2 changes: 1 addition & 1 deletion src/app/examples/todos/todos.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h2>
</md-chip>
</md-chip-list>
</h2>
<md-card *ngFor="let todo of filteredTodos" class="todo">
<md-card *ngFor="let todo of filteredTodos" class="todo" [ngClass]="animateOnRouteEnter">
<md-checkbox class="todo-done" [checked]="todo.done" (change)="onToggleTodo(todo)"></md-checkbox>
<span class="todo-label" (click)="onToggleTodo(todo)">{{todo.name}}</span>
</md-card>
Expand Down
3 changes: 3 additions & 0 deletions src/app/examples/todos/todos.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Subject } from 'rxjs/Subject';
import 'rxjs/add/operator/takeUntil';
import 'rxjs/add/operator/map';

import { ANIMATE_ON_ROUTE_ENTER } from '@app/core';

import {
actionAddTodo,
actionPersistTodos,
Expand All @@ -24,6 +26,7 @@ export class TodosComponent implements OnInit, OnDestroy {

private unsubscribe$: Subject<void> = new Subject<void>();

animateOnRouteEnter = ANIMATE_ON_ROUTE_ENTER;
todos: any;
newTodo = '';

Expand Down
14 changes: 7 additions & 7 deletions src/app/static/about/about.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
<div class="container">
<h1>Angular ngRx Material Starter</h1>
<div class="actions">
<a md-raised-button color="primary" routerLink="../features"
class="route-enter-staggered">
<a [ngClass]="animateOnRouteEnter"
md-raised-button color="primary" routerLink="../features">
Check Features
</a>
<a md-raised-button color="accent" routerLink="../examples"
class="route-enter-staggered">
[ngClass]="animateOnRouteEnter">
Check Examples
</a>
<a md-raised-button routerLink="../settings"
class="route-enter-staggered">
[ngClass]="animateOnRouteEnter">
Change Theme
</a>
<span class="route-enter-staggered">or</span>
<span [ngClass]="animateOnRouteEnter">or</span>
<a md-raised-button
class="route-enter-staggered"
[ngClass]="animateOnRouteEnter"
target="_blank"
href="https://medium.com/@tomastrajan/the-complete-guide-to-angular-material-themes-4d165a9d24d1">
<i class="fa fa-medium"></i> Check Blog Post
</a>
</div>
<div class="get-started route-enter-staggered">
<div class="get-started" [ngClass]="animateOnRouteEnter">
<h2>Getting started</h2>
<code>git clone
https://github.com/tomastrajan/angular-ngrx-material-starter.git
Expand Down
7 changes: 4 additions & 3 deletions src/app/static/about/about.component.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { Component, OnInit } from '@angular/core';

import { ANIMATE_ON_ROUTE_ENTER } from '@app/core';

@Component({
selector: 'anms-about',
templateUrl: './about.component.html',
styleUrls: ['./about.component.scss']
})
export class AboutComponent implements OnInit {

intro = require('../../../assets/intro.jpg');
animateOnRouteEnter = ANIMATE_ON_ROUTE_ENTER;

constructor() { }

ngOnInit() {
}
ngOnInit() {}

}
16 changes: 8 additions & 8 deletions src/app/static/features/features.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h1 class="main-heading">Features</h1>
</div>
</div>
<div class="row align-items-end">
<div class="col-md-6 col-lg-4 route-enter-staggered">
<div class="col-md-6 col-lg-4" [ngClass]="animateOnRouteEnter">
<md-card>
<md-card-title><code>{{versions.angular}}</code>Angular</md-card-title>
<md-card-subtitle>
Expand All @@ -21,7 +21,7 @@ <h1 class="main-heading">Features</h1>
</md-card-actions>
</md-card>
</div>
<div class="col-md-6 col-lg-4 route-enter-staggered">
<div class="col-md-6 col-lg-4" [ngClass]="animateOnRouteEnter">
<md-card>
<md-card-title><code>{{versions.material}}</code>Angular Material</md-card-title>
<md-card-subtitle>
Expand All @@ -37,7 +37,7 @@ <h1 class="main-heading">Features</h1>
</md-card-actions>
</md-card>
</div>
<div class="col-md-6 col-lg-4 route-enter-staggered">
<div class="col-md-6 col-lg-4" [ngClass]="animateOnRouteEnter">
<md-card>
<md-card-title><code>{{versions.angularCli}}</code>Angular Cli</md-card-title>
<md-card-subtitle>
Expand All @@ -53,7 +53,7 @@ <h1 class="main-heading">Features</h1>
</md-card-actions>
</md-card>
</div>
<div class="col-md-6 col-lg-4 route-enter-staggered">
<div class="col-md-6 col-lg-4" [ngClass]="animateOnRouteEnter">
<md-card>
<md-card-title><code>{{versions.ngrx}}</code>ngRx</md-card-title>
<md-card-subtitle>
Expand All @@ -69,7 +69,7 @@ <h1 class="main-heading">Features</h1>
</md-card-actions>
</md-card>
</div>
<div class="col-md-6 col-lg-4 route-enter-staggered">
<div class="col-md-6 col-lg-4" [ngClass]="animateOnRouteEnter">
<md-card>
<md-card-title><code>{{versions.rxjs}}</code>RxJS</md-card-title>
<md-card-subtitle>
Expand All @@ -85,7 +85,7 @@ <h1 class="main-heading">Features</h1>
</md-card-actions>
</md-card>
</div>
<div class="col-md-6 col-lg-4 route-enter-staggered">
<div class="col-md-6 col-lg-4" [ngClass]="animateOnRouteEnter">
<md-card>
<md-card-title><code>{{versions.bootstrap}}</code>Bootstrap</md-card-title>
<md-card-subtitle>
Expand All @@ -101,7 +101,7 @@ <h1 class="main-heading">Features</h1>
</md-card-actions>
</md-card>
</div>
<div class="col-md-6 col-lg-4 route-enter-staggered">
<div class="col-md-6 col-lg-4" [ngClass]="animateOnRouteEnter">
<md-card>
<md-card-title>Themes</md-card-title>
<md-card-subtitle>Flexible theming support for provided and custom components</md-card-subtitle>
Expand All @@ -115,7 +115,7 @@ <h1 class="main-heading">Features</h1>
</md-card-actions>
</md-card>
</div>
<div class="col-md-6 col-lg-4 route-enter-staggered">
<div class="col-md-6 col-lg-4" [ngClass]="animateOnRouteEnter">
<md-card>
<md-card-title>Lazy loading</md-card-title>
<md-card-subtitle>Faster startup time with lazy loaded feature modules</md-card-subtitle>
Expand Down
5 changes: 3 additions & 2 deletions src/app/static/features/features.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';

import { environment as env } from '@env/environment';
import { ANIMATE_ON_ROUTE_ENTER } from '@app/core';

@Component({
selector: 'anms-features',
Expand All @@ -9,10 +10,10 @@ import { environment as env } from '@env/environment';
})
export class FeaturesComponent implements OnInit {

animateOnRouteEnter = ANIMATE_ON_ROUTE_ENTER;
versions = env.versions;

ngOnInit() {
}
ngOnInit() {}

openLink(link: string) {
window.open(link, '_blank');
Expand Down

0 comments on commit be7a040

Please sign in to comment.