简体   繁体   English

Jquery Mouseover对象无限循环与Flippy插件

[英]Jquery Mouseover Object Infinite Loop with Flippy Plugin

I want to flip a simple image on "mouseover" with the Jquery plugin Flippy, the problem now is that it loops when I "mouseover" it. 我想用Jquery插件Flippy在“mouseover”上翻转一个简单的图像,现在的问题是它在我“鼠标悬停”时循环。 I am a JS beginner, hence I am sorry for this maybe rather simple question.. 我是JS的初学者,因此我很抱歉这可能是一个相当简单的问题。

My code looks like this: 我的代码看起来像这样:

$(".chameleonclass").mouseover(function() {
$(".chameleonclass").flippy({
content: '<img class="top" src="a1records.jpg" alt="a1records"/>',
direction:"TOP",
duration:"750",
onFinish:function(){
}
});
});

Now, I guess I have to add something in the onFinish part. 现在,我想我必须在onFinish部分添加一些内容。 I have tried everything I have come up with (end, stop etc.) but nothing really works, the object just loops and flips multiple times without an end when I mouseover the oject. 我已经尝试了我想出的所有内容(结束,停止等),但没有什么真正起作用,当鼠标悬停在对象上时,对象只是循环并翻转多次而没有结束。

Could you possibly help me? 你能帮帮我吗? Thanks in advance for reading and have a great weekend Tim 提前感谢阅读,并有一个美好的周末蒂姆

I had the same problem but finally managed to think it through. 我有同样的问题,但终于设法思考它。 The idea is to turn the event trigger off when it first time happens. 我们的想法是在第一次发生时关闭事件触发器。 And then trigger it on again when your mouse leaves. 然后在鼠标离开时再次触发它。

I hope you can make sense of the code, but I got it working with this. 我希望你能理解代码,但我得到了它。

<script>

    $(document).ready(function(){
        $(".flipbox").on("mouseenter",function(){
                $(this).flippy({
                    color_target: "red",
                    verso:"jippii",
                    duration:"500",
                    direction: "TOP",
                });
                $(".flipbox").off("mouseenter");
        });
        $(".flipbox").on("mouseleave",function(){
                $(this).flippyReverse();
                $(".flipbox").on("mouseenter",function(){
                $(this).flippy({
                    color_target: "red",
                    verso:"jippii",
                    duration:"500",
                    direction: "TOP",
                });
                $(".flipbox").off("mouseenter");
        });

        });
    });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM