[英]Angular2 Animation for simple hover, without any state change
I need help with ng2 animate. 我需要帮助ng2 animate。 I need to prepare simple hover effect based on this: 我需要根据这个准备简单的悬停效果:
@Component({
selector: 'category',
template : require('./category.component.html'),
styleUrls: ['./category.component.scss'],
animations: [
trigger('albumState', [
state('inactive', style({
bottom: '0px'
})),
state('active', style({
bottom: '200px'
})),
transition('inactive => active', animate('100ms ease-in')),
transition('active => inactive', animate('100ms ease-in'))
])
]
})
I need a hint how can I assign that to the template? 我需要一个提示如何将其分配给模板? On Ng2 Docs, we have implementation base on object parameter. 在Ng2 Docs上,我们有基于object参数的实现。 I don't need to change any parameter of my 我不需要改变我的任何参数
item/object/album
from the category , just want assign animation to template. 从类别中 ,只想将动画分配给模板。
Regards! 问候! Greg 格雷格
As long as you are not using the "bottom" property as a hover, any regular ":hover" pseudo class will work. 只要您不使用“bottom”属性作为悬停,任何常规的“:hover”伪类都可以使用。 For example: 例如:
.album:hover {
background-color:red;
}
Support for pseudo classes within the state is yet a feature request 在州内支持伪类仍然是一个功能请求
Possible workaround: Add a parent to your element by wrapping it, then add the :hover
pseudoclass to this parent. 可能的解决方法:通过包装将元素添加到元素,然后将:hover
伪类添加到此父元素。
<span class="parent">
<div class="album">...</div>
</span>
Then 然后
.parent:hover {
bottom:50px; // or what you want to achieve here
}
If you need to override a property being set by the Angular animation you could always use !important
. 如果你需要覆盖由Angular动画设置的属性,你总是可以使用!important
。
.album:hover {
bottom: 20px !important;
}
Using the important flag is not the most desirable solution, but it will work until we get support for pseudo classes in Angular animation. 使用重要标志不是最理想的解决方案,但它会一直有效,直到我们在Angular动画中获得伪类的支持。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.