erik-krogh / SudoSlider

The most versatile jQuery content slider
36 stars 24 forks source link

jQuery version detection is broken #63

Closed codener closed 6 years ago

codener commented 6 years ago

First: Thanks for the SudoSlider. We're using it for years and are quite happy with it.


I was wondering why SudoSlider would refuse to use CSS for transitions. When I dug into the code, I found that SudoSlider set usecss to false because it believed the jQuery version was too low.

https://github.com/webbiesdk/SudoSlider/blob/33253a1ea51af256021ba81ddb4c4831369c1552/js/jquery.sudoSlider.js#L74-L76

Unfortunately, the minJQueryVersion function is lying. It will only return true if all digits are greater than the required minimum, which is wrong when it comes to versions numbers.

https://github.com/webbiesdk/SudoSlider/blob/33253a1ea51af256021ba81ddb4c4831369c1552/js/jquery.sudoSlider.js#L2899-L2909

Instead, the function should return early as soon as any digit is greater than required:

    // The minVersion is specified in an array, like [1, 8, 0] for 1.8.0
    function minJQueryVersion(minVersion) {
        var version = $.fn.jquery.split(".");
        var length = version.length
        for (var i = 0; i < length; i++) {
            if (+version[i] < +minVersion[i]) { return FALSE; }
            if (+version[i] > +minVersion[i]) { return TRUE; }
        }
        return TRUE;
    }

Best regards

webbiesdk commented 6 years ago

Nicely spotted 👍

codener commented 6 years ago

Ok THIS was fast :smile: Thanks!