我有一个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();
}
);
当然,他们在技术上仍然是两个功能,我能够将它们简写为悬停方法
答案 0 :(得分:0)
我能够解决这个问题
<div id="slideHolder" ng-mouseenter="fade($event)" ng-mouseleave="fade($event)">
....
</div>
并以角度
$scope.fade = function(event)
{
(event.type == 'mouseover') ? TweenLite.to("#zoomInButton",0.3,{opacity:1}) : TweenLite.to("#zoomInButton",0.3,{opacity:0});
}