Skip to content

Commit

Permalink
chore(*): adding public folder Tue Feb 13 20:54:17 CET 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
0x-r4bbit committed Feb 13, 2024
0 parents commit ab8cc7f
Show file tree
Hide file tree
Showing 1,330 changed files with 37,850 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions 2015-06-06-ng-messages-revisited/index.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions 21790b11d643613a43a1039157bae9a3/git-detached-head-4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions 2dd8e9b119adc196261798a139c683ab/injector-tree-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions 404.html

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions 404/index.html

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions 44820d092a70af998a5c33b718f3969d/cd-tree-7.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions 477bd3a6ea642886f1669072185d43e3/transient-dependencies-4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions 6f49d0871e4dd635846506901215239e/upgrade-2-phases-3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions 70c21bbe865416334d97588bb4da9a5a/git-branching-new-branch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions 7ac7580fb5b9791eca7c265ce8f60ab6/git-detached-head-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions 7cd38f19f51a597d970346585e57a9c6/injector-tree-3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions 8393e4d5673c51a3779a96651966d72d/cd-tree-10.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions 9f0fd18e6f0ea759062f1317f6f9d73f/git-detached-head-3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blog.thoughtram.io
4 changes: 4 additions & 0 deletions a77dcff322d4e61495ce23c050433bf8/i18n-process.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
585 changes: 585 additions & 0 deletions all/index.html

Large diffs are not rendered by default.

139 changes: 139 additions & 0 deletions angular/2015/03/21/angular-and-i18n-the-new-world.html

Large diffs are not rendered by default.

235 changes: 235 additions & 0 deletions angular/2015/03/27/building-a-zippy-component-in-angular-2.html

Large diffs are not rendered by default.

244 changes: 244 additions & 0 deletions angular/2015/04/09/developing-a-tabs-component-in-angular-2.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

100 changes: 100 additions & 0 deletions angular/2015/05/09/writing-angular-2-code-in-es5.html

Large diffs are not rendered by default.

298 changes: 298 additions & 0 deletions angular/2015/05/18/dependency-injection-in-angular-2.html

Large diffs are not rendered by default.

214 changes: 214 additions & 0 deletions angular/2015/06/16/routing-in-angular-2.html

Large diffs are not rendered by default.

117 changes: 117 additions & 0 deletions angular/2015/06/25/styling-angular-2-components.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

146 changes: 146 additions & 0 deletions angular/2015/06/29/shadow-dom-strategies-in-angular2.html

Large diffs are not rendered by default.

104 changes: 104 additions & 0 deletions angular/2015/07/06/even-better-es5-code-for-angular-2.html

Large diffs are not rendered by default.

112 changes: 112 additions & 0 deletions angular/2015/07/07/service-vs-factory-once-and-for-all.html

Large diffs are not rendered by default.

137 changes: 137 additions & 0 deletions angular/2015/08/11/angular-2-template-syntax-demystified-part-1.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

211 changes: 211 additions & 0 deletions angular/2015/09/03/forward-references-in-angular-2.html

Large diffs are not rendered by default.

147 changes: 147 additions & 0 deletions angular/2015/09/17/resolve-service-dependencies-in-angular-2.html

Large diffs are not rendered by default.

235 changes: 235 additions & 0 deletions angular/2015/10/24/upgrading-apps-to-angular-2-using-ngupgrade.html

Large diffs are not rendered by default.

112 changes: 112 additions & 0 deletions angular/2015/11/16/multiple-transclusion-and-named-slots.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

177 changes: 177 additions & 0 deletions angular/2016/01/06/taking-advantage-of-observables-in-angular2.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

151 changes: 151 additions & 0 deletions angular/2016/01/22/understanding-zones.html

Large diffs are not rendered by default.

141 changes: 141 additions & 0 deletions angular/2016/02/01/zones-in-angular-2.html

Large diffs are not rendered by default.

225 changes: 225 additions & 0 deletions angular/2016/02/22/angular-2-change-detection-explained.html

Large diffs are not rendered by default.

288 changes: 288 additions & 0 deletions angular/2016/03/14/custom-validators-in-angular-2.html

