fix(animations): ensure position
and display
styles are handled outside of keyframes/web-animations (#28911)
When web-animations and/or CSS keyframes are used for animations certain CSS style values (such as `display` and `position`) may be ignored by a keyframe-based animation. Angular should special-case these styles to ensure that they get applied as inline styles throughout the duration of the animation. Closes #24923 Closes #25635 Jira Issue: FW-1091 Jira Issue: FW-1092 PR Close #28911
This commit is contained in:
@ -11,6 +11,7 @@ import {allowPreviousPlayerStylesMerge, balancePreviousStylesIntoKeyframes, copy
|
||||
import {AnimationDriver} from '../animation_driver';
|
||||
import {CssKeyframesDriver} from '../css_keyframes/css_keyframes_driver';
|
||||
import {containsElement, invokeQuery, isBrowser, matchesElement, validateStyleProperty} from '../shared';
|
||||
import {packageNonAnimatableStyles} from '../special_cased_styles';
|
||||
|
||||
import {WebAnimationsPlayer} from './web_animations_player';
|
||||
|
||||
@ -66,7 +67,8 @@ export class WebAnimationsDriver implements AnimationDriver {
|
||||
|
||||
keyframes = keyframes.map(styles => copyStyles(styles, false));
|
||||
keyframes = balancePreviousStylesIntoKeyframes(element, keyframes, previousStyles);
|
||||
return new WebAnimationsPlayer(element, keyframes, playerOptions);
|
||||
const specialStyles = packageNonAnimatableStyles(element, keyframes);
|
||||
return new WebAnimationsPlayer(element, keyframes, playerOptions, specialStyles);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,8 @@
|
||||
*/
|
||||
import {AnimationPlayer} from '@angular/animations';
|
||||
|
||||
import {allowPreviousPlayerStylesMerge, balancePreviousStylesIntoKeyframes, computeStyle, copyStyles} from '../../util';
|
||||
import {computeStyle} from '../../util';
|
||||
import {SpecialCasedStyles} from '../special_cased_styles';
|
||||
|
||||
import {DOMAnimation} from './dom_animation';
|
||||
|
||||
@ -33,7 +34,8 @@ export class WebAnimationsPlayer implements AnimationPlayer {
|
||||
|
||||
constructor(
|
||||
public element: any, public keyframes: {[key: string]: string | number}[],
|
||||
public options: {[key: string]: string | number}) {
|
||||
public options: {[key: string]: string | number},
|
||||
private _specialStyles?: SpecialCasedStyles|null) {
|
||||
this._duration = <number>options['duration'];
|
||||
this._delay = <number>options['delay'] || 0;
|
||||
this.time = this._duration + this._delay;
|
||||
@ -91,6 +93,9 @@ export class WebAnimationsPlayer implements AnimationPlayer {
|
||||
this._onStartFns.forEach(fn => fn());
|
||||
this._onStartFns = [];
|
||||
this._started = true;
|
||||
if (this._specialStyles) {
|
||||
this._specialStyles.start();
|
||||
}
|
||||
}
|
||||
this.domPlayer.play();
|
||||
}
|
||||
@ -102,6 +107,9 @@ export class WebAnimationsPlayer implements AnimationPlayer {
|
||||
|
||||
finish(): void {
|
||||
this.init();
|
||||
if (this._specialStyles) {
|
||||
this._specialStyles.finish();
|
||||
}
|
||||
this._onFinish();
|
||||
this.domPlayer.finish();
|
||||
}
|
||||
@ -131,6 +139,9 @@ export class WebAnimationsPlayer implements AnimationPlayer {
|
||||
this._destroyed = true;
|
||||
this._resetDomPlayerState();
|
||||
this._onFinish();
|
||||
if (this._specialStyles) {
|
||||
this._specialStyles.destroy();
|
||||
}
|
||||
this._onDestroyFns.forEach(fn => fn());
|
||||
this._onDestroyFns = [];
|
||||
}
|
||||
|
Reference in New Issue
Block a user