Skip to content

Commit

Permalink
fix(button): skip animation on first render of loading button (#1155)
Browse files Browse the repository at this point in the history
This is a port of 6692977 (#1141) to 17.x.

The button text/content should only be faded when transitioning to or
from a non-default state.

CDE-1596
closes #1075
  • Loading branch information
kevinbuhmann authored Jan 23, 2024
1 parent 058b0c5 commit 1951e9a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions projects/angular/src/button/button-loading/loading-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const MIN_BUTTON_WIDTH = 42;
@Component({
selector: 'button[clrLoading]',
template: `
<ng-container [ngSwitch]="state">
<div @parent [ngSwitch]="state">
<span *ngSwitchCase="buttonState.LOADING">
<span @spinner class="spinner spinner-inline"></span>
</span>
Expand All @@ -30,10 +30,15 @@ const MIN_BUTTON_WIDTH = 42;
<span *ngSwitchCase="buttonState.DEFAULT" @defaultButton>
<ng-content></ng-content>
</span>
</ng-container>
</div>
`,
providers: [{ provide: LoadingListener, useExisting: ClrLoadingButton }],
animations: [
trigger('parent', [
// Skip :enter animation on first render.
// The button text/content should only be faded when transitioning to or from a non-default state.
transition(':enter', []),
]),
trigger('defaultButton', [
transition(':enter', [style({ opacity: 0 }), animate('200ms 100ms ease-in', style({ opacity: 1 }))]),
// TODO: see if we can get leave animation to work before spinner's enter animation
Expand Down

0 comments on commit 1951e9a

Please sign in to comment.