Large diffs are not rendered by default.

224 changes: 224 additions & 0 deletions angular/2016/03/21/template-driven-forms-in-angular-2.html

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions angular/2016/05/13/angular-2-providers-using-map-literals.html

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions angular/2016/05/16/exploring-rx-operators-map.html

Large diffs are not rendered by default.

175 changes: 175 additions & 0 deletions angular/2016/05/23/opaque-tokens-in-angular-2.html

Large diffs are not rendered by default.

292 changes: 292 additions & 0 deletions angular/2016/06/08/component-relative-paths-in-angular-2.html

Large diffs are not rendered by default.

239 changes: 239 additions & 0 deletions angular/2016/06/14/routing-in-angular-2-revisited.html

Large diffs are not rendered by default.

228 changes: 228 additions & 0 deletions angular/2016/06/16/cold-vs-hot-observables.html

Large diffs are not rendered by default.

207 changes: 207 additions & 0 deletions angular/2016/06/22/model-driven-forms-in-angular-2.html

Large diffs are not rendered by default.

123 changes: 123 additions & 0 deletions angular/2016/07/18/guards-in-angular-2.html

Large diffs are not rendered by default.

493 changes: 493 additions & 0 deletions angular/2016/07/27/custom-form-controls-in-angular-2.html

Large diffs are not rendered by default.

91 changes: 91 additions & 0 deletions angular/2016/09/14/bypassing-providers-in-angular-2.html

Large diffs are not rendered by default.

121 changes: 121 additions & 0 deletions angular/2016/09/15/angular-2-final-is-out.html

Large diffs are not rendered by default.

247 changes: 247 additions & 0 deletions angular/2016/09/16/angular-2-animation-important-concepts.html

Large diffs are not rendered by default.

201 changes: 201 additions & 0 deletions angular/2016/10/10/resolving-route-data-in-angular-2.html

Large diffs are not rendered by default.

128 changes: 128 additions & 0 deletions angular/2016/10/13/two-way-data-binding-in-angular-2.html

Large diffs are not rendered by default.

279 changes: 279 additions & 0 deletions angular/2016/11/28/testing-services-with-http-in-angular-2.html

Large diffs are not rendered by default.

651 changes: 651 additions & 0 deletions angular/2016/12/27/angular-2-advance-testing-with-custom-matchers.html

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions angular/2017/01/09/a-revamped-angular-master-class.html

Large diffs are not rendered by default.

359 changes: 359 additions & 0 deletions angular/2017/02/02/making-your-angular-app-fast.html

Large diffs are not rendered by default.

166 changes: 166 additions & 0 deletions angular/2017/02/21/using-zones-in-angular-for-better-performance.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions angular/2017/05/08/angular-master-class-redux-and-ngrx.html

Large diffs are not rendered by default.

491 changes: 491 additions & 0 deletions angular/2017/05/23/custom-themes-with-angular-material.html

Large diffs are not rendered by default.

419 changes: 419 additions & 0 deletions angular/2017/07/26/a-web-animations-deep-dive-with-angular.html

Large diffs are not rendered by default.

276 changes: 276 additions & 0 deletions angular/2017/11/13/easy-dialogs-with-angular-material.html

Large diffs are not rendered by default.

380 changes: 380 additions & 0 deletions angular/2017/11/20/custom-overlays-with-angulars-cdk.html

Large diffs are not rendered by default.

330 changes: 330 additions & 0 deletions angular/2017/11/27/custom-overlays-with-angulars-cdk-part-two.html

Large diffs are not rendered by default.

706 changes: 706 additions & 0 deletions angular/2018/03/05/advanced-caching-with-rxjs.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

111 changes: 111 additions & 0 deletions angular2/2015/11/23/multi-providers-in-angular-2.html

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions angularjs/2014/10/14/exploring-angular-1.3-one-time-bindings.html

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions angularjs/2014/10/19/exploring-angular-1.3-ng-model-options.html

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions angularjs/2014/11/06/exploring-angular-1.3-angular-hint.html

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions angularjs/2014/11/19/exploring-angular-1.3-stateful-filters.html

Large diffs are not rendered by default.

