richardscarrott / jquery-ui-carousel

jQuery RS Carousel is a responsive and touch-enabled carousel written on top of jQuery and the jQuery UI Widget Factory providing a full and familiar API in less than 2.6kB minified and gzipped.
http://richardscarrott.github.io/jquery-ui-carousel/
192 stars 56 forks source link

Chrome displays items in incorrect order when using the continuous extension #54

Open richardscarrott opened 11 years ago

richardscarrott commented 11 years ago

When there's over 10 items visible on one page and using the continuous extension the item order is incorrect when going from page 1 to the last page in Chrome and Safari.

Caused by sorting bug with disconnected nodes in Webkit which jQuery, as of version 1.9.0, is vulnerable to - http://bugs.jquery.com/ticket/13331

To fix add nodes before cloning like this:

elems.clonedBeginning = visibleItems
        // add one extra item in case it's partially visible
        .add(this.elements.items.slice(visibleItems.length).first())
            .clone()
                .addClass(cloneClass)
                .appendTo(elems.runner);

Instead of:

elems.clonedBeginning = visibleItems
        .clone()
             // add one extra item in case it's partially visible
            .add(this.elements.items.slice(visibleItems.length).first().clone())
                .addClass(cloneClass)
                .appendTo(elems.runner);

At line 79 - https://github.com/richardscarrott/jquery-ui-carousel/blob/master/js/jquery.rs.carousel-continuous.js#L79