JQuery 的“暂停和充值”功能如果光标停留在元素内则计时器
与我一起工作的设计师给了我一些需要处理的功能,但我不知道如何处理它。她基本上想要以下内容;
- 当您将鼠标悬停在链接上时,面板应该下拉(完成此操作没有问题)。面板应该
- 在 10 秒后消失(也完成没有问题)
- 如果您的光标位于面板内,则面板应该永远不会消失。一旦你的光标离开面板,10 秒计时器应该再次启动(呃..)
有人能给我指出一个插件或文章的正确方向,解释如何实现第三个功能吗?我是一位经验丰富的开发人员,但正在努力解决如何解决这个问题,甚至从哪里开始谷歌搜索。这是我到目前为止所做的,除了第三个要点之外,一切都有效。我有一种感觉,我可能需要彻底改变我的方法才能使其发挥作用;
function showMiniBasket() {
$("#basketMiniSummary").slideDown();
}
function hideMiniBasket() {
$("#basketMiniSummary").fadeOut();
}
var config = {
over: showMiniBasket,
timeout: 10000,
out: hideMiniBasket
};
$("#basketDropDown").hoverIntent(config);
答案...
根据下面的建议,最终的解决方案是...
function showMiniBasket() {
$("#basketMiniSummary").slideDown("fast");
}
function hideMiniBasket() {
if (!$('#basketMiniSummary').hasClass('being_hovered')) {
$("#basketMiniSummary").fadeOut();
}
}
var config = {
over: showMiniBasket,
timeout: 1000,
out: hideMiniBasket
};
$("#basketDropDown").hoverIntent(config);
$('#basketMiniSummary').hover(function() {
//hover in
$(this).addClass('being_hovered');
$("#basketMiniSummary").slideDown();
}, function() {
//hover out
$(this).removeClass('being_hovered');
$("#basketMiniSummary").delay(1000).fadeOut();
});
The designer I am working with has given me a bit of functionality to work on and I'm not sure how to approach it. She basically wants the following;
- When you hover over a link, a panel should drop down (done this bit no problem)
- The panel should dissapear after 10 seconds (also done no problem)
- If your cursor is within the panel, the panel should never dissapear. Once your cursor leaves the panel, the 10 second timer should start again (erm..)
Could anyone point me in the right direction of a plugin or article that explains how to achieve this third bit of functioality? I'm a fairly seasoned developer but am struggling with how to approach this or even where to start googling. Here's what I have so far, all working but for that third bullet point. I have a feeling I may need to completely change my approach to get this to work;
function showMiniBasket() {
$("#basketMiniSummary").slideDown();
}
function hideMiniBasket() {
$("#basketMiniSummary").fadeOut();
}
var config = {
over: showMiniBasket,
timeout: 10000,
out: hideMiniBasket
};
$("#basketDropDown").hoverIntent(config);
THE ANSWER...
Based on a suggestion below, the eventual solution was...
function showMiniBasket() {
$("#basketMiniSummary").slideDown("fast");
}
function hideMiniBasket() {
if (!$('#basketMiniSummary').hasClass('being_hovered')) {
$("#basketMiniSummary").fadeOut();
}
}
var config = {
over: showMiniBasket,
timeout: 1000,
out: hideMiniBasket
};
$("#basketDropDown").hoverIntent(config);
$('#basketMiniSummary').hover(function() {
//hover in
$(this).addClass('being_hovered');
$("#basketMiniSummary").slideDown();
}, function() {
//hover out
$(this).removeClass('being_hovered');
$("#basketMiniSummary").delay(1000).fadeOut();
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会像这样使用 $.hover :
I would use $.hover like so: