jQuery.vticker.js mouseleave、mouseenter 函数问题

发布于 2024-12-29 13:13:20 字数 1540 浏览 4 评论 0原文

我正在开发一个带有新闻滚动或条带盲效果的网站。场景是当用户将鼠标悬停在新闻项目上时,将打开一个弹出框。

我编写的代码一切顺利:

    if(options.mousePause)
    {
        obj.bind("mouseenter",function(){
            options.isPaused = true;
            $Box.css('width',200);
            obj.children('ul').children('li').css('background','#f0f0f0');
            obj.children('ul').children('li').children('a').css('color','#000');
            var offset = obj.children('ul').children('li').offset();
            $Box.css('left', offset.left);
            $Box.css('top', offset.top+25);
            $Box.css('display','block');
        }).bind("mouseleave",function(){

            $Box.hover(function(){
                options.isPaused = true;
            },function() { 
                options.isPaused = false;
                $Box.css('display','none');
                obj.children('ul').children('li').css('background','transparent');
                obj.children('ul').children('li').children('a').css('color','#ffe300');
            });

            options.isPaused = false;
            $Box.css('display','none');
            obj.children('ul').children('li').css('background','transparent');
            obj.children('ul').children('li').children('a').css('color','#ffe300');
        }); // mouseleave function end

一切都很好,但是当我将鼠标悬停在正在显示的新闻项框上时,我无法将鼠标悬停在该框上,因为鼠标指针离开新闻条, vticker.js 函数 mouseleave 调用盒子又消失了。

请实时查看此页面 http://tagbees.designforce.us/ 并请给我解决此问题的建议。

提前致谢。 问候

I am developing a website with a news scroll up or blind effect in a strip. Scenario is when user will mouse hover on a news item then a popbox will open.

Everything is going fine with the codes i wrote:

    if(options.mousePause)
    {
        obj.bind("mouseenter",function(){
            options.isPaused = true;
            $Box.css('width',200);
            obj.children('ul').children('li').css('background','#f0f0f0');
            obj.children('ul').children('li').children('a').css('color','#000');
            var offset = obj.children('ul').children('li').offset();
            $Box.css('left', offset.left);
            $Box.css('top', offset.top+25);
            $Box.css('display','block');
        }).bind("mouseleave",function(){

            $Box.hover(function(){
                options.isPaused = true;
            },function() { 
                options.isPaused = false;
                $Box.css('display','none');
                obj.children('ul').children('li').css('background','transparent');
                obj.children('ul').children('li').children('a').css('color','#ffe300');
            });

            options.isPaused = false;
            $Box.css('display','none');
            obj.children('ul').children('li').css('background','transparent');
            obj.children('ul').children('li').children('a').css('color','#ffe300');
        }); // mouseleave function end

Everything is fine but when i hover on a news item box is displaying but i am not able to hover over the box, as mouse pointer leave the news strip, the vticker.js function mouseleave called and box is again disappear.

Please check this page live http://tagbees.designforce.us/ and please give me advise to solve this problem.

Thanks in advance.
Regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

尽揽少女心 2025-01-05 13:13:20

我看到 2 个选项:

选项 1

.Scroller.tickPop 元素包装在另一个元素中,并绑定 mouseovermouseleave< /code> 包装器上的事件。在 mouseover 中检查:

  • 如果事件目标是 .Scroller 项 (li),则打开或更新 .tickPop< /code>
  • 如果事件目标是 .tickPop,则不执行任何
  • 操作,否则关闭 .tickPop
    mouseleave 中,您知道鼠标已离开整个容器,因此您关闭 .tickBox

选项2

mouseleave上的.tickPop的关闭处添加一点setTimeout,如果鼠标进入则调用clearTimeout .tickBox.Scroller 项。

I see 2 options:

option 1

Wrap your .Scroller and .tickPop elements in another element, and bind the mouseover and mouseleave events on the wrapper. In the mouseover you check:

  • if the event target is a .Scroller item (li) then open or update the .tickPop
  • if the event target is .tickPop, do nothing
  • otherwise, close the .tickPop
    And in mouseleave you know that the mouse has left the entire container, so you close the .tickBox.

option 2

Add a little setTimeout to the closing of .tickPop on mouseleave, and call clearTimeout if the mouse enters .tickBox or a .Scroller item.

无人接听 2025-01-05 13:13:20

声明一个全局布尔变量“DisplayPopup”。默认值 false
仅在新闻条的鼠标悬停和鼠标输入以及新闻条的每个子项中设置“DisplayPopup”=true,并确保如果“DisplayPopup”设置为“true”,则不会更改其值。
现在,在新闻条的鼠标悬停、鼠标进入和鼠标离开以及新闻条的每个子项中,确保如果“DisplayPopup”=true,则将弹出窗口设置为可见。

现在要关闭弹出窗口,您可以有两个选项

  1. 关闭按钮。 设置“DisplayPopup”= false
  2. 在此关闭按钮后面,在鼠标离开弹出窗口时

设置“DisplayPopup”= false 并关闭弹出窗口。还要确保弹出窗口不是新闻条的子项目。它仅显示在其下方。

Declare a global boolean variable "DisplayPopup". default value false
Only in mouse hover and mouse enter of news strip and every child item of news strip set "DisplayPopup"=true and also make sure that if "DisplayPopup" is set to "true" you do not change its value.
now in the mouse hover, mouse enter and mouse leave of the news strip and every child item of news strip make sure that popup is set to visible if "DisplayPopup"=true.

now to close the popup you can have two options

  1. close button. behind this close button set "DisplayPopup"=false
  2. on mouse leave of popup set "DisplayPopup"=false and close popup.

Also ensure that popup is not child item of news strip. it is just displayed below it.

请恋爱 2025-01-05 13:13:20

非常感谢 Ori 和 Syed Salman Akbar 的关心并试图帮助我。我尝试了 Ori 的两种方法和 Syed Salman akbar 的一种逻辑,但没有成功。我还尝试了很多其他选择,最后我得到了它。

问题不在于剥离 LI“mouseleave”功能,该功能过去和现在都工作正常。当 mouseleave li 函数通过设置 $Box.css('display','none'); 重新绘制/恢复 LI 颜色和背景;

我对代码进行了以下更改。

  1. 在我的问题中,弹出框悬停功能代码嵌套在LI的“mouseleave”功能中。我将 $Box.hover 函数从 LI“mouseleave”函数中取出。

  2. 将“mouseenter”和“mouseleave”函数与$Box绑定,因为它是与strip分开的对象。

  3. 在 $Box 的“mouseenter”功能上添加了重新绘制条带 LI 的代码,以营造 LI 仍在悬停的感觉,并在 $Box 的“mouseleave”功能上恢复/重新绘制 LI。

看看新代码:

    if(options.mousePause)
    {
        obj.bind("mouseenter",function(){
            options.isPaused = true;
            $Box.css('width',200);
            obj.children('ul').children('li').css('background','#f0f0f0');
            obj.children('ul').children('li').children('a').css('color','#000');
            var offset = obj.children('ul').children('li').offset();
            $Box.css('left', offset.left);
            $Box.css('top', offset.top+25);
            $Box.css('display','block');
        }).bind("mouseleave",function(){
            options.isPaused = false;
            $Box.css('display','none');
            obj.children('ul').children('li').css('background','transparent');
            obj.children('ul').children('li').children('a').css('color','#ffe300');
        }); // mouseleave function end
    } // if end
    $Box.bind("mouseenter",function(){
        options.isPaused = true;
        isBoxHover = true;
            $Box.css('width',200);
            obj.children('ul').children('li').css('background','#f0f0f0');
            obj.children('ul').children('li').children('a').css('color','#000');
            var offset = obj.children('ul').children('li').offset();
            $Box.css('left', offset.left);
            $Box.css('top', offset.top+25);
            $Box.css('display','block');

    }).bind("mouseleave",function() { 
        options.isPaused = false;
        isBoxHover = false;
        $Box.css('display','none');
        obj.children('ul').children('li').css('background','transparent');
        obj.children('ul').children('li').children('a').css('color','#ffe300');
    }); 

现在它对我来说工作得很好。您可以通过访问以下页面查看结果:http://tagbees.designforce.us/

Many thanks for Ori and Syed Salman Akbar for being concerned and tried to help me. I tried both methods of Ori and one logic of Syed Salman akbar but in vain. I also tried many other options and finally i got it.

The problem was not in strip LI "mouseleave" function that was and is working fine. when mouseleave the li function is repainting/restore the LI color and background with setting the $Box.css('display','none');

I've made the following changes in the codes.

  1. In my question, the popup box hover function codes were nested in "mouseleave" function of LI. I put the $Box.hover function out from LI "mouseleave" function.

  2. Binded the "mouseenter" and "mouseleave" functions with the $Box as it is a seperate object from strip.

  3. On $Box "mouseenter" function added the codes to repaint the strip LI to make the feel as LI is still hovering and restoring/repainting the LI on "mouseleave" function of the $Box.

have a look the new codes:

    if(options.mousePause)
    {
        obj.bind("mouseenter",function(){
            options.isPaused = true;
            $Box.css('width',200);
            obj.children('ul').children('li').css('background','#f0f0f0');
            obj.children('ul').children('li').children('a').css('color','#000');
            var offset = obj.children('ul').children('li').offset();
            $Box.css('left', offset.left);
            $Box.css('top', offset.top+25);
            $Box.css('display','block');
        }).bind("mouseleave",function(){
            options.isPaused = false;
            $Box.css('display','none');
            obj.children('ul').children('li').css('background','transparent');
            obj.children('ul').children('li').children('a').css('color','#ffe300');
        }); // mouseleave function end
    } // if end
    $Box.bind("mouseenter",function(){
        options.isPaused = true;
        isBoxHover = true;
            $Box.css('width',200);
            obj.children('ul').children('li').css('background','#f0f0f0');
            obj.children('ul').children('li').children('a').css('color','#000');
            var offset = obj.children('ul').children('li').offset();
            $Box.css('left', offset.left);
            $Box.css('top', offset.top+25);
            $Box.css('display','block');

    }).bind("mouseleave",function() { 
        options.isPaused = false;
        isBoxHover = false;
        $Box.css('display','none');
        obj.children('ul').children('li').css('background','transparent');
        obj.children('ul').children('li').children('a').css('color','#ffe300');
    }); 

and now its working fine for me. You can see the result by visiting the page: http://tagbees.designforce.us/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文