jCarousel Lite – A jQuery plugin

jcarousellite-img-02

jCarousel Lite is a jQuery plugin that carries you on a carousel ride filled with images and HTML content. Put simply, you can navigate images and/or HTML in a carousel-style widget. It is super light weight, at about 2 KB in size, yet very flexible and customizable to fit most of our needs.

Did I mention that it weighs just 2 KB?

As if that wasn’t enough, the best part is yet to come… You don’t need any special css file or class name to get this to work. Include the js file. Supply the HTML markup. Then, construct the carousel with just a simple function call.

Visit the project page for more information. There you can find a lot of demos and exhaustive documentation. This blog entry is just a teaser for further exploration.

Installing and getting it to work is as trivial as following the 3 steps given below…

Step 1:

Include a reference to the jQuery library and the jCarouselLite plugin. You can download jQuery here and jCarouselLite here. If you like interesting effects, include the Easing plugin as well (Optional). You may also want to use a compatibility easing plugin if you want to use old easing names. If you would like to navigate the carousel using mouse wheel, then include the mouse-wheel plugin as well (Optional).

<script type="text/javascript" src="path/to/jquery.js"></script>
<script type="text/javascript" src="path/to/jquery.jcarousellite.js"></script>

<!-- Optional -->
<script type="text/javascript" src="path/to/easing.js"></script>
<script type="text/javascript" src="path/to/mousewheel.js"></script>

Step 2:

In your HTML file, provide the markup required by the carousel (a div enclosing an ul). You also need the navigation buttons, but these buttons need not be part of the carousel markup itself. An example follows…

<button class="prev">&laquo;</button>
<button class="next">&raquo;</button>

<div class="any-class">
    <ul>
        <li><img src="image/1.jpg" style="width:150px; height:118px;"></li>
        <li><img src="image/2.jpg" style="width:150px; height:118px;"></li>
        <li><img src="image/3.jpg" style="width:150px; height:118px;"></li>
        <li><img src="image/4.jpg" style="width:150px; height:118px;"></li>
        <li><img src="image/5.jpg" style="width:150px; height:118px;"></li>
    </ul>
</div>

Step 3:

Fire a call to the plugin and supply your navigation buttons. You just managed to architect your own carousel.

$(function() {
    $(".any-class").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev"
    });
});

If you have any comments/suggestions/requests, feel free to drop in a comment or reach @ganeshmax in twitter.

 

Update

Based on popular request, jCarouselLite has been updated to support jquery 1.2.x versions. Goto the download page and download version 1.0.1 to enjoy jquery 1.2.x support. Since Firefox 3 has some issues with $(document).ready() function, try using $(window).load() instead if you face any problems. Hopefully a future version of Firefox or jQuery will fix the problem.

Ganeshji Marwaha

