jsor / jcarousel

Riding carousels with jQuery.
https://sorgalla.com/jcarousel/
MIT License
2k stars 734 forks source link

Abilities of the 0.3 branch #352

Closed Dupond closed 12 years ago

Dupond commented 12 years ago

I'd like to convert my carousels to 0.3 branch, in order to fix my focus problems, and the resize problems under Chrome, as discussed in several issues here.

Is there some kind of know limitations with this branch, compared to the 0.2.8 one ? For example :

Furthermore, I've put my config code in an external file : should I use $(document).ready() (as I used to with 0.2.8) ? For the moment, I just have the following code in my config file :

$(function() { $('#carousel-editos').jcarousel()
    .find('[tabindex]')
    .focus(function(e) { e.preventDefault(); e.stopPropagation(); $(this).closest('.jcarousel').jcarousel('scroll', this); });
});

Is that fine ?

Thanx for your help, Dupond

Dupond commented 12 years ago

After all it was not that difficult to fix this issue :)

Here's what I've done :

// The focus must go to the first link of the first VISIBLE item :
$("#carousel-comments").delegate("li:first a", "focusin", function () {
    $("#carousel-comments li.jcarousel-item-first a").focus();
    return false;
});
// After the last link of the last visible item, the focus should go out :
$("#carousel-comments").delegate("li.jcarousel-item-last a", "keydown", function (e) {
    var code = (e.keyCode ? e.keyCode : e.which);
    if (code == 9) { $("#rang3 a").first().focus(); return false; }
});
marya-ivanovna commented 11 years ago

Hello! Everything work's perfectly, but some problem in scrollCallback from this code:

var scrollCallback = function(event, carousel, target) {
    var list  = carousel.list(),
        items = carousel.items(),
        size = carouselCommentsData.length,
        parsed = jCarousel.parseTarget(target),
        first = carousel.last().index() + 1,
        last = first + parsed.target;
    for (var i = first; i < last; i++) {
        if (i >= size) { break; }
        if (items.eq(i).size() > 0) { continue; }
        list.append(createItem(carouselCommentsData[i]));
    }
    carousel.reload();
};

Error from firebug console:

ReferenceError: jCarousel is not defined
parsed = jCarousel.parseTarget(target);
jsor commented 11 years ago

In the meantime, everything was moved under the $namespace, so it is now

$.jCarousel.parseTarget(target)
marya-ivanovna commented 11 years ago

Works like a charm! Many thx!