【问题标题】:Disappearing elements while using SHAKE effect使用 SHAKE 效果时消失的元素
【发布时间】:2017-06-21 20:43:28
【问题描述】:

我正在尝试弄清楚这个框架,但我在实现抖动效果时遇到了问题。每次我将鼠标悬停在元素上时,其他 div 都会消失。在小提琴中,我尝试了不同的 JQuery 和 JQuery ui,它正在工作,但选择最新的只是破坏了整个事情。有小费吗?谢谢!

https://jsfiddle.net/w11qknc4/

$( ".box" ).mouseenter(function() {
$( this ).effect( "shake", { direction: "up", times: 4, distance: 10}, 1000 );
$( this ).finish().effect( "shake", { direction: "up", times: 4, distance: 2}, 1000 );
});

【问题讨论】:

    标签: javascript jquery html css jquery-ui


    【解决方案1】:

    此行不是必需的,会导致您的问题:

    $( this ).finish().effect( "shake", { direction: "up", times: 4, distance: 2}, 1000 );

    只需使用:

    $( ".box" ).mouseover(function() {
      $(this).effect( "shake", { direction: "up", times: 4, distance: 2}, 1000 );
    });
    

    如果您希望在另一个效果之前等待效果结束,请参阅使用:

    var start = true,
        delay = 1000;
    
    $(".box").mouseover(function() {
      if (start) {
        start = false;
        $(this).effect("shake", { direction: "up", times: 4, distance: 2}, delay);
    
        setTimeout(function () {
          start = true;
        }, delay)
      }
    });
    

    【讨论】:

    • 您好,感谢您的宝贵时间!我试过了,但是当我删除 finish() 时,我的动画只是在排队。我曾尝试使用 stop 或 clearQueue,但这只会导致我的元素向上移动。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-01
    • 2017-11-22
    • 1970-01-01
    • 2010-11-27
    • 1970-01-01
    • 2020-07-29
    相关资源
    最近更新 更多