bxslider-3 icon indicating copy to clipboard operation
bxslider-3 copied to clipboard

bxslider breaks jQuery.animate() in IE < 9

Open PhilippSoehnlein opened this issue 13 years ago • 6 comments

If bxslider is included in a webpage that includes another module which uses jQuery.animate(), the other module may break.

Here is a reduced testcase: http://jsbin.com/iluwus/11

Here is the same version in which bxslider isn't included (this one works): http://jsbin.com/iluwus/9

IE < 9 throws an "Invalid argument" exception, because there is a NaN applied to the animated objects top coordinate in jQuery.fx.step._default:

fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;

This happens because bxslider overwrites the jQuery.fx.prototype.cur function and skips the additional check that the original jQuery function does:

// Get the current size
cur: function() {
    if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
        return this.elem[ this.prop ];
    }

    var parsed,
        r = jQuery.css( this.elem, this.prop );
    // Empty strings, null, undefined and "auto" are converted to 0,
    // complex values such as "rotate(1rad)" are returned as is,
    // simple values such as "10px" are parsed to Float.
    return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
},

PhilippSoehnlein avatar Feb 08 '12 08:02 PhilippSoehnlein

I'm having the same issue but with the integration of Lightview 3. I'm sure it's related to the same problem where jQuery.animate() is called because it throws an error when the Lightview window is just about to expand.

Here's a dev link so that you can see what's happening: http://postcardmaniaweb.com/websites2/ReelClear_new/ Pull the link up in IE8 or below and click any of the videos in the rotating bxSlider. The error that's thrown is:

SCRIPT87: Invalid argument. jquery.min.js, line 4 character 23894

I've seen a lot of other jQuery.animate() related errors when using bxSlider. How soon can we expect a fix?

thanks!

Concept211 avatar Mar 28 '12 19:03 Concept211

Update the following function at the end of the jquery.bxslider.js file

    jQuery.fx.prototype.cur = function(){
    /* START OF ORIGINAL */
    //  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 r && r > -10000 ? r : 0;
    //  return r;
    /* END OF ORIGINAL */

            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 ) );
            // Empty strings, null, undefined and "auto" are converted to 0,
            // complex values such as "rotate(1rad)" are returned as is,
            // simple values such as "10px" are parsed to Float.
            return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
    }

dallasclark avatar Apr 10 '12 11:04 dallasclark

Just wanted to say thank you! I got your message a while back but just realized I never thanked you for your time and work :)

Concept211 avatar May 23 '12 14:05 Concept211

Thanks dallasclark

kkarkos avatar Jun 25 '12 21:06 kkarkos

@dallasclark

Many thanks for the solution to this tricky and annoying issue.

shoaib-ahmad avatar Oct 22 '12 07:10 shoaib-ahmad

Just came across this issue, thanks!

jvechicago avatar Feb 01 '13 04:02 jvechicago