我有一个div
<div id="slideHolder" ng-mouseenter="fadeIn()" ng-mouseleave="fadeOut()">
...
</div>中间的内容在鼠标输入/离开时淡入淡出
$scope.fadeIn = function()
{
TweenLite.to("#zoomInButton",0.3,{opacity:1});
}
$scope.fadeOut = function()
{
TweenLite.to("#zoomInButton",0.3,{opacity:0});
}是否可以使用if statement将这两个函数合并为一个函数?我知道如何在jQuery中做到这一点,但不确定如何在Angular中。谢谢
编辑:这就是我在jQuery中做的事情
$("#slideHolder").hover(
function() {
$("#zoomButton").stop(true,true).fadeIn();
},
function() {
$("#zoomButton").stop(true,true).fadeOut();
}
);假设它们在技术上仍然是两个函数,我能够将它们简写为hover方法
发布于 2013-03-12 01:58:41
我能弄明白这一点
<div id="slideHolder" ng-mouseenter="fade($event)" ng-mouseleave="fade($event)">
....
</div>在angular中
$scope.fade = function(event)
{
(event.type == 'mouseover') ? TweenLite.to("#zoomInButton",0.3,{opacity:1}) : TweenLite.to("#zoomInButton",0.3,{opacity:0});
}https://stackoverflow.com/questions/15345049
复制相似问题