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

  • I have just migrated a site using your excellent script. Sadly though your script worked well on the original server it doesn’t work on the new.

    Would this be anything to do with the current temporary URL?

    All links to the scripts are correct from what I can see.

    Hope you can help.

    Crispin

  • Further to my last message here. I migrated the website to a testing server with a proper domain set up.

    The script is still non functioning. I can’t think what might be effecting it.

    Some clues what to look for would be appreciated.

  • Hello, I have enjoyed working with jCarousel Lite.

    I have been having problems with my installation not being compatible with Internet Explorer 7 and below. The images drop below the next div. Do you have any suggestions that may assist me in fixing this problem?

  • this is very useful! i will try it for my web. thanks

  • Jeremy Duenas

    I’m getting a weird bug where at random the width of my items is increasing. For example:
    Here’s how it should look
    http://i.imgur.com/j8vCV.png
    Here’s how at random it looks:
    http://i.imgur.com/hTdEN.png

    disregard the misplaced navigation up top, that was due to HTML/CSS mistake on my part.

    I’m pretty sure it’s caused by the script because when I remove the script from the page I can’t duplicate the issue. Any help would be mucho appreciated. Thanks!

  • jeremy duenas

    I should note that I can confirm with Firebug that my width on the items jump from 290px to 481px. So it’s not like it’s doubling or anything weird like that.

  • Mike

    I enjoy your carousel! Is there a way to link from the navigation to a specific slide?

    For example, About links to slide 4.

  • I have 9 images in my carousel.

    When I navigate up my list and wrap around from image 9 to image 1, image 1 returns an index of 10.

    If I go directly back down, image 9 will return an index of 9. But if I start on image 2 and go down to image 1 then wrap around to image 9, image 9 will return an index of 0.

    Similarly, going directly back up from image 9, image 1 will return an index of 1. And if I go down to image 8 and then back up to 1, image 1 will again return an index of 10.

  • I would like to start by saying what a great script this is. Thank you so much. I am using the script twice in the website provided and it works great but I am having some issues in IE7 with the vertical scroll I am using to scroll through a list of testimonials. I have looked through the dimensions being calculated and it all seems good but after scrolling there is an offset in the alignment which gets worse with each scroll. it is probably an error in my css but any help would be much appreciated.

  • Mohammed

    thanks a lot for this script, its great
    but i have some problem that if i want the image stop scrolling when the mouse over it ,how can I do that?

  • Mital

    Can i set left to right in auto scroll

  • I have a problem with Chorme, and i do not know what it is.Because, only .next and .prev are show, all images is disapear, who can help me?, please!, send me an email in dannie.haui@gmail.com

  • chow

    hi
    i have one image showing in carousal.
    every image have one ID. how to get that image id when the image active in carousal..
    any one help me in that pls..

  • Scott

    My slider is functioning fine, however anchor tags are null on every page minus the first one. Any ideas what could be causing this?

  • Abdul Wahhab

    how can i make this work for arabic website i want it to scroll the other way around

  • Hussain Al-Khalaf

    I’ve seen a small but annoying bug, the plug-in will change the css to the required UL>LI and all nested also…

    so if you apply jCarousel Lite to a carousel that contains list’s inside it… the nested lists will be affected also with CSS changes…

  • Volik

    Just like ‘1313. Mr. Cloud’ have same problem with the Chrome(17.0.953).

    When page is loaded there no image. Reload cann’t be helpful. But when I click on the active directory, the carousel load the images.

    Same problem goes in Opera(11.61). Fierfox() shows all correct.

    Any reason why it happens?

    Will be thanks for any ideas. Great carousel, very light and easy. So I choose it for several my sites. Only annoying this ugly bug.

  • Volik

    Just like ‘1313. Mr. Cloud’ have same problem with the Chrome(17.0.953).

    When page is loaded there no image. Reload cann’t be helpful. But when I click on the active directory, the carousel load the images.

    Same problem goes in Opera(11.61). Fierfox(10.0.2) shows all correct.

    Any reason why it happens?

    Will be thanks for any ideas. Great carousel, very light and easy. So I choose it for several my sites. Only annoying this ugly bug.

  • Volik

    issue 1319 SOLVED!

    Just need to set weidth and height to picture. The reason – Chrome and Safari does not calculating width/height automatically

  • Sam

    Hi, This is great. Nice explanation of every thing. We have a requirement to display 5 images and scroll 5 at once. I am able to do it with your app if I have enough images to display on the scroll. Otherwise the scroll is not working. We want to show white space in the place of images if we don;t have enough categories. Is there a solution?

  • Jan

    Hello there, is there a way for the non-circular mode to jump to the beginning when the carousel reaches the last item?

    Thanks!
    – Jan

  • Zidaps

    I’m having a problem getting this to work in internet explorer.

    I get: Object doesn’t support this property or method – line 748 character 6

    line 748 looks like this… $(“.anyClass”).jCarouselLite({

    Any ideas on how to resolve this? thanks.

  • Sam

    Zidaps,

    Try running your page on google chrome and do “inspect element”. I am guessing your page is not able to load JCarousellite.js. If there is a “404” error then it’s the problem. HTH!

  • Zidaps

    Hi Sam,

    It works great in chrome, firefox, Opera and Safari… Just fails in Internet Explorer.

  • britain

    thank you for this tutorial, but how to enlarge the space of slides, default width: 675px; thank you

  • MissStack

    HI,
    I have a query generating the image list. When i have more than four images, it works great. But when I have only one image, I cannot see the image. it is hidden on the left side of the page when i check it via developers tool. Can you help me with this?

    Thanks!

  • Roland

    Does this work on mobile devices? I should have checked sooner. Now I find it does not work on mobile Safari and Android

  • Thank you for this great script. It is working wonderfully until the client wanted it to stop on the last image. When I scroll through all the photos, I get to the end and since the carousel is in the middle of the page, it resets the page to the top instead of just showing the slideshow stopping so you can click on the back button. Does this make sense?

    Thanks!

  • Ayyappa Javvaji

    thanks for your great nice script.
    does this plugin work with jquery 1.6.x. i am using jQuery 1.6.2 for my website.
    It seems this plug-in is not working properly in chrome. I set the carousel to vertical and circular auto scroll. When it first loads in chrome, only first div is scrolling and then freezes. I have to do mouse over to bring it back to action and then it is working as expected. can you resolve this issue?

  • Patricia

    I like the carousel lite. Now, I need that it has touch events.
    Can I add it? Can you add touch events to carousel? 🙂

  • vosmer

    before jCarouselLitre applied the html looks like this:
    __

    ololo aw dawd awd awd aw dawd
    ololo
    ololo
    ololo
    ololo
    ololo
    ololo
    ololo

    __
    and the width of the list is smaller than the first li text needs so the first li items height becomes bigger than other list-items.
    After Carousel applied it includes inline height for all list-items. The problem is that all list-elements get the same inline height (height of first(biggest) element). To solve it I had to comment “,height:f.height()” but the height of scrollable area is still as if all elements are like the biggest one.

    Please be free to ask for more details by email. Thank you.

  • vosmer

    sorry for previous garbage (delete it please)
    here we go:
    before jCarouselLitre applied the html looks like this:
    __

    ololo aw dawd awd awd aw dawd
    ololo
    ololo
    ololo
    ololo
    ololo
    ololo
    ololo

    __
    and the width of the list is smaller than the first li text needs so the first li items height becomes bigger than other list-items.
    After Carousel applied it includes inline height for all list-items. The problem is that all list-elements get the same inline height (height of first(biggest) element). To solve it I had to comment “,height:f.height()” but the height of scrollable area is still as if all elements are like the biggest one.

    Please be free to ask for more details by email. Thank you.

  • vosmer

    div-ul-li jcarouselLite applied to div

  • Actron

    Hello Ganeshji,

    first off, thank you for this great tool! However, I have a problem with your plugin: On my site, I use jCarousel Lite in auto-scrolling mode. In the carousel I have a couple of images. Additionally, I use Fancybox so users can click on images to view them in bigger size in a lightbox-like popup window.

    In the first cycle everything is fine. But as soon as the second cycle begins, some images do not open with Fancybox. So I guess some attributes get lost, when the image is moved from the left side of the carousel to the right side.

    Have you ever experienced similar problems or know what’s wrong here? Seems like some properties get lost.

    Regards,
    Actron

  • Actron

    #834 fixed my problem from #1338. You should really change this in jCarousel Lite 1.0.2.

  • 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…

  • Andy

    Looks great can the images be indevidually linked to seperate targets?

  • Wayne

    Hello

    Great little carousel.. great work!

    I am creating multiple jcarouselLite custom widgets per page. I get data from a recordset and add a class of ‘img+rsid’ to the main image and a rel=”img+rsid” to each thumbnail. And on-click using $(this) I can get the info I need to update the correct Image.
    Works great.

    however.. I am stuck with the previous and next buttons, when I click on the next or previous button all widgets respond.

    Think you can help?

  • Indeed great work and thanks for sharing.

  • Tyler

    What am I doing wrong? I’ve done everything I know.

    http://stlw.ktmediagroup.com/

  • Krinkster

    Found a couple of issues when using non-circular. This occurs when the number of items is not an equal multiple of “visible”.

    1. You need to round up the itemLength to a multiple of “visible” when calculating whether to scroll forward/backward by “scroll” items

    2. You need to round up the itemLength to a multiple of “visible” when determining whether to display the next & previous buttons

  • Your jCarouselLite Plugin Have a Bug When li tag count tLi.size() ? tLi.size() : o.visible

    Example Use:
    http://www.barnameha.ir/66/dreamland.html

    Regards
    Parsa

  • Security through obscurity is used by those trying to justify their own mess. *nix, by design, is considerably more secure than the early versions of Windows.

  • Dezinger

    239: li.css({overflow: “hidden”, “float”: o.vertical ? “none” : “left”});

    This better because someone js minify fail on “float” option.

  • line 227:
    v = o.visible > tLi.size() ? tLi.size() : o.visible;

  • Hi Ganeshji, this is a very cool script! Q: how can I setup the script to hide the preview-Button at the start of Slider and the next-Button at the end of the slider? Thank you very much!

  • neel

    Carousel is not loading properly in Chrome,after refreshing for 2-3 times it loads. i do not know what is it. only “next” and “prev” buttons are show, but all images of carousel disappears. In IE there is no such problem. please help me. Thanks.

  • Xajel

    I’m facing a bug with the non-circular option in jCL..

    to explain it well, I have a 30 items jCL, 7 visible each time… when I set the circular: false option then the carousel will work till item 28, the carousel won’t show the rest 2 as there’s no other items to complete 7 visible items, so if I want to show them I have to add another 5 empty items to fill the space… (7*4 = 28, 7*5 = 35) in basic words the total items count should be dividable to the number of visible items… if not, items will be hidden… the only solutions that can be done is to enable circular or to add empty items…

    I feel there should be a small option to make the last scroll adds the required items or to limit the last scroll just to the rest of the items left… so if the carousel was 30 items, 7 visible and 7 scroll, it will continue until only two items are left then it will change the scroll to 2 to move them normally…

  • Pingback: jCarousel Lite – A jQuery plugin | Ganesh » Web Design()

  • ScR4tCH