2011-04-17 111 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; 

}