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.

Animation events in HostListeners aren't supported in Angular Elements (yet?)

See original GitHub issue
  • Regression (a behavior that used to work and stopped working in a new release)
  • Bug report
  • Feature request
  • Documentation issue or request
  • Support request

Could be considered a bug, but also a feature. You decide 😄

Current behavior

Angular component with built-in animations using Angular animation events in components host listeners aren’t supported. For example Assuming a component with animation events like this:

host: {
 '(@transform)': 'doSomethign',
 '(@transform.start)': 'doSomethignElse'
}

Won’t be triggered by the resulting Angular Element of this component. While native host listener will work. E.g.

host: {
  '(keyup)': 'doSomethignElse'
}

The reason why this isn’t working yet, is because there’s no Custom Element equivalent of Angular’s @foo events.

Expected behavior

Not sure whether I’d expect this to be magically handled by Angular Elements, nor am I sure this is supposed to be supported eventually, but it definitely makes some components not work the way as expected when running them as Custom Elements. That’s why I’m bringing this up here.

What is the motivation / use case for changing the behavior?

We might want Angular Elements to support Angular Animations as well. This affects many of Angular Material’s components.

Issue Analytics

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

github_iconTop GitHub Comments

6reactions
alanxonecommented, Aug 23, 2018

@talamaska The HostListener should be given the args to output the data, eg.

	@HostListener('@animate.done', ['$event'])
	animationDone(event: AnimationEvent) {
		// Do something
    }

This should work.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 13, 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 13 animation Hostlistener doesn't work as expected
I have created an small animation with a state which works well in general. It simply fade in/out the div . Like this:...
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 >
Component testing scenarios - Angular
The HostListener wires the click event of the host element (the <a> anchor elements in AppComponent ) to the stub directive's onClick method....
Read more >
Nobody has to use HostListener - angular
In Angular event handling is often implemented using the hostListener decorator, even though it might not be the best fit for the problem....
Read more >
Advanced Angular Interview Questions You Must Prepare For ...
The easy answer is directives do not have their shadow DOM while components have their HTML. Components used to break our application based...
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