【问题标题】:Window width and animation changing on the fly窗口宽度和动画动态变化
【发布时间】:2012-05-17 21:32:27
【问题描述】:

如果使用 ie 并且浏览器窗口宽度低于 1400,我正在尝试编写一个更改动画的脚本。我的代码(动画更改)不起作用,尽管控制台在更改窗口宽度时显示正确的文本。有人可以帮忙吗?

代码如下:

$(document).ready(function() {



  function checkWindow() {


                if ( $.browser.msie ) {

                if ( $(window).width() >= 1400 ) {    

                $("#box1").everyTime(2, function(){                        
                         $("#box1").animate({top:"-20px"}, 3000).animate({top:"-10px"}, 3000);
                      });  
                $("#box2").everyTime(10, function(){                        
                         $("#box2").animate({top:"-100px"}, 2500).animate({top:"-90px"}, 2500);    
                      });        

                console.log("width over 1400");

                } else {

                $("#box1").everyTime(2, function(){                        
                         $("#box1").animate({top:"-200px"}, 3000).animate({top:"-100px"}, 3000);
                      });  
                $("#box2").everyTime(10, function(){                        
                         $("#box2").animate({top:"-200px"}, 2500).animate({top:"-900px"}, 2500);    
                      });    

                console.log("width under 1200");      

                }

                }

   }

var resizeTimer;


$(window).resize(function() {
     clearTimeout(resizeTimer);
     resizeTimer = setTimeout(checkWindow, 100);
});





});

【问题讨论】:

    标签: jquery animation window width


    【解决方案1】:

    您可能需要在某个地方调用 $.stopTime 吗?否则,在调整窗口大小后,$.everyTime 调用将持续存在。

    【讨论】:

      猜你喜欢
      • 2012-09-02
      • 1970-01-01
      • 1970-01-01
      • 2013-09-13
      • 1970-01-01
      • 1970-01-01
      • 2014-05-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多