I spend my days as the Director of Technology for Mobility practice and help my clients design enterprise and consumer mobile strategies. Mobile Payments, Digital Wallet and Tokenization technologies are my areas of specialization

  • ali kkhan

    Hi : first thanks for great plugin.
    i have little problem ,
    jQuery(“.jCarouselLite-related”).jCarouselLite({
    btnNext: “.next-rel”,
    btnPrev: “.prev-rel”,
    });
    working fine with 3 or many images but
    if there is only 1 image , it does not work ? any solution.

  • cbf

    @Ganesh
    @kkhan

    Thats caused by the circular setting.

    When circular is true and there are less items than ‘visible’ (default 3) states, the carousel doesnt work.

    So, if you have less then visible items, just set circular to false.

  • Hi, this is a great plugin, but it doesn’t work nicely on liquid design. Is there anyway we can make it work on liquid layout.?

  • Valentin

    Good day,

    is it possible to reset (unbind) jCarouselLite?

    I was trying these code:

    but its not helped me (((

  • Valentin

    Good day,

    is it possible to reset (unbind) jCarouselLite?

    I was trying these code:

    jc.jCarouselLite = null;
    r.unbind(‘click’).hide();
    l.unbind(‘click’).hide();

    but its not helped me (((

  • sud

    when i was trying to use scroll with circular ‘false’, it wasn’t working.
    Could you please resolve this issue?

  • Miลกa

    Hey man,
    thanks for the plugin, it’s great!
    However, I have a problem. These are my init settings:
    $(“.slides”).jCarouselLite({
    vertical: false,
    hoverPause:true,
    visible: 3,
    auto:5000,
    speed:500,
    scroll: 3,
    btnNext: “.arrow-r”,
    btnPrev: “.arrow-l”,
    mouseWheel: true,
    easing: “easeOutQuad”,
    beforeStart: function() {
    Cufon.refresh();
    }
    });
    });

    I have photos sliding. Now, the problem is that in most cases everything is working fine, but when I have any number of photos which is a product of three (for example – 3, 6, 9, 12 or 15 photos), the slider is not working. Actually, when I check in the Firebug, all the elements are created, but are not visible. Any help?

  • Safwen

    Hi,
    There is a problem issue in the plugin with 1 item in the list.
    If the list (ul) contains 1 element, the carousel does not show nothing!
    How to fix that? Maybe someone fixed the problem.
    Thanks a lot

  • Kenneth

    Hi! Your plugin is awesome! Thanks for sharing it.
    I had an extra requirement on my webpage, which was for the prev and next buttons to be hidden in case the total items were less than or equal to the visible items. I modified your plugin to make that work, and added a new “hidePrevNext” option to the parameters.
    I thought that maybe you would want to include this in a next version. Let me know if you do, I can send you the patch.

  • Jeff

    Hello,

    I am using jCarrouselLite with jQuery 1.6.3 and I have noticed a little problem with li alignment that have margin or padding.
    This is due to line 247 that use li.height() and li.width() to change the CSS value of li elements. The heigth or width are different from liSize on line 243 that use height(li) or width(li). As the ulSize is calculated with liSize, so my elements are not correctly placed.

    Since I change line 247 to use height(li) and width(li), I don’t have problem.

    Regards.

  • Sam

    Hello

    I am relatively experienced with HTML & CSS, but I cannot find any help as to where each of the 3 parts of the installation go in my html file…
    Do I need to upload the jquery & jCarouselLite to my server?
    Where does the script for the buttons go in my with the css or next to the images list?

    I have played around and cannot get any further than a standard list of images…

    Please can someone help with some real step by step instructions…

    Thank you

    Sam

  • Melanie

    Sam,

    Ganeshji has already provided a helpful document that answers all your questions: http://www.gmarwaha.com/jquery/jcarousellite/#install

    Additionally, to Demo pages show every possible configuration of the carousel.

    Your control buttons can go anywhere in your document. You just have to tell the little script that calls the plugin what the class names are for your back/forward buttons.

    You may want to read up a bit on the general topic of including scripts in HTML documents. Generally, you do all the linking in the portion of the document, as well as the little script block that fires the call to the plugin to get it all initialized.

  • Michl

    Hello,

    i got an issue with your jCarousel Lite and IE 8.
    The “Slider” slides some pictures automatically.
    Now if you click into any Testbox on the Page, the textcursor flickers to the interval of the carousel.
    Hope you write back as soon as possible ๐Ÿ™‚

    Best Regards

  • Jay

    Hi,
    I’m working with your jcarousel lite plugin. The question I have is about the slider div itself. When I construct the slider, all the images show with the same width/height. Whatever size I specify is ignored, and it just computes it’s own width/height to use. This distorts the images because the original aspect ratio is not maintained. Is there a way to preserve the original aspect ratio? So perhaps the height can be fixed for all the thumbnails, but the width can vary based on the original image. Thanks
    Jay

  • MI

    HI Sir:
    There are only three pictures i can see! how could see more pictrues??

  • Bliss

    Hi,

    I have implemented jcarousellite for my carousel hwich works fine with mouseclick but not when I have a focus on Next/Prev divs and hit “Enter”. Could You please help with this?

    Thanks in advance.

  • die besten hundetrainings tipps unter http://www.hund-trainieren.de/

  • Dominic

    Hello there,

    Firstly I’d like to say that this jCarousel is awesome! But i’m having some issues.

    Here’s an example of it working correctly with my drop down menu with the style display:block http://yellowduckhouse.co.uk/vineyards-test/

    But… I need the drop down hidden to begin with. And when this happens you can see the result here http://yellowduckhouse.co.uk/vineyards-test/index2.html

    I’ve tried forcing width’s and height’s but I’m having no luck…

    Do you have any ideas/solutions?

    Very much appreciated for your help in advance.

  • enric

    hi,

    Great work many thanks!
    I would like to ask you how do I configure a space between the different images. I am using the auto option and I would like to have some space between them, how can I configurate that?

    many thanks!

  • Curious if there is a non minified version floating around somewhere. I tried searching through the comments but many are from years ago.

    Great product, really amazing design and effects!

  • Andy

    Using the carousel which works fine, but for each li element i have a mouse over – overlay appear with just some text, this also works fine. However if i have ‘circular’ set to TRUE as soon as it gets to the loop part the javascript seems to fail on the overlay.

    from the firebug console i can’t see anything thats breaking or firing an error.

    And when i get past the ‘join’ part and slide on to the next lot of li’s it works again. It seems like there is something happening at the join that breaks it. Even when i click back on the first li’s that show and go the other way the same thing happens.

    Any ideas?

    thanks in advance.

  • Jake

    Hi, the plugin is very useful.

    However, I have a small problem with it when the list is not exactly divisible by the number of items being displayed. For instance, if the list has 11 elements and the visible size is set to three, out of the box the plugin never displays the last 2 items in the list.

    To address this I changed the if else check in the go function to:

    if (to 0) curr = 0;
    else return;
    } else if (to > itemLength – v) {
    if (to < itemLength) curr = itemLength – v;
    else return;
    }
    else curr = to;

    Thanks.

  • Sabrina

    Nice work!

    I found a (possible) bug that if scroll is set to 4, and there is only 7 items, and circular is set to false, then the carousel does not paginate to next set of items ( 5 to 7).

    $(“.carousel”).jCarouselLite({
    btnNext: “.next”,
    btnPrev: “.prev”,
    visible: 4,
    scroll: 4,
    speed: 1600,
    circular: false
    });

  • Sabrina

    Jake, which lines did you replace with your correction? I have the same issue. Thanks!

  • Sabrina

    To those who are having issues with list is not exactly divisible by the number of items being displayed when circular is set to false,

    here is the solution from a previous post:
    http://plugins.jquery.com/node/8145

    and the details:
    http://plugins.jquery.com/files/issues/jcarouselPatch.js_.txt

  • Is there a way that I can send you some screenshots so that you can see what I am talking about?

  • I have very much enjoyed your website and have bookmarked you. I am new at integrating Jquery galleries. I am having a problem with the JqueryCarouselLite Implementation… Someone please help…. Here is the website: http://www.mmechicago.com/Developed%20Sites/Briggs%20Tree%20Service/index.html#

    Step 1: I have called and linked all the necessary Jquery script files that you requested within the head section of my webpage. As well as the function call for the class=”gallery”.

    $(function() {
    $(“.gallery”).jCarouselLite({
    btnNext: “.next”,
    btnPrev: “.prev”
    });
    });

    Step 2: Supplying the Markup. I also supplied the markup you mentioned within the body of the webpage.

    Question: Why doesn’t it work?

  • Sebastian

    Hello!
    JCarouselLight is great (when pauseCarousel is added ๐Ÿ˜‰ ) but i have a problem with it. Please help me on that.

    I NEED the carousel to span over 100% width of the document but it only uses only 1666px instead of about 1866px.

    I really need help on this.

    CSS Setup:

    .widget-area#primary,
    .widget-area#tertiary {

    float: left;
    width: 100%;
    }

    .widget-area .prev,
    .widget-area .next {

    float: left;
    width: 20px;
    height: 100px;
    }

    .widget-area .next {

    float: right;
    }

    .widget-area#primary .widget-container,
    .widget-area#tertiary .widget-container {

    overflow: hidden;
    height: 100px;
    width: 100%;
    margin: 0 25px;
    border: 1px solid red;
    }

    .widget-area#primary .widget-container > ul,
    .widget-area#tertiary .widget-container > ul {

    width: 100%;
    height: inherit;
    }

    .widget-area#primary .widget-container > ul > li,
    .widget-area#tertiary .widget-container > ul > li {

    height: inherit;
    width: 25%;
    float: left;
    overflow: hidden;
    }

    Best regards.

  • Hi all,
    I use jCarousel all the time, thanks for the plug in. With the latest website I built, I added some controls to fade in and fade out the carousel controls. You can check it here: http://www.iconsnowskates.com

    One thing I noticed… has anyone else had an issue with Chrome and Safari (webkit) where the images don’t load fast enough, and the carousel gets an incorrect height? Sometimes when the page loads, the carousel looks fine, other times it is only set to 20px high (on the LI element). Maybe I need to pause the loading of the carousel until all the images are loaded?

    Thanks again.

  • Hi, I used your plugin, but I had to change the code. There is problem e.g. 3 visible pics, 7 total, 2 scrolling and non-repeatable (the last one doesn’t appear). And when non-repeatable plugin load, the button prev isn’t disabled. I can send you my new version, which repairs these bugs. Sry for my english.

  • Brenda

    Hi,
    Love the plugin and have used it a few times. Way lighter and easier to implement that other carousels.
    I have run into an issue where I have one element which has content that has another script which is meant to animate something just once using (backgroundpos plugin). Seems like I have a conflict with that and the carousel which is set to autoscroll.
    Carousel itself is still working, but the animation in the seems to start once and then starts over again and then does it’s callback which is mean to show another element afterwards. The animation moves the background on a div. After the carousel comes back around to that div, the background position on the div reverts back to the original.

    I have tried debugging but don’t get very far with Firebug. Any help or pointers would be greatly appreciated.

  • Elan Noy

    I use the plugin to rotate blocks of html that each contain the summary of a person’s information (it contains a name, image and some text).
    It all works fine except when I have in the text lists. The plug in adds css to the ul and changes the behavior of the page.

    Can you please provide a work around or a patch?

    Thanks

    Elan

  • alan

    I’m having a similar issue to the not exactly divisible by the number of items displayed problem, but with circular set to true:

    I have 13 items to scroll, 3 at a time. When I get near the end, the 3 being displayed ‘jumps’ 1 along – I’m assuming this must be the plugin adding items from the start to the end.
    However if I knock one off the list, so I have 12, it all scrolls fine.

    Anyone else have this issue?

  • Julia

    On your “Known Issues” page it says

    “If displaying images in your carousel, set the “width” and the “height” attributes for every image. This is required only if you construct the carousel on document.ready event. If you are using window.load, these attributes are not required.”

    This doesn’t seem to be true with the Chrome browser. I need to set width and height with window.load, too, as it won’t work otherwise.

  • Followed documentation to the letter and auto scrolling is impossible to disable. This is causing me to switch to another solution. If it is possible to disable autoscroll please update documentation.

  • When start is set to 0.5, after 3 next clicks it glitches.

  • Everything works FINE! That’s the only problem in ie6 with the display of png (does not support transparent background). Because of this was connected DD_belated_PNG, which fixes this bug in ie6. This is only a picture disappeared, the main thing they have but not displayed. Are there any suggestions about this?

  • cc

    Hi,

    I have an issue with your plugin. I have a number of visible items set to 5, however if when creating the list dinamically the number of is = 2 the carousel only displays 1 item.
    However, when displaying 1, 3, 4 and 5 I do get the same amount of items.

    Is there any way to fix this without having to change the amount of visible items ?

    Thanks,
    cc

  • Matt

    great little tool. one issue though…

    let’s say i have a carousel. in it i can have 5 to 12 items. i want to set sroll: 4. scroll shifts by 4 if there are 4 to scroll to… but… if there are only 5 items it doesn’t scroll at all.

    what would be great is if i can set scroll: 4, but if there is only one more item, it should just scroll to the one more item. right now it doesn’t scroll at all if there is only 5. is this something that can be addressed? would it be possible to say scroll by x or scroll by whatever is left if there is not enough for a full scroll by x? is it possible to to determine the number of items in the set?

    thanks!

  • Guillaume

    Very nice, plus it does (almost) exactly what I want.
    May be two more features and a bug fix would be great !
    First the bug, [on circular with external control] when you roll after the last item (then back to the first one) you are on a clone(clone of the first) item that is at the end of the list. If at this moment you try to go the the second (clicking an external control), it will roll backward. This does not occur when pushing next (neither on letting it “auto roll”). It must be just a small glitch caused by a little piece of code forgotten in one little case (as I guess).
    Then for the 2 features : It would be awesome to be able to set ourself the size of the carousel with options (and then specify alignement).
    Next would be to add the ability to set ourself the “rolling method” like with this kind of option “scrollMethod:function(ul,currentLi,targetLi)”.
    yet this last feature is more of a bonus assuming that I can do most things with beforeStart and afterEnd.

    Re-reading myself i really feel like some self concious/know it all prick that tells you what to do or something ๐Ÿ™ That is absolutely NOT the case, I think you work is awesome and I am not able to do the same (beleive me I tried) so I just try to say : great job and thank you it helps me a lot !

  • Thanks a lot!
    It’s what I’ve wanted! But there is a problem…
    When I put include pages inside the list itens, the slider cut part of the smallest one! I solve this with a fixed height for the , but it makes my site looks horrible!
    Have anyone an idea?

  • I noticed that when I use circular:false and visible:1 and I am displaying images with width and height attributes. The width of the first image constrains the following images to that width, if the following images are wider than the first image.

  • Gerhard van Zyl

    Thanks for a great plugin.
    There are a couple bugs when you use fractions for visibility. The first is that when when circular is false, you only even see part of the last item in the queue. The fix is to use math.ceil on line 300 in the source:

    } else { // If non-circular and to points to first or last, we just return.
    if(toMath.ceil(itemLength-v)) return;
    else curr = to;
    }

    The other is that when circular is false, the fractional image is displayed on the left instead of the right. (It might be good to make this configurable?)
    I did not look into the cause of the second issue.

  • Hi,

    This question may have been asked before but with so many comments, I can’t go through of all of them.

    I’m using this plugin to displays tweets. Basically it’s profile images with text besides them. Most of the time this works fine. Sometimes however, the text is cut off with the final line(s) not showing. What can I do about this? I don’t know beforehand how long the tweets are going to be and I can’t tell what causes the problem exactly.

    See: http://www.reekx.nl/ and http://www.reekx.nl/weblog/ (scroll down)

    – Walter

  • Gotcha

    Hi,

    I’ve used 2 carousel lite to replace the original one but I can;’t seem to find how i can :

    1. change the “slPrev” to a disabled state on load
    2. change the image to a grey image (indicating a disabled state)
    3. similarly for the slNext when i reach the end of the carousel.

    I have a roll over image for the next and previous…

    Can anyone help me?
    Otherwise, this version is much better than the original version … which has a weird behaviour in Chrome when you click too fast on the arrow.

  • Gotcha

    Sorry mark up was not displayed … hopefully this time it does…
    here the code below:

    <div class=”slPrev” >
    <img src=”../Images/prev_dn.gif” alt=”Prev” border=”0″ name=”slPrev” onmouseout=”MM_swapImgRestore()”
    onmouseover=”MM_swapImage(‘slPrev’,”,’../Images/prev_up.gif’,0)” /></div>

  • hi,
    I am new in this field.fresher web designer.
    I have downloaded all js files mentioned above.
    but its not working.And I was looking this effect since last week for my 1st project.
    pls pls help me.

    Sarita

  • Pingback: Javascript breaking a page in Firefox 3.6()

  • Andrea

    Very nice plugin. Easy to customize.
    One question: I have pictures of same height but different width (some are 100px, others are 75px). Your plugin takes the bigger width no matter what I do. Is there any workaround?
    Thank you

  • First off, I love the script- Simple and functional! I am implementing it with a 3-up style on a dynamic site – but I would like the first element to be centered (in case there are only 1 or 2 items). I have tried using start: -1, and at first it seems to do the trick. However, when I click the back and get to the end of the list, I have to click twice for it to go back to the end. Is there anything I can do to fix this?

    Thank you and thanks again for such a great plugin! ^_^