[英]delay on menu hover overlay
I am struggling to add 0.3 delay on overlay in on:hover menu in .js. 我正在努力在.js的on:hover菜单中的叠加上添加0.3延迟。 I tried FadeIn(), Delay() with dequeue (I might have done something wrong) without luck.
我没有运气就尝试了FadeIn()和Delay()出队(我可能做错了)。 Any suggestions how to modify this function?
有什么建议如何修改此功能?
$('.activate-overlay-effect').on('mouseenter mouseleave', '.menu-item-responsive', function(e) {
var target = $('.menu');
var overlay = $('#overlay');
if (overlay.length && !$('#' + _.container).hasClass('touch')) {
if (e.type == 'mouseenter') {
target.addClass('hovered');
overlay.removeClass('hidden');
} else if (e.type == 'mouseleave') {
target.removeClass('hovered');
overlay.addClass('hidden');
} else {}
}
return false;
});
There are some nice plugins that does exactly that. 有一些很好的插件可以做到这一点。 One of them is $.hoverDelay() .
其中之一是$ .hoverDelay() 。 It gives you a configurable delay for both the 'in' and 'out' events like so:
它为“输入”和“输出”事件提供了可配置的延迟,如下所示:
$('.activate-overlay-effect').hoverDelay({
delayIn: 200,
delayOut:700,
handlerIn: function($element){
$element.css({backgroundColor: 'red'});
},
handlerOut: function($element){
$element.css({backgroundColor: 'auto'});
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.