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.

Angular animation and loading template not working together

See original GitHub issue

I’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:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
C0ZENcommented, Apr 27, 2020

@itayod @shaharkazaz the fix is working fine, thank you. Smooth and beautiful animations in my apps now 😃

1reaction
shaharkazazcommented, Apr 24, 2020

@C0ZEN released in v2.17.0 🙂

Read more comments on GitHub >

github_iconTop 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 >

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