我想这就是你想要的。
https://stackblitz.com/edit/angular-j2p2kg?file=src/app/app.component.ts
诀窍在于flex 不允许您处理width。因此,我专注于更改 flex 值以及移除过渡,并将其全部交给 Angular 来处理。
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ],
animations: [
trigger('slidePanel', [
state('leave', style({
flex: '0 0 100%'
})),
state('enter', style({
flex: '1'
})),
transition('* => leave',
animate('300ms cubic-bezier(0.35, 0, 0.25, 1)' ),
),
transition('* => enter',
animate('400ms cubic-bezier(0.35, 0, 0.25, 1)'),
)
]),
]
})
export class AppComponent {
public panelShown = 'leave';
public toggle() : void {
this.panelShown = this.panelShown === 'enter' ? 'leave' : 'enter';
}
}
<div fxLayout="row" fxLayoutAlign="end center" class="fullScreen">
<div [@slidePanel]="panelShown" fxLayout="column" fxLayoutAlign="center center" fxFlex="35" class="green fullHeight">
</div>
<div fxLayout="column" fxLayoutAlign="center center" class="content" [fxFlex]="100">
<div fxLayout="column" fxLayoutAlign="start start" class="blue">
</div>
<button (click)="toggle()">Toggle panel</button>
</div>
</div>