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.

BrowserAnimationsModule breaks size calculations

See original GitHub issue

🐞 bug report

Affected Package

@angular/platform-browser/animations

Is this a regression?

The latest version working was 5.2.3

Description

When Angular router is used to navigate and a new component is loaded into router-outlet, the size retrieved from the new compoent in OnInit or AfterViewInit is wrong whenever BrowserAnimationsModule is used.

In the StackBlitz example the FrameComponent gets loaded into router-outlet. In OnInit and AfterViewInit the size of the div #frame gets read by

this.frame.nativeElement.client[Width/Height]

When BrowserAnimationsModule is part of AppModule, the height of the div is completely wrong (should be the same as viewport height). If BrowserAnimationsModule does not get imported, the size of the div gets reported correctly.

This breaks any application that depends on size calculations.

πŸ”¬ Minimal Reproduction

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

  • Load StackBlitz and open up the console (the sizes get logged there)
  • Click on the link β€œClick Here”
  • Check the logged size in the console (especially the height)
  • Go to app.module and delete BrowserAnimationsModule from imports
  • Reload and repeat the above process -> the size is now correct (viewport size)

🌍 Your Environment

Angular Version:

NG 9.0.6
Chrome 80.0.3987.132
Firefox 74
Windows 10 1909

Anything else relevant?

May be related to #20290 but I am not sure if it is the exact same problem

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
FSDREcommented, Oct 26, 2020

@jelbourn If I understand it correctly there is not really a solution for a simple task like β€œscrolling something into view after the page was rendered” without using zone-hacks or double change detection? Why is something basic like this not on a roadmap? And by β€œbasic” I mean the feature, not the implementation, knowing it could be a lot of work.

β€œWorking as expected” is weird. We have a pretty solid inconsistency here. Depending on what modules you include in the project, rendering changes completely and API’s suddenly return different values. I don’t know, it just doesn’t feel right. A framework should keep struggle away from the developers, not introduce confusion.

0reactions
angular-automatic-lock-bot[bot]commented, Nov 26, 2020

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

import { BrowserAnimationsModule } causing problems in ...
In two of my components I'm running some typescript to create a cursor animation which is breaking when i import BrowserAnimationsModule. NoΒ ...
Read more >
In-Depth guide into animations in Angular - InDepth.Dev
Explore the various animation methods in Angular, their use cases, implementation, and some tips on performance, debugging, and reusability.
Read more >
BrowserAnimationsModule - Angular
Configures the module based on the specified object. See also: BrowserAnimationsModuleConfig Β· static withConfigΒ ...
Read more >
swiper | Yarn - Package Manager
Flexbox Layout: Swiper uses modern flexbox layout for slides layout, which solves a lot of problems and time with size caclulations. Such layout...
Read more >
public/node_modules/@angular/animations/esm5/animations.js ...
n *\n * ```ts\n * // remember to include the BrowserAnimationsModule module for this to work...\n * import {AnimationBuilder} from '\\@angular/animations'Β ...
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