fix(animations): ensure the web-animations driver properly handles empty keyframes (#20648)
Closes #15858 PR Close #20648
This commit is contained in:
parent
10771d0bd8
commit
c26e1bba1d
|
@ -65,7 +65,7 @@ export class WebAnimationsPlayer implements AnimationPlayer {
|
|||
|
||||
const keyframes = this.keyframes.map(styles => copyStyles(styles, false));
|
||||
const previousStyleProps = Object.keys(this.previousStyles);
|
||||
if (previousStyleProps.length) {
|
||||
if (previousStyleProps.length && keyframes.length) {
|
||||
let startingKeyframe = keyframes[0];
|
||||
let missingStyleProps: string[] = [];
|
||||
previousStyleProps.forEach(prop => {
|
||||
|
|
|
@ -33,6 +33,24 @@ export function main() {
|
|||
expect(p.log).toEqual(['pause', 'play']);
|
||||
});
|
||||
|
||||
it('should allow an empty set of keyframes with a set of previous styles', () => {
|
||||
const previousKeyframes = [
|
||||
{opacity: 0, offset: 0},
|
||||
{opacity: 1, offset: 1},
|
||||
];
|
||||
|
||||
const previousPlayer = new WebAnimationsPlayer(element, previousKeyframes, {duration: 1000});
|
||||
previousPlayer.play();
|
||||
previousPlayer.finish();
|
||||
previousPlayer.beforeDestroy();
|
||||
|
||||
const EMPTY_KEYFRAMES: any[] = [];
|
||||
const player =
|
||||
new WebAnimationsPlayer(element, EMPTY_KEYFRAMES, {duration: 1000}, [previousPlayer]);
|
||||
player.play();
|
||||
player.destroy();
|
||||
});
|
||||
|
||||
it('should not pause the player if created and started before initialized', () => {
|
||||
const keyframes = [
|
||||
{opacity: 0, offset: 0},
|
||||
|
|
Loading…
Reference in New Issue