Skip to content

refactor(animations): refactor non-animatable check to be timeline based - #46666

Closed
dario-piotrowicz wants to merge 6 commits into
angular:mainfrom
dario-piotrowicz:improve-not-animatable-warning
Closed

dario-piotrowicz wants to merge 6 commits into
angular:mainfrom
dario-piotrowicz:improve-not-animatable-warning

Conversation

@dario-piotrowicz

@dario-piotrowicz dario-piotrowicz commented Jul 1, 2022 •

Copy link
Copy Markdown
Contributor

move the check for non-animatable properties from the animation building
phase to the application of the animation's transition instead, in such
a way we can check it against the keyframes of the transition's timeline
in order to only provide warnings for properties which are being
animated, thus not providing any warning for non-animatable properties
being applied to elements via the style function

this change has the benfit just mentioned above but it comes with two
drawbacks:

  • the warning handling is not done in the building time so it is a bit
    inconsistent with other type of validations (such as the unsupported css
    properties one for example)
  • before the warning was being applied only when the animation's data
    was being parsed, so it happed only once but now since it is applied
    when the animation is actually being prepared to be played, it happens
    each time the animation runs

resolves #46602

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix (sort of?)
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #46602

Using the style function on non-animatable properties produces a warning in the console, even thought those properties are only being applied to the elements but not animated

For example:
before

What is the new behavior?

The warning is presented only if the animation tries to animate the non-animatable properties

For example:
after

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

  • @jessicajaniuk, please let me know what you think of this possible change 🙂

@pullapprove
pullapprove Bot requested review from atscott and crisbeto July 1, 2022 14:37
@dario-piotrowicz
dario-piotrowicz force-pushed the improve-not-animatable-warning branch 2 times, most recently from a663ec9 to 0a93a5e Compare July 1, 2022 15:05
@jessicajaniuk jessicajaniuk added area: animations legacy animations package only. Otherwise use area: core. target: patch This PR is targeted for the next patch release labels Jul 1, 2022
@ngbot ngbot Bot modified the milestone: Backlog Jul 1, 2022
@jessicajaniuk jessicajaniuk added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jul 1, 2022

@jessicajaniuk jessicajaniuk left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this solution to the problem. I have a couple of non-blocking questions / comments, but I'm otherwise ok with this. Thanks, @dario-piotrowicz!

reviewed-for: fw-animations, fw-core

@AndrewKushnir AndrewKushnir left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dario-piotrowicz FYI I've left a couple comments as well.

From PR description:

before the warning was being applied only when the animation's data
was being parsed, so it happed only once but now since it is applied
when the animation is actually being prepared to be played, it happens
each time the animation runs

If the number of warnings becomes a problem, we can update the logic (in a followup PR) to keep track of the warnings that we've already produced, similar to what we do for Forms here:
https://github.com/angular/angular/blob/main/packages/forms/src/directives/shared.ts#L372

@dario-piotrowicz

Copy link
Copy Markdown
Contributor Author

@dario-piotrowicz FYI I've left a couple comments as well.

From PR description:

before the warning was being applied only when the animation's data
was being parsed, so it happed only once but now since it is applied
when the animation is actually being prepared to be played, it happens
each time the animation runs

If the number of warnings becomes a problem, we can update the logic (in a followup PR) to keep track of the warnings that we've already produced, similar to what we do for Forms here: https://github.com/angular/angular/blob/main/packages/forms/src/directives/shared.ts#L372

Yes!!! I was thinking the exact same thing as I was coding the solution! 🙂

The biggest issue I think is we'd warn every possible issue once (for example, trigger myAnimation can have an initial/:enter transition which tries to animate display, then it can have a different transition which tried to animate both display and font-style, so we'd initially want to remember that for the myAnimation trigger one warning was issued for the display prop and then re issue a new warning but only for the font-style prop when the new transition kicks in. Also of course other triggers should be unaffected by other getting warnings) all possible of course but it could require us to store a few strings/maps which we would then need to clean up after the animation finished.

So yeah I would totally give it a shot but I'd imagine only if need be as it would add some overhead and complexity I think 🙂

(Unless you were thinking of a different sort of implementation?)

@AndrewKushnir AndrewKushnir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dario-piotrowicz looks good, just left some minor comments.

move the check for non-animatable properties from the animation building
phase to the application of the animation's transition instead, in such
a way we can check it against the keyframes of the transition's timeline
in order to only provide warnings for properties which are being
animated, thus not providing any warning for non-animatable properties
being applied to elements via the style function

this change has the benfit just mentioned above but it comes with two
drawbacks:
 - the warning handling is not done in the building time so it is a bit
inconsistent with other type of validations (such as the unsupported css
properties one for example)
 - before the warning was being applied only when the animation's data
was being parsed, so it happed only once but now since it is applied
when the animation is actually being prepared to be played, it happens
each time the animation runs

resolves angular#46602
@dario-piotrowicz
dario-piotrowicz force-pushed the improve-not-animatable-warning branch from 14d7054 to 2c231a5 Compare July 12, 2022 20:05
…line based

remove unused pushNonAnimatablePropertiesWarning
@AndrewKushnir AndrewKushnir added action: presubmit The PR is in need of a google3 presubmit and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 12, 2022
@jessicajaniuk jessicajaniuk added action: merge The PR is ready for merge by the caretaker and removed action: presubmit The PR is in need of a google3 presubmit labels Jul 12, 2022
@jessicajaniuk

Copy link
Copy Markdown
Contributor

This PR was merged into the repository by commit a4ec109.

jessicajaniuk pushed a commit that referenced this pull request Jul 12, 2022
…sed (#46666)

move the check for non-animatable properties from the animation building
phase to the application of the animation's transition instead, in such
a way we can check it against the keyframes of the transition's timeline
in order to only provide warnings for properties which are being
animated, thus not providing any warning for non-animatable properties
being applied to elements via the style function

this change has the benfit just mentioned above but it comes with two
drawbacks:
 - the warning handling is not done in the building time so it is a bit
inconsistent with other type of validations (such as the unsupported css
properties one for example)
 - before the warning was being applied only when the animation's data
was being parsed, so it happed only once but now since it is applied
when the animation is actually being prepared to be played, it happens
each time the animation runs

resolves #46602

PR Close #46666
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Aug 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: animations legacy animations package only. Otherwise use area: core. target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Angular 14 unnecessarily warning about not animatable properties?

3 participants