【发布时间】:2013-12-31 12:56:42
【问题描述】:
我会尝试为没有 CSS3 功能的砖块制作动画。
我有几个街区并排。当鼠标进入砖块时,砖块内的信息为切换(关闭砖块>砖块打开)和鼠标离开,返回原始(砖块打开>砖块关闭)。
您可以在这里找到示例:FIDDLE(使用的框架:jQuery + jQuery UI)
$('.brick').on('mouseenter', function(e){
// hide previous brick-on displayed
$('.brick-on:visible').hide("drop",{ direction: "down" }, 200, function(){
$(this).prev('.brick-off').show("drop",{ direction: "up" }, 100);
});
$(this).children('.brick-off').hide("drop",{ direction: "up" }, 200, function(){
$(this).next('.brick-on').show("drop",{ direction: "up" }, 100);
});
}).on('mouseleave', function(e){
$(this).children('.brick-on').hide("drop",{ direction: "down" }, 200, function(){
$(this).prev('.brick-off').show("drop",{ direction: "up" }, 100);
});
});
但是我在使用 mouseenter/mouseleave 操作时遇到了问题。有时当你在积木上快速翻滚时,一些积木会保持其 mouseenter 状态,而它们通常不必这样做,因为我不在。
谁能解释一下它是如何正常工作的。
【问题讨论】:
标签: jquery mouseenter mouseleave