123 changes: 123 additions & 0 deletions angularjs/2014/12/18/exploring-angular-1.3-es6-style-promises.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

200 changes: 200 additions & 0 deletions angularjs/2015/01/02/exploring-angular-1.3-bindToController.html

Large diffs are not rendered by default.

147 changes: 147 additions & 0 deletions angularjs/2015/01/11/exploring-angular-1.3-validators-pipeline.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

162 changes: 162 additions & 0 deletions angularjs/2015/01/23/exploring-angular-1.3-ngMessages.html

Large diffs are not rendered by default.

204 changes: 204 additions & 0 deletions angularjs/2015/02/19/futuristic-routing-in-angular.html

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions angularjs/2015/02/21/around-the-globe.html

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions angularjs/2015/03/08/joining-betahaus-education.html

Large diffs are not rendered by default.

102 changes: 102 additions & 0 deletions angularjs/2016/03/29/exploring-angular-1.5-lifecycle-hooks.html

Large diffs are not rendered by default.

148 changes: 148 additions & 0 deletions angularjs/es6/2015/01/23/exploring-angular-1.3-using-es6.html

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions annoucements/2015/06/17/anouncing-hanovers-second-rust-meetup.html

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions announcements/2014/06/06/we-are-thoughtram.html

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions announcements/2014/06/23/announcing-our-first-workshop.html

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions announcements/2014/07/04/tickets-are-on-sale-now.html

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions announcements/2014/07/05/git-ninya-class-comes-to-istanbul.html

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions announcements/2014/11/02/git-ninja-class-in-amsterdam.html

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions announcements/2015/04/19/upcoming-events-in-2015.html

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions announcements/2015/05/08/speaking-at-code-talks.html

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions announcements/2015/05/11/sponsoring-angularconnect.html

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions announcements/2015/08/31/going-full-time.html

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions announcements/2015/09/14/angular-training-day-bangkok.html

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions announcements/2015/10/08/pascal-becomes-a-gde.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions announcements/2015/11/19/how-we-run-trainings.html

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions announcements/2015/12/21/introducing-angular-2-master-class.html

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions announcements/2015/12/31/angular2-master-class-at-ng-nl.html

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions announcements/2016/02/10/sponsoring-angularconnect-again.html

Large diffs are not rendered by default.

91 changes: 91 additions & 0 deletions announcements/2016/04/15/updates-and-announcements.html

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions announcements/2016/05/19/thomas-joins-thoughtram.html

Large diffs are not rendered by default.

131 changes: 131 additions & 0 deletions announcements/2016/06/23/updates-and-announcements.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions announcements/2017/02/09/dominic-joins-thoughtram.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions announcements/2019/09/02/more-GDE-power-at-thoughtram.html

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions announcements/2024/02/13/farewell.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions app-db11fdec89ef44788bcc.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app-db11fdec89ef44788bcc.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,339 @@
---
layout: post
title: Angular Animations - Foundation Concepts
date: 2016-09-16T00:00:00.000Z
update_date: 2017-04-01T00:00:00.000Z
imageUrl: ../assets/images/banner/angular-2-component-animations.jpg
summary: >-
Animation in Angular is now easy and more intuitive... Learn foundational
animation concepts and start animating your Angular components!
categories:
- angular
tags:
- angular2
- animation
- components
- relative paths
topic: components
author: thomas_burleson
related_posts:
- Component-Relative Paths in Angular
- RxJS Master Class and courseware updates
- Advanced caching with RxJS
- Custom Overlays with Angular's CDK - Part 2
- Custom Overlays with Angular's CDK
- Easy Dialogs with Angular Material
related_videos:
- '175255006'
- '193524896'
- '189792758'
- '189785428'
- '175218351'
- '189618526'

---

Animations features often are scary goals for developers. And Angular's doctrine

> "... controllers should not directly modify DOM elements!"
made Animation features intimidating as hell. But **Angular animations are not scary!** Templates are closely associated/integrated with `@Component`. We will notice that animations following a similar pattern.

Let's build a component that hides and shows its contents, uses fade animation effects, and allows external components to easily trigger those fade effects.

### Our Scenario

