使用 jquery 在画廊中动画活动(悬停)缩略图不透明度
我正在尝试为不透明度设置动画。所有缩略图的默认不透明度均为 0.8。悬停后,不透明度会增加到 1,并在悬停另一个缩略图时返回到 0.8。
我已经尝试过这段代码:
container.delegate("a:has(img)", "mouseenter", function(e){
$(e.currentTarget).stop(true, true).animate({opacity: 1}, options.thumbsopacityFadeTime);
}).delegate("a:has(img)", "mouseout", function(e){
$(e.currentTarget).stop(false, true).animate({opacity: options.thumbsOpacity}, options.thumbsopacityFadeTime);
);
但悬停的缩略图有时(大多数时候)会返回到默认的不透明度,即使鼠标仍然位于同一缩略图上并且没有移动。
我认为这与当前正在运行的动画有关,但我认为 $(e.currentTarget) 仅适用于这 1 个缩略图,那么为什么当我不离开时会为该缩略图触发鼠标移出事件缩略图?
关于如何解决这个问题有什么想法吗?
谢谢, 韦斯利
I'm trying to animate the opacity. Default opacity is 0.8 for all thumbnails. Once hovered, the opacity increases to 1 and should go back to 0.8 when another thumbnail is hovered.
I've tried this code:
container.delegate("a:has(img)", "mouseenter", function(e){
$(e.currentTarget).stop(true, true).animate({opacity: 1}, options.thumbsopacityFadeTime);
}).delegate("a:has(img)", "mouseout", function(e){
$(e.currentTarget).stop(false, true).animate({opacity: options.thumbsOpacity}, options.thumbsopacityFadeTime);
);
but the hovered thumbnails sometimes (most of the time) goes back to the default opacity, even when the mouse is still over that same thumbnail and hasn't moved.
I assume this has something to do with the animations currently running and what not, but I thought $(e.currentTarget) would only apply to this 1 thumbnail, so why would a mouse out event be triggered for that thumbnail when I do not leave the thumbnail?
Any ideas on how to fix this?
Thanks,
Wesley
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我理解你的意思是你不想有鼠标移出效果吗?仅当悬停不同的缩略图时?
第一次尝试应该是将“mouseout”替换为“mouseleave”。如果没有帮助,请尝试其他方法:
Did I understand you that you don't want to have mouseout effect? Only when hovering different thumbnail?
FIrst attempt should be replacing "mouseout" to "mouseleave". If it doesn't help, try different way: