【发布时间】:2011-10-16 11:50:51
【问题描述】:
我有以下代码,但如果我真的快速移动鼠标,图像仍然会不断淡入淡出。
如果我使用animate(),stop() 可以工作,但是当我使用这个插件时它就不行了。
$('.person a').live('mouseenter', function() {
$($(this).children('.overstate')).stop().diagonalFade({
time: 350,
fadeDirection_x: 'left-right',
fadeDirection_y: 'top-bottom',
fade: 'out'
});
}).live('mouseleave', function() {
$($(this).children('.overstate')).stop().diagonalFade({
time: 350,
fadeDirection_x: 'left-right',
fadeDirection_y: 'top-bottom',
fade: 'in'
});
});
html
<div class="person">
<a href="#">
<img src="images/p1h.jpg" />
<span class="name">Lee</span>
<span class="overstate">
<img src="images/p1.jpg" />
</span>
</a>
</div><!--end person-->
css
.person { float:left; width:180px; margin-bottom:40px; height:236px; margin-right:31px; }
.lastperson { margin-right:0; }
.person a { display:block; width:180px; height:236px; overflow:hidden; position:relative; }
.person img { position:relative; z-index:2000; }
.name { display:block; width:170px; height:34px; background:url(../images/team-name.png) no-repeat top left; font-size:18px; color:#FFF; text-align:left; line-height:33px; padding-left:10px; float:left; position:relative; z-index:5000;}
.overstate { left:0; top:0; position:absolute; z-index:3000; }
我认为类似的东西可能会起作用,但如果我将鼠标移过几次就会一直闪烁
$('.person a').live('mouseenter', function() {
if (!$(this).children('.overstate').hasClass('animated')) {
$($(this).children('.overstate')).stop().diagonalFade({
time: 450,
fadeDirection_x: 'left-right',
fadeDirection_y: 'top-bottom',
fade: 'out'
});
}
}).live('mouseleave', function() {
$($(this).children('.overstate')).addClass('animated').stop().diagonalFade({
time: 450,
fadeDirection_x: 'left-right',
fadeDirection_y: 'top-bottom',
fade: 'in',
complete: function() { $('.person a').children('.overstate').removeClass('animated'); }
});
});
【问题讨论】:
-
还有css,你的整个代码
-
当我将鼠标悬停时,span.overstate 会通过对角渐变插件获得 opacity:0 并显示 。
标签: jquery jquery-plugins jquery-animate