2011-04-17 131 views
1

我有一个奇怪的问题在这里,更有趣的是,它工作正常jquery版本1.5.2和不在版本1.4.3。jquery动画问题

所以,我要放下了一块这里的代码:

$('.slides .items').animate({ 
    left: number + 'px' 
}, 500, 'swing'); 

这里是HTML的一个项目:

<div class = 'slides'> 

       <div class = 'items'> 

        <div class = 'item' style = 'background: url(img/slides/slide-1919.jpg) no-repeat;'> 

         <div class = 'nav'> 
          <div class = 'back link' onclick = 'changeSlide(-1);'></div> 
          <div class = 'forward link' onclick = 'changeSlide(1);'></div> 
         </div> 

         <div class = 'title'><span class = 'textBuffer'>1919</span></div> 

         <div class = 'contentTitle'><span class = 'textBuffer'>The first Loblaw <em>Groceterias</em> store opens in Toronto</span></div> 

         <div class = 'content'><span class = 'textBuffer'>The new self-serve, cash-and-carry concept of grocery retailing is a big hit with customers, who take advantage of quality goods at lower prices. Within a decade, the Loblaw chain expands to more than 70 stores in Ontario alone.</span></div> 

        </div> 
              ........ 

</div> 
</div> 

所以,当这number>1000px动画似乎循环的从乞讨的整个项目再次,直到要进入正确的位置

我不知道如果1000px造成的问题,或者这是巧合。

有人见过这种问题,如果有可能解决这个问题。或者我杀了这个'有生命的'?

谢谢!

+0

如果它工作正常,在1.5.2为什么你想开发旧版本? – wdm 2011-04-17 21:48:45

+0

我不能升级到1.5.2,在我的情况下,我必须使用旧版本 – AlexC 2011-04-17 21:54:22

+0

@alexander,我不认为有任何问题的版本的jQuery,它的主要是你的HTML或代码的一些问题...发布你的HTML也 – kobe 2011-04-17 22:27:43

回答

2

好吧,我发现这个问题,它是jQuery核心bug,它对animate,10000px有限制。

这是很容易解决,只需添加或更改这部分代码:

$.fx.prototype.cur = function(){ // we are overwriting this function to remove limiting of the size of the 

    if (this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null)) { 
     return this.elem[ this.prop ]; 
    } 

    var r = parseFloat(jQuery.css(this.elem, this.prop)); 
    return typeof r == 'undefined' ? 0 : r; 

}