Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular animation :leave not triggered #29496

Closed
vlio20 opened this issue Mar 24, 2019 · 5 comments
Closed

Angular animation :leave not triggered #29496

vlio20 opened this issue Mar 24, 2019 · 5 comments
Labels
area: animations freq3: high P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent state: confirmed type: bug/fix
Milestone

Comments

@vlio20
Copy link

vlio20 commented Mar 24, 2019

I have a tooltip component with animations in which the :enter animation is working as expected but the :leave animation never triggered.

Here is a link to stackblitz: https://stackblitz.com/edit/building-tooltip-eoby9e?file=src/app/tooltip/tooltip.component.ts

  animations: [
    trigger('tooltip', [
      transition(':enter', [
        style({ opacity: 0 }),
        animate(300, style({ opacity: 1 })),
      ]),
      transition(':leave', [
        animate(300, style({ opacity: 0 })),
      ]),
    ]),
  ],

Angular version: 7.1.4

@ngbot ngbot bot added this to the needsTriage milestone Mar 25, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Apr 16, 2019
@jelbourn jelbourn added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed severity3: broken labels Oct 1, 2020
@dario-piotrowicz
Copy link
Contributor

Hi @vlio20 The issue here is that you have your trigger inside the tooltip component on the div element and not on the tooltip component itself, so when the tooltip component enters it actually works fine because the div with the trigger is entering alongise the component, but when you remove the component you remove it and the div practically doesn't know that it is being removed if you catch what I mean 🙂

The solution here is to apply the trigger to the component itself and not the div inside of it (this can be done with a simple HostBinding) in that case the animation will actually be bound to the component in the way you wanted and all works as it should 🙂

See: https://stackblitz.com/edit/building-tooltip-hf7bp6?file=src%2Fapp%2Ftooltip%2Ftooltip.component.ts

So, yeah I am quite sure this is working as expected 🙂

@dario-piotrowicz
Copy link
Contributor

(PS: :enter and :leave are a bit tricky and not very clearly explained in the docs, I've got an issue open to amend that 🙂 #44253 )

@dario-piotrowicz
Copy link
Contributor

(PS: this issue is practically the same as #29509 I put a similar explanation there if you want to check it out 🙂)

@jessicajaniuk
Copy link
Contributor

Closing since @dario-piotrowicz was able to offer clarity on what's happening here. Feel free to re-open if this is still an issue.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: animations freq3: high P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent state: confirmed type: bug/fix
Projects
None yet
Development

No branches or pull requests

6 participants