Skip to content

Commit d36dfd4

Browse files
dario-piotrowiczthePunderWoman
authored andcommitted
fix(animations): fix non-animatable warnings for easing (#48583)
the easing "prop" used to specify the easing function to apply to animations isn't a valid css property, it is thus considered not animatable but different values for such property shouldn't cause non-animatable warnings resolves #48571 PR Close #48583
1 parent 6443086 commit d36dfd4

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

packages/animations/browser/src/dsl/animation_transition_factory.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,22 @@ function checkNonAnimatableInTimelines(
123123
return;
124124
}
125125

126+
const allowedNonAnimatableProps = new Set<string>([
127+
// 'easing' is a utility/synthetic prop we use to represent
128+
// easing functions, it represents a property of the animation
129+
// which is not animatable but different values can be used
130+
// in different steps
131+
'easing'
132+
]);
133+
126134
const invalidNonAnimatableProps = new Set<string>();
127135

128136
timelines.forEach(({keyframes}) => {
129137
const nonAnimatablePropsInitialValues = new Map<string, string|number>();
130138
keyframes.forEach(keyframe => {
131-
for (const [prop, value] of keyframe.entries()) {
139+
const entriesToCheck =
140+
Array.from(keyframe.entries()).filter(([prop]) => !allowedNonAnimatableProps.has(prop));
141+
for (const [prop, value] of entriesToCheck) {
132142
if (!driver.validateAnimatableStyleProperty!(prop)) {
133143
if (nonAnimatablePropsInitialValues.has(prop) && !invalidNonAnimatableProps.has(prop)) {
134144
const propInitialValue = nonAnimatablePropsInitialValues.get(prop);

packages/core/test/animation/animation_integration_spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import {animate, animateChild, animation, AnimationEvent, AnimationMetadata, AnimationOptions, AUTO_STYLE, group, keyframes, query, state, style, transition, trigger, useAnimation, ɵPRE_STYLE as PRE_STYLE} from '@angular/animations';
8+
import {animate, animateChild, animation, AnimationEvent, AnimationMetadata, AnimationOptions, AUTO_STYLE, group, keyframes, query, sequence, state, style, transition, trigger, useAnimation, ɵPRE_STYLE as PRE_STYLE} from '@angular/animations';
99
import {AnimationDriver, ɵAnimationEngine, ɵNoopAnimationDriver as NoopAnimationDriver} from '@angular/animations/browser';
1010
import {MockAnimationDriver, MockAnimationPlayer} from '@angular/animations/browser/testing';
1111
import {ChangeDetectorRef, Component, HostBinding, HostListener, Inject, RendererFactory2, ViewChild} from '@angular/core';
@@ -4411,6 +4411,16 @@ describe('animation tests', function() {
44114411
]);
44124412
expect(spyWarn).not.toHaveBeenCalled();
44134413
});
4414+
4415+
it('should not show a warning if a different easing function is used in different steps',
4416+
() => {
4417+
const spyWarn = spyOn(console, 'warn');
4418+
buildAndAnimateSimpleTestComponent([sequence([
4419+
animate('1s ease-in', style({background: 'red'})),
4420+
animate('1s ease-out', style({background: 'green'})),
4421+
])]);
4422+
expect(spyWarn).not.toHaveBeenCalled();
4423+
});
44144424
});
44154425
});
44164426
})();

0 commit comments

Comments
 (0)