Skip to content

Commit

Permalink
feat(sort): add enter and leave arrow animations (#7180)
Browse files Browse the repository at this point in the history
Adds animations for when the sorting arrow is added and removed from the DOM.
  • Loading branch information
crisbeto authored and andrewseguin committed Sep 29, 2017
1 parent f19f19c commit 2d350a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/sort/sort-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ng-content></ng-content>
</button>

<div *ngIf="_isSorted()" class="mat-sort-header-arrow">
<div *ngIf="_isSorted()" class="mat-sort-header-arrow" [@indicatorToggle]="_sort.direction">
<div class="mat-sort-header-stem"></div>
<div class="mat-sort-header-indicator" [@indicator]="_sort.direction" >
<div class="mat-sort-header-pointer-left" [@leftPointer]="_sort.direction"></div>
Expand Down
21 changes: 20 additions & 1 deletion src/lib/sort/sort-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
state,
style,
animate,
transition
transition,
keyframes,
} from '@angular/animations';
import {CdkColumnDef} from '@angular/cdk/table';
import {Subscription} from 'rxjs/Subscription';
Expand Down Expand Up @@ -70,6 +71,24 @@ const SORT_ANIMATION_TRANSITION =
state('asc', style({transform: 'rotate(45deg)'})),
state('desc', style({transform: 'rotate(-45deg)'})),
transition('asc <=> desc', animate(SORT_ANIMATION_TRANSITION))
]),
trigger('indicatorToggle', [
transition('void => asc', animate(SORT_ANIMATION_TRANSITION, keyframes([
style({transform: 'translateY(25%)', opacity: 0}),
style({transform: 'none', opacity: 1})
]))),
transition('asc => void', animate(SORT_ANIMATION_TRANSITION, keyframes([
style({transform: 'none', opacity: 1}),
style({transform: 'translateY(-25%)', opacity: 0})
]))),
transition('void => desc', animate(SORT_ANIMATION_TRANSITION, keyframes([
style({transform: 'translateY(-25%)', opacity: 0}),
style({transform: 'none', opacity: 1})
]))),
transition('desc => void', animate(SORT_ANIMATION_TRANSITION, keyframes([
style({transform: 'none', opacity: 1}),
style({transform: 'translateY(25%)', opacity: 0})
]))),
])
]
})
Expand Down

0 comments on commit 2d350a0

Please sign in to comment.