question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Easy way to animate change of bound values

See original GitHub issue

🚀 feature request

In my application I have some text. When the text changes, I want to fly out the old text and fade in the new text.

Relevant Package

This should probably be implemented in @angular/animations?

Description

In order to implement the solution at the moment, I see two alternatives:

  1. Work with two internal properties (oldValue, newValue) and overlay two divs in order to animate them.
  2. Trigger first animation in code, implement a animation done callback. When the callback is executed, change value and trigger the second animation.

Both solutions seem to be quite complex for such a simple task. I wish I could define an animation for before changing the value and after change.

Describe the solution you’d like

This could look like:

@Component({
  selector: 'my-comp',
  template: '<div [@myTrigger]=myText>{{myText}}</div>',
  animations: [
    trigger('oldContent', [
      transition(':before', [
        animate('0.5s ease-in', style({
          opacity: 0.0,
        }))
      ]),
      transition(':after', [
        animate('0.5s ease-in', style({
          opacity: 1.0,
        }))
      ])
    ])
  ]
})
export class MyComponent{
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:17
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
andruicommented, Jun 21, 2019

@eosgortor You may use ‘void <=> *’ transition along with custom strucural directive which recreates view when data is changed. Here is example https://stackblitz.com/edit/angular-5vng7d

3reactions
ghostcommented, Jun 24, 2019

This is a great third possibility, but still quite complex for the task. I will keep the feature request open.

Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to animate changes in binding values - Hacking with Swift
SwiftUI's two-way bindings let us adjust the state of our program, and we can respond to that by adjusting our view hierarchy. For...
Read more >
Angular: Quick and easy animation on changed binding value
With ngAnimate, you can easily animate certain events (see directive support Archive ). We'll make use of ngClass animations to style an element ......
Read more >
Change Detection triggered animations in Angular
In this article we will cover a simple way to animate changes in Angular components using CSS transitions that are triggered with change...
Read more >
Angular Animations Explained with Examples - freeCodeCamp
The first argument matches the value of the data bound to the animation binding. That is, the value bound to [@selector] in the...
Read more >
Animation transitions and triggers - Angular
In general, use wildcard states when an element has multiple potential states that it can change to. If the button can change from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found