1

I have managed to build a custom carousel from code I had for a slider.\

Now all is working but I just have a little issue with lining things up! Here is what I have so far:- http://goo.gl/lw4FVS

What I want is for 4 slides to always show within the central none faded area. As you can see it's just off center.

I have to make the four carousel items show in the center no matter what screen size you are using.

My jquery code is as follows:-

var carouselsliderWidth = 0;
var carouselsliderWidth = 0;
var carouselimageWidth = $('.carousel-slider .carousel-slide:first').width();
var carouselcount = 0;
var carouselimageCount = 0;
var carouselimageLeft = 0;

carouselrepositionImages();

$('.carousel-slider .carousel-slide').each(function(){
    carouselsliderWidth = carouselsliderWidth + $(this).width();
});

$('.carousel-slider').width(carouselsliderWidth);

//alert(carouselimageWidth);

function carouselrepositionImages() {
    carouselimageLeft = 234 - (($(window).width() - 234) / 2 );
    $('.carousel-slider .carousel-slide').css('left','-'+carouselimageLeft+'px');
}

$('a.carousel-move-left').click(function(){
    if($('.carousel-slider .carousel-slide:not(":animated")').length != 0) {
        $('.carousel-slider .carousel-slide:first').addClass('carousel-move-0');
        carouselfirstImage = $('.carousel-slider').children('.carousel-slide.carousel-move-0').clone();
        $('.carousel-slider').width(carouselsliderWidth+carouselimageWidth);
        $('.carousel-slider').append(carouselfirstImage);
        $('.carousel-slider .carousel-slide').animate({'left':'-='+carouselimageWidth}, 500 ,function(){
            $('.carousel-slider .carousel-slide:last').removeClass('carousel-move-0');
            $('.carousel-slider').children('.carousel-slide.carousel-move-0').remove();
            $('.carousel-slider .carousel-slide').css('left','-'+carouselimageLeft+'px');
            $('.carousel-move-0').removeClass('carousel-move-0');
        })
    }
    return false;
});

$('a.carousel-move-right').click(function(){
    if($('.carousel-slider .carousel-slide:not(":animated")').length != 0) {
        $('.carousel-slider .carousel-slide:last').addClass('carousel-move-5');
        carouselfirstImage = $('.carousel-slider').children('.carousel-slide.carousel-move-5').clone();
        $('.carousel-slider').width(carouselsliderWidth+carouselimageWidth);
        $('.carousel-slider').prepend(carouselfirstImage);
        $('.carousel-slider .carousel-slide').css('left','-'+(carouselimageLeft+carouselimageWidth)+'px');
        $('.carousel-slider .carousel-slide').animate({'left':'+='+carouselimageWidth}, 500 ,function(){
            $('.carousel-slider .carousel-slide:first').removeClass('carousel-move-5');
            $('.carousel-slider').children('.carousel-slide.carousel-move-5').remove();
            $('.carousel-slider .carousel-slide').css('left','-'+carouselimageLeft+'px');
            $('.carousel-move-5').removeClass('carousel-move-5');
        })
    }
    return false;
});

$(window).resize(function(){
    carouselrepositionImages();
    //resizeOverlay();
})

Any help or advice on how to do this would be great. Thank you kind people.

0 Answers0