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:
- Work with two internal properties (oldValue, newValue) and overlay two divs in order to animate them.
- 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:
- Created 5 years ago
- Reactions:17
- Comments:6 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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
This is a great third possibility, but still quite complex for the task. I will keep the feature request open.
Thank you