开发者

jquery Animate issue

开发者 https://www.devze.com 2023-02-27 03:33 出处:网络
I have got a weird problem here, and more interesting thatit works fine on jquery version1.5.2 and doesn\'t on version 1.4.3.

I have got a weird problem here, and more interesting that it works fine on jquery version 1.5.2 and doesn't on version 1.4.3.

So, I am going to drop a piece of the code here:

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

Here 开发者_如何转开发is an item of the 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>

So, when this number>1000px the animation seems cycling the whole items from the begging again, until is going to get in right position

I am not sure if 1000px makes the problem, or it is a coincidence.

Did somebody ever seen that kind of problem and if it is possible to fix it. Or I have kill this 'animate' ?

Thanks !


Ok, I found the problem, it is jQuery core bug, it has limitation on animate, 10000px.

It is easy to fix, just add or change this part of the code:

$.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;

}
0

精彩评论

暂无评论...
验证码 换一张
取 消