Slideshow bug solved!

Something went seriously wrong with our slide show. In first instance, it looked like it worked perfectly on a local machine, but on our deploy server it refused to do the animation. After a decent debug session we found a tiny little mistake, so the animation could not be executed.

At the initialization of our slide show, we take the image width, so we know how many pixels we have to slide. The bug was in our jQuery selector. jQuery returns an array, so the width() function returned null.

We changed:

imgWidth    = jQuery("img.slideshow, this").width();

into:

imgWidth    = jQuery("img.slideshow:first").width();

In our case, all the images have the same width, so it’s save to take only the width of the first element with the :first operator.

Be the first to share your knowledge earthling

Leave a Reply