【问题标题】:Disabling jQuery animations if user is on a lowend unit如果用户在低端设备上,则禁用 jQuery 动画
【发布时间】:2023-04-09 23:49:02
【问题描述】:

我正在使用 jQuery Mobile 开发一个 HTML5 应用程序,并且我想显示滑动动画slideUp / slideDown 仅适用于功能足够强大的单元。

我不希望低端手机上的人看到滞后的动画,所以我宁愿为他们关闭动画。

我敢肯定之前有人想过这个问题,并且可能为此做了一些插件或解决方案?

【问题讨论】:

    标签: jquery performance jquery-mobile


    【解决方案1】:

    以前有人想过这个:How can I disable a jquery include for low bandwidth connections

    一般来说,假设用户拥有低端设备或带宽低是一个坏主意。更聪明的想法是设置切换功能,让用户自己决定。

    这可以使用:jQuery.fx.off,http://api.jquery.com/jquery.fx.off/

    在这里提琴:http://jsfiddle.net/dnLq49sm/

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>jQuery.fx.off demo</title>
      <style>
        div {
          width: 50px;
          height: 30px;
          margin: 5px;
          float: left;
          background: green;
        }
      </style>
      <script src="//code.jquery.com/jquery-1.10.2.js"></script>
    </head>
    <body>
    
      <input type="button" value="Run">
      <button>Toggle fx</button>
      <div></div>
    
      <script>
       var toggleFx = function() {
         $.fx.off = !$.fx.off;
        };
        toggleFx();
        $( "button" ).click( toggleFx );
        $( "input" ).click(function() {
            $( "div" ).toggle( "slow" );
        });
      </script>
    
    </body>
    </html>
    

    【讨论】:

      猜你喜欢
      • 2014-07-24
      • 2012-04-17
      • 2014-05-20
      • 2016-05-14
      • 1970-01-01
      • 2014-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多