代码之家  ›  专栏  ›  技术社区  ›  Thinker

慢速计算机上的jQuery

  •  1
  • Thinker  · 技术社区  · 15 年前

    我正在使用jQuery创建一个在线游戏。由于速度较慢的电脑有很多淡入淡出的效果,我做了一个设置 jQuery.fx.off = true;

    $('<div>'+msg+'</div>').fadeOut(5000,function({$(this).remove()}).appendTo('#msg');
    

    此代码在#msg div中显示消息,5秒后消息消失。可以有许多消息,并且可以随时添加这些消息。什么时候 jQuery。外汇。关=真; $('#id').delay(5000).remove()

    我在jQuery的帮助下寻找它,但什么也没找到。

    1 回复  |  直到 15 年前
        1
  •  2
  •   Deniz Dogan    15 年前

    jQuery.fn.maybeFadeOut = function (time, fun) {
      if (slowComputer) {
        setTimeout(function () {
          $(this).remove();
          if (fun) fun(); // Optionally run the callback function.
        }, time);
        return $(this);
      } else {
        return $(this).fadeOut(5000, function () { $(this).remove; });
      } 
    };