Angular animation and loading template not working together
See original GitHub issueI’m submitting a…
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:
Current behavior
The loading template does not change his state during a page animation.
Expected behavior
Once the language/scope is loaded, the loading template should detects the change and update the view.
Minimal reproduction of the problem with instructions
You can check this video showing the problem.
The “skeleton design” is still visible in the DOM despite that the scope is already loaded.
The content of the <ng-template #x>
is visible at the same time as the content of <ng-container *transloco="let translation; scope: 'x'; loadingTpl: x">
You can also see on StackBlitz the error.
In StackBlitz:
- You start from the home page: it’s ok (i18n in cache)
- You go to the error page: it’s ok
- You go back to the home page: it’s ok
- You go once more into the home page: it’s broken (the loading state stay until the page animation is finished. The i18n is yet cached and even if not cached, the loaded should be faster than the page animation in this case)
I recorded the bug on StackBlitz.
Code
Typo
<ng-container *transloco="let translation; scope: 'x'; loadingTpl: x">
<p class="title">
{{ translation('x.title') }}
</p>
</ng-container>
<ng-template #x>
<p class="title title-fake"></p>
</ng-template>
Animation
import {
animate,
animateChild,
group,
query,
style
} from '@angular/animations';
export const SLIDE_FROM_RIGHT_ANIMATION = [
style({
position: 'relative'
}),
query(':enter', [
style({
height: '100vh',
left: 0,
overflow: 'hidden',
position: 'fixed',
top: 0,
width: '100%'
})
]),
query(':leave', [
style({
height: '100vh',
left: 0,
overflow: 'hidden',
position: 'absolute',
top: 0,
width: '100%'
})
]),
query(':leave', [
style({
transform: 'translateX(0%)'
})
]),
group([
query(':enter', [
style({
'z-index': 0
})
]),
query(':leave', [
style({
'z-index': 1
}),
animate('350ms ease-out', style({
transform: 'translateX(100%)'
}))
])
]),
query(':enter', animateChild())
];
Environment
"@angular/core": "9.1.1"
"@angular/animations": "9.1.1"
"@ngneat/transloco": "2.14.0"
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Angular 5 - Animation not working
I have found that animations do not fire correctly on component tags that are not displayed as block . Update your template to...
Read more >Animation transitions and triggers
To turn off all animations for an Angular application, place the @.disabled host binding on the topmost Angular component. src/app/app.component.ts content_copy
Read more >Introduction to Angular animations
In the HTML template file, use the trigger name to attach the defined animations to the HTML element to be animated. Code reviewlink....
Read more >Complex animation sequences - Angular
Angular animations are based on the components DOM structure and do not directly take View Encapsulation into account, this means that components using ......
Read more >Dynamic component loader
Component templates are not always fixed. An application might need to load new components at runtime. This cookbook shows you how to add...
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
@itayod @shaharkazaz the fix is working fine, thank you. Smooth and beautiful animations in my apps now 😃
@C0ZEN released in v2.17.0 🙂