Вот код stackblitz , и он работает, я использовал немного CSS и другой триггерный элемент в угловой анимации.
Вот ресурсы, которые можно использовать для справки
HTML:
<div class="container" [@slide]="isOpen ? true : false">
<button [class.button-resize-expand]="!isOpen"
[class.button-resize-collapse]="isOpen"
(click)="togglePanel()" [@openClose] ="isOpen ? 'open': 'closed'">
<mat-icon class="rotate-chevron" [class.rotate-clicked]="!isOpen">{{panelExpanded ? 'chevron_left' : 'chevron_right'}}</mat-icon>
</button>
<div *ngIf="isOpen" class="expandable-panel">
<div class="current-task-info">
So much data here damn!
</div>
</div>
</div>
TS:
type isOpen = true|false;
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.scss' ],
animations: [
trigger('slide', [
transition('* <=> *', [
group([
query(':enter', [
style({transform: 'translateX(-100%)'}),
animate('.3s', style({transform: 'translateX(0%)'}))
], {optional: true}),
query(':leave', [
style({transform: 'translateX(0%)'}),
animate('.3s', style({transform: 'translateX(-100%)'}))
], {optional: true}),
])
])
]),
trigger('openClose', [
// ...
state('open', style({
animation: 'slidefront .3s linear 0s forwards'
})),
state('closed', style({
animation: 'slideback .3s linear 0s backwards, bounce 1.5s'
}))
]),
]
})
export class AppComponent {
isOpen = true;
togglePanel(): void {
this.isOpen = !this.isOpen;
}
}
CSS:
@keyframes slidefront {
from {left: 0%;}
to {left: 80%;}
}
@keyframes slideback {
from {right: 5%;}
to {right: 80%;}
}