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.

:leave animation does not work on Firefox and Edge

See original GitHub issue

I’m submitting a…


[x] Bug report  

Current behavior

The enter animation is working fine on all the browsers, but the leave animation is not working on firefox and edge (works on chrome and safari)

Expected behavior

Should work as it works in chrome and safari

Minimal reproduction of the problem with instructions

https://stackblitz.com/edit/angular-xivr7n

Environment


Angular version: 5.0.0


Browser:
- [x] Firefox version 57
- [x] Edge version 41
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mhamcommented, Nov 19, 2017

In your case Angular needs to calculate styles for width (explicitly set to *) and margin (not provided but used in animation, so implicitly *).

transition(':leave', [
  style({ transform: 'scale(1)', opacity: 1, width: '*' }),
  animate('1s cubic-bezier(.8,-0.6,0.2,1.5)', 
    style({ transform: 'scale(0.5)', opacity: 0, width: '0px', margin: '0px' }))
])

From documentation for style function.

Auto-styles (using *)

When an asterix (*) character is used as a value then it will be detected from the element being animated and applied as animation data when the animation starts.

This feature proves useful for a state depending on layout and/or environment factors; in such cases the styles are calculated just before the animation starts.

Angular uses Window.getComputedStyle to calculate property value for auto-styles. Window.getComputedStyle returns empty string for margin property in Firefox. When property value is empty string, Angular sets REMOVAL_FLAG of element to NULL_REMOVED_QUERIED_STATE and then the NoopAnimationPlayer is used - animation does not play.

When property is not longhand property, we should ignore its empty value.

According to specification of CSS Object Model, Window.getComputedStyle returns all longhand properties. While iterate over numeric indexes of Window.getComputedStyle, there is no margin property in Chrome and Firefox. But when access margin property directly, there is non-empty value in Chrome and empty value in Firefox. We cannot rely on this across the browsers.

var computed = window.getComputedStyle(document.body);
// no margin
for (var i = 0; i < computed.length; i++) {
  if (computed[i].startsWith('margin')) {
    console.info(computed[i]);
  }
}
// non-empty in Chrome, empty in Firefox
console.info(computed['margin']);

Workaround is use of longhand properties.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 12, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular animation doesn't work in Firefox - Stack Overflow
I am using the below code to gradually hide a DIV in Angular 2. This perfectly works in Chrome and Microsoft Edge. But...
Read more >
Edge Animate animations not working with FIREFOX
Solved: Problem with FIREFOX Almost all of my websites have animated sliders on them that have been made with Edge Animate in Muse....
Read more >
Work with animations — Firefox Source Docs documentation
This article covers three tools you can use to visualize and edit animations: the animation inspector. diting @keyframes. editing timing functions ...
Read more >
3 Ways to Fix Keyframes if not Working in Firefox
How do I fix keyframes if they are not working in Firefox? · 1. Double-check the code · 2. Set animation duration ·...
Read more >
Animations does not work on Edge/Internet explorer. Why?
Although I added -webkit the animation is still not supported by Edge or IE. Can you help me figure out why? Below is...
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