Skip to content

Feature Request: Allow binding expression in style(), keyframes() etc... #9668

@shlomiassaf

Description

@shlomiassaf

I'm submitting a ... (check one with "x")
feature request

Current behavior
Animation instructions doesn't accept bindings expression.

Expected/desired behavior
Animation metadata should allow instructions from the component instance.

Example:

@Component({
  selector: 'my-app',
  animations: [
    trigger('fade', [
      transition('void => in', [
        animate('150ms linear', keyframes([
          style('MY_STYLE'),
          style({opacity: '*'})
        ]))
      ])
    ])
  ],
  encapsulation: ViewEncapsulation.None,
  template: `<div  @fade="fadeState"></div>`})
export class FadeInBackdrop {
  private fadeState: 'in' | 'out' = 'in';
  MY_STYLE = {
    opacity: 0
  }
}

What is the motivation / use case for changing the behavior?
This will allow dynamic animation based on user input.
Sine animation instructions are static the only way to change them in runtime is
A) Using auto style, letting the user set * from css
B) Define multiple states (not really dynamic)

This is really useful in 3rd part libraries where some sort of animation customization is needed.

Since the generated animation factory runs on every change it can get a hold of the instance and easily get the value.
The syntax for referencing a bind needs definition as style might be a string.

Metadata

Metadata

Assignees

Labels

area: animationsfeatureIssue that requests a new featurefeature: under considerationFeature request for which voting has completed and the request is now under considerationfreq1: low

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions