jsor / jcarousel

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

Item scroll visible item on add class first and last. #741

Closed rvpatel closed 9 years ago

rvpatel commented 9 years ago

I have display 3 item on slide scroll on by on i want class visible item list on add class first and last. How to fix i have add class first .

var jcarousel1 = $('.jcarousel1');
jcarousel1.on('jcarousel:targetin', 'li', function() {
    $(this).addClass('first');
})
jcarousel1.on('jcarousel:targetout', 'li', function() {
    $(this).removeClass('first');
})

How to add class last ?

rvpatel commented 9 years ago
var jcarousel1 = $('.jcarousel1');

jcarousel1.on('jcarousel:targetin', 'li', function() {
    $( ".jcarousel1 li" ).eq($(this).index() + 2).addClass('last');
    $(this).addClass('first');

});
jcarousel1.on('jcarousel:targetout', 'li', function() {
    $(this).removeClass('first');
    $( ".jcarousel1 li" ).eq($(this).index()+ 2).removeClass('last');
});
jsor commented 9 years ago

Use the firstin, firstout, lastin and lastout events, see http://sorgalla.com/jcarousel/docs/reference/events.html#firstin