Search code examples
javascriptjqueryjcarousel

Multiple rows with jcarousel


I'm trying to use jcarousel to build a container with multiple rows, I've tried a few things but have had no luck. Can anyone make any suggestions on how to create it?


Solution

  • We have had to make a similar modifiaction. We do this by extending the default options, to include a rows value, and the width of each item (we call them modules) then divide the width by the number of rows.

    Code added to jCarousel function...

    Add to default options:

    moduleWidth: null,
    rows:null,
    

    Then set when creating jCarousel:

    $('.columns2.rows2 .mycarousel').jcarousel( {
            scroll: 1,
            moduleWidth: 290,
            rows:2,
            itemLoadCallback: tonyTest,
            animation: 'slow'
        });
    

    The find and edit the lines in:

    $.jcarousel = function(e, o) { 
    
    if (li.size() > 0) {
    ...
    moduleCount = li.size();
    wh = this.options.moduleWidth * Math.ceil( moduleCount / this.options.rows );
    wh = wh + this.options.moduleWidth;
    
    this.list.css(this.wh, wh + 'px');
    
    // Only set if not explicitly passed as option
    if (!o || o.size === undefined)
       this.options.size = Math.ceil( li.size() / this.options.rows );
    

    Hope this helps,

    Tony Dillon