Here is a simple Angular component with hide and show features. This sample, however, does not have animations (yet):

```js
@Component({
selector: 'my-fader',
template: `
<div *ngIf="visibility == 'shown'" >
<ng-content></ng-content>
Can you see me?
</div>
`
})
export class MyComponent implements OnChanges {
visibility = 'shown';

@Input() isVisible : boolean = true;

ngOnChanges() {
this.visibility = this.isVisible ? 'shown' : 'hidden';
}
}
```

This component simply publishes an `@Input() isVisible` property; which allows other external components to show/hide the text content... without any animations.

### Enable Animations Module

Since Angular 4.x, there's a new module `BrowserAnimationsModule` that introduces all animation capabilities. That's why we first have add that to our application module's `imports` like this:

```js
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

@NgModule({
imports: [
...
BrowserAnimationsModule
]
...
})
export class AppModule {}
```

Once that is done, we can use any kind of animation API in our application. If we want to use animation function like `trigger()` or `state()`, we need to import them also from `'@angular/platform-browser/animations'` instead of `'@angular/core'`.

### Configure Component Animations

We want the `my-fader` component to **fade-in** or **fade-out** its text content. And we want to *animate* those fades effects.

To start animating, let's first add animation metadata to our component.

```js
@Component({
...,
template : ``,
animations: [
...
]
)]
class MyComponent() { ... }
```
Above we show that the `animations` metadata property is defined in the `@Component` decorator. Just like `template` metadata property!
Since our component has a `visibility` property whose state can change between `shown` and `hidden`, let’s configure animations to trigger and animate during each value change.
```js
animations: [
trigger('visibilityChanged', [
state('shown' , style({ opacity: 1 })),
state('hidden', style({ opacity: 0 }))
])
]
```
Before we add more metadata, let's talk about the syntax above. What does it mean... and why is this syntax used?
The techno-speak above is saying that when the `visibilityChanged` property changes and the value `== shown`, then the target element opacity changes to 1. And when the value changes to `== hidden`, the target element opacity should change to 0.
> Note: The `[@visibilityChanged]` binding is on `<div>` child content element in the `<my-fader>` component. It is NOT on the `<my-fader>` element itself. In other words, the animation target in our example is actually the `<div>` element; not the component **host** element.
Now, you might also wonder where `visibilityChanged` comes from? Because our component property is just called `visibility`. Hold your wild horses Mr. StageCoach, we'll clarify that soon!" Let's first talk about animation durations.
We want to animate these changes over a time duration instead of instantly hiding/showing the content. We need to configure a *transition* to specify animation durations. With Angular this is also suprisingly easy:
```js
animations: [
trigger(’visibilityChanged', [
state('shown' , style({ opacity: 1 })),
state('hidden', style({ opacity: 0 })),
transition('* => *', animate('.5s'))
])
]
```
With the above `transition`, we added information to the animation configuration so each trigger value change will have a 500 msec transition.
So a **fade-in** (opacity 0 -> 1, with a duration of 500 msec) will occur when the value changes from `hidden` to `shown`. And likewise the **fade-out** (opacity 1 -> 0, with a duration of 500 msec) will occur when the value changes from `shown` to `hidden`. By the way, you could also have used `animate('500ms')` to indicate the millsecond duration explicitly.
And what does the `transition('* => *', ...)` mean? Think of `* => *` as a transition from one state to another state; where `*` is a wildcard to mean **any** state value. If we wanted the *fade-out* to be slower than the *fade-in*, here is how we would configure the animation metadata:
```js
animations: [
trigger(’visibilityChanged', [
state('shown' , style({ opacity: 1 })),
state('hidden', style({ opacity: 0 })),
transition('shown => hidden', animate('600ms')),
transition('hidden => shown', animate('300ms')),
])
]
```
See how easy this is? This notation is so easy to understand.
### The Essential Concept
The essential take-away Animation concept is that **Angular Animations** are triggered on component <u>state changes</u>. And developers should consider <u>state changes</u> to be equivalent to <u>value changes in a property</u> of the component instance.
![super-cool](https://media.giphy.com/media/NUC0kwRfsL0uk/giphy.gif)
### Linking Animation to the Component
<br/>
While we configured the Animation metadata, I am sure you are wondering:
* How is the animation property `visibilityChanged` actually connected to the component?
* How are the animations linked to the component’s properties?
Since data-binding features are already supported between the **component** and its **template**, Angular uses a <u>special</u> template animation syntax to support triggering the animation after data-binding changes. So in the component template, we can do this:
```html
<div [@visibilityChanged]="visibility">
Can you see me? I should fade in or out...
</div>
```
Above the `@visibilityChanged` is the special template animation property and it uses databinding `[@visibilityChanged]=“visibility”` to bind the component's visibility property to the animation trigger property `visibilityChanged`.
Here is the entire component definition updated with Animation features:
```js
import { Component, OnChanges, Input } from '@angular/core';
import { trigger, state, animate, transition, style } from '@angular/platform-browser/animations';

@Component({
selector : 'my-fader',
animations: [
trigger('visibilityChanged', [
state('shown' , style({ opacity: 1 })),
state('hidden', style({ opacity: 0 })),
transition('* => *', animate('.5s'))
])
],
template: `
<div [@visibilityChanged]="visibility" >
<ng-content></ng-content>
<p>Can you see me? I should fade in or out...</p>
</div>
`
})
export class FaderComponent implements OnChanges {
@Input() isVisible : boolean = true;
visibility = 'shown';

ngOnChanges() {
this.visibility = this.isVisible ? 'shown' : 'hidden';
}
}
```
### Reducing Complexity
What if - instead of the using the extra `visibility` property - you just wanted to use the `isVisible` property directly? This would obviate `ngOnChanges()` and reduce the code complexity to:
```js
@Component({
animations: [
trigger('visibilityChanged', [
state('shown' , style({ opacity: 1 })),
state('hidden', style({ opacity: 0 })),
transition('* => *', animate('.5s'))
])
],
template: `
<div [@visibilityChanged]="isVisible" >
...
</div>
`
})
export class FaderComponent {
@Input() isVisible : boolean = true;
}
```
I love the tersity of this code. But this will not work without another **important** change to the animation metadata!
> Remember that the `@visibilityChanged` animation trigger property has defined states for the values: `shown` or `hidden`.
If you use the `myFader::isVisible` boolean property, then your animation state values must be changed to `true` and `false` since those are the possible values of the `isVisible` property.
```js
import { Component, OnChanges, Input } from '@angular/core';
import { trigger, state, animate, transition, style } form '@angular/platform-browser/animations';

@Component({
selector : 'my-fader',
animations: [
trigger('visibilityChanged', [
state('true' , style({ opacity: 1, transform: 'scale(1.0)' })),
state('false', style({ opacity: 0, transform: 'scale(0.0)' })),
transition('1 => 0', animate('300ms')),
transition('0 => 1', animate('900ms'))
])
],
template: `
<div [@visibilityChanged]="isVisible" >
<ng-content></ng-content>
<p>Can you see me? I should fade in or out...</p>
</div>
`
})
export class FaderComponent implements OnChanges {
@Input() isVisible : boolean = true;
}
```
> Extra Bonus: The demo has some extra features. The *host* `my-fader` element now has a purple background; when you hide the `my-fader` content children you will see the host background. This change was added so you can visually see the differences between the *host* and the *target* animation elements.
### Our Animation Workflow
Above we have an improved the component definition; enhanced with animation features. Here is a workflow of the [animation] process:
1. the input value for `isVisible` changes,
2. the template databinding updates the `@visibilityChanged` property,
3. the animation trigger is invoked,
4. the `@visibilityChanged` value is used to identify the **state** animations and transitions, and
5. the target element opacity (and other properties) change-animates for xxx msecs
### Animation Philosophy
One of the design goals for Angular Animations is to make it **easy** for developers to configure and use animations. The API and syntax is designed to be:
* intuitive
* declarative and
* immediately associated with the component using metadata
The best part of Angular Animation design is that the **component->template->animation** binding solution <u>decouples</u> the animation from the component internals and uses the template as the binding bridge.
The developer decides which component properties should bind to which animation triggers, then simply uses the possible component property values to set the animation *state* values accordingly.
> In most cases, you will never need to write JavaScript animation logic.
All the mechanics of preparing and managing the animations are hidden from the developer. This 'separation of concerns' provides HUGE benefits to allow developers to easily use Angular Animations with custom architectures & custom implementations.
### Animations with Components Hierarchies
Components should never be concerned with the details regarding animation of child components. Parent components can monitor and alter the public **state** of child components, but should never attempt to modify the internals of those components.
In our examples (above), parent components can simply change the state of the child `my-fader` instances and then magically the contents of the `my-fader` instance will fadeIn or fadeOut.
```js
@Component({
selector : 'my-app',
template: `
<my-fader [isVisible]="showFader">
Am I visible ?
</my-fader>
<button (click)="showFader = !showFader"> Toggle </button>
`
})
export class MyAppComponent {
showFader : boolean = true;
}
```
### Summary
The Angular Animation engine and compiler does all the hard work preparing, managing, and running the animations. Developers use the `@Component` metadata to declaratively define the component styles, templates, and [now] animations. And it is the component **template** that serves as the *bridge* to link the component instance state to the animation trigger property.
### Thanks
Kudos to [Matias Niemelä](https://twitter.com/yearofmoo) for the amazing Animation engine in Angular!
![matiasvikinghair](https://cloud.githubusercontent.com/assets/210413/18608523/49b8707c-7cb1-11e6-8d2c-ab43db07ca78.jpg)
These core animation features [discussed above] are available in the Angular 2.0.0 release. And never fear, Matias and his team are working hard on more amazing, intuitive Animation features. So stay tuned for even MORE cool features and blogs coming soon!
4 changes: 4 additions & 0 deletions b85647d61ad1b8e9ac1b77890f04b18a/injector-tree-4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions bac05e8fc17328a1f27f61b62254db8c/cd-tree-8.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions bca1a6fa015ccd5fca4e829987f67fa7/injector-tree.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions c0cf1789bd907b79e2b567861935a74d/a1-a2-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions categories/angular-2/index.html

Large diffs are not rendered by default.

317 changes: 317 additions & 0 deletions categories/angular/index.html

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions categories/angularjs/index.html

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions categories/annoucements/index.html

Large diffs are not rendered by default.

171 changes: 171 additions & 0 deletions categories/announcements/index.html

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions categories/company/index.html

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions categories/es-6/index.html

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions categories/git/index.html

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions categories/machine-learning/index.html

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions categories/meetups/index.html

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions categories/rebase-book/index.html

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions categories/rust/index.html

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions categories/rx/index.html

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions categories/rxjs/index.html

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions categories/tools/index.html

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions cec743a8e1904a4f0268047a87341368/cd-4.svg

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions chunk-map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"app":["/app-db11fdec89ef44788bcc.js"],"component---src-templates-blog-post-js":["/component---src-templates-blog-post-js-6a14d6c49d22aa388ff9.js"],"component---src-templates-category-js":["/component---src-templates-category-js-4376524bed80ab31f5c7.js"],"component---src-pages-404-js":["/component---src-pages-404-js-6a74e57e5569370f5224.js"],"component---src-pages-all-js":["/component---src-pages-all-js-7aa251af6b402c5bb6a7.js"],"component---src-pages-confirmation-thank-you-js":["/component---src-pages-confirmation-thank-you-js-e20b16d362e2acd832ef.js"],"component---src-pages-finish-newsletter-subscription-js":["/component---src-pages-finish-newsletter-subscription-js-9bc9dd352c7e25398f2b.js"],"component---src-pages-index-js":["/component---src-pages-index-js-34313bc70d6e2470e416.js"]}
2 changes: 2 additions & 0 deletions commons-d9ac4630fec9b8cc9044.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions commons-d9ac4630fec9b8cc9044.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions commons.743a077edf8bbf03e9ea.css

Large diffs are not rendered by default.

227 changes: 227 additions & 0 deletions company/2017/08/17/company-offsite-2017.html

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions component---src-pages-404-js-6a74e57e5569370f5224.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions component---src-pages-404-js-6a74e57e5569370f5224.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ab8cc7f

Please sign in to comment.