I made my first steps in @angular/animations with help of official tutorial. I added reqired libraries and i create my first animation. I already know what transition and state is. I can create simple animations (changing background colors and changing size of elements.
I use @angular/flex-layout library in my project to create neat page layout. And here comes the question: How can I animate increasing and decreasing width of elements my flex layout? For example:
I have 3 "columns" on my page:
- In the first state their width is: 38%, 52%, 10% of container
- and in the second state their width is: 50%, 25%, 25%
just like in the picture (these are the same columns in other states)
Question: How should I make a transitions to animate changing width of columns? Which methods and attributes can I use? What code should look like?
=====
@EDIT:
I publish fragment of my HTML code to present which attribute I want change (fxFlex)
app.component.html
<div class="flex-container"
fxLayout="row"
fxLayout.xs="column"
fxLayoutAlign="end none"
fxLayoutAlign.xs="end none" class="container-style">
<!-- first column -->
<div class="flex-item" fxFlex="38%" fxShow.xs="false" class="one" [@oneState]="state"></div>
<!-- second column -->
<div class="flex-item" fxFlex="52%" class="two" [@twoState]="state"></div>
<!-- third column -->
<div class="flex-item" fxFlex class="three"></div>
</div>
for app.component.ts
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
animations: [
trigger('oneState', [
state('inactive', style({
//I have no idea what I should use to change fxFlex attribute!
//Style? Maybe, something else?
})),
state('active', style({
//I have no idea...
})),
transition('inactive => active', animate('100ms ease-in')),
transition('active => inactive', animate('100ms ease-out'))
]),
trigger('twoState', [
state('inactive', style({
//I have no idea what I should use to change fxFlex attribute!
//Style? Maybe, something else?
})),
state('active', style({
//I have no idea...
})),
transition('inactive => active', animate('100ms ease-in')),
transition('active => inactive', animate('100ms ease-out'))
]),
]
})
export class AppComponent {
title = 'app works!';
state: string = 'inactive';
toggleMove() {
this.state = (this.state === 'inactive' ? 'active' : 'inactive');
console.log(this.state);
}
}
I know that I can change styles of div in simple way. But i don't want to change style. I would like to change a fxFlex attribute of element.
Anyone can help me? Is it possible??