简体   繁体   English

具有自定义组件的角度列表项目动画

[英]Angular List item animation with custom component

I am new with angular and angular animation and I want to understand something. 我是新来的角度和角度动画,我想了解一些东西。

I've created an animation on a list of item (on enter / on leave). 我在项目列表上(进入/离开时)创建了动画。 For each item, I use a custom component. 对于每个项目,我使用一个自定义组件。 And to make the animation working, I have to wrap the component inside a div. 为了使动画正常工作,我必须将组件包装在div中。

https://stackblitz.com/edit/angular-animation-question-with-component?file=src%2Fapp%2Fhello.component.html https://stackblitz.com/edit/angular-animation-question-with-component?file=src%2Fapp%2Fhello.component.html

Is it a limitation ? 有限制吗? Or can I do something to make the animation working with the "main" div of the custom component ? 或者我可以做些什么使动画与自定义组件的“主” div一起使用?

You just need to set display: block to your box component host element, you can do that in css like: 您只需要将display: block设置为box组件宿主元素,就可以在CSS中执行以下操作:

:host {
  display: block
}

Here is changed example on stackblitz . 这是关于stackblitz的更改示例。

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM