Skip to content

Commit 2d350a0

Browse files
crisbetoandrewseguin
authored andcommitted
feat(sort): add enter and leave arrow animations (#7180)
Adds animations for when the sorting arrow is added and removed from the DOM.
1 parent f19f19c commit 2d350a0

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/lib/sort/sort-header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ng-content></ng-content>
66
</button>
77

8-
<div *ngIf="_isSorted()" class="mat-sort-header-arrow">
8+
<div *ngIf="_isSorted()" class="mat-sort-header-arrow" [@indicatorToggle]="_sort.direction">
99
<div class="mat-sort-header-stem"></div>
1010
<div class="mat-sort-header-indicator" [@indicator]="_sort.direction" >
1111
<div class="mat-sort-header-pointer-left" [@leftPointer]="_sort.direction"></div>

src/lib/sort/sort-header.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import {
2020
state,
2121
style,
2222
animate,
23-
transition
23+
transition,
24+
keyframes,
2425
} from '@angular/animations';
2526
import {CdkColumnDef} from '@angular/cdk/table';
2627
import {Subscription} from 'rxjs/Subscription';
@@ -70,6 +71,24 @@ const SORT_ANIMATION_TRANSITION =
7071
state('asc', style({transform: 'rotate(45deg)'})),
7172
state('desc', style({transform: 'rotate(-45deg)'})),
7273
transition('asc <=> desc', animate(SORT_ANIMATION_TRANSITION))
74+
]),
75+
trigger('indicatorToggle', [
76+
transition('void => asc', animate(SORT_ANIMATION_TRANSITION, keyframes([
77+
style({transform: 'translateY(25%)', opacity: 0}),
78+
style({transform: 'none', opacity: 1})
79+
]))),
80+
transition('asc => void', animate(SORT_ANIMATION_TRANSITION, keyframes([
81+
style({transform: 'none', opacity: 1}),
82+
style({transform: 'translateY(-25%)', opacity: 0})
83+
]))),
84+
transition('void => desc', animate(SORT_ANIMATION_TRANSITION, keyframes([
85+
style({transform: 'translateY(-25%)', opacity: 0}),
86+
style({transform: 'none', opacity: 1})
87+
]))),
88+
transition('desc => void', animate(SORT_ANIMATION_TRANSITION, keyframes([
89+
style({transform: 'none', opacity: 1}),
90+
style({transform: 'translateY(25%)', opacity: 0})
91+
]))),
7392
])
7493
]
7594
})

0 commit comments

Comments
 (0)