Multiple rows with jcarousel

后端 未结 6 1665
别跟我提以往
别跟我提以往 2020-12-03 12:50

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?

6条回答
  •  难免孤独
    2020-12-03 13:12

    This is .js code substitutions according to @Sike and a little additional of me, the height was not set dynamically, now it is.

    var defaults = {
            vertical: false,
            rtl: false,
            start: 1,
            offset: 1,
            size: null,
            scroll: 3,
            visible: null,
            animation: 'normal',
            easing: 'swing',
            auto: 0,
            wrap: null,
            initCallback: null,
            setupCallback: null,
            reloadCallback: null,
            itemLoadCallback: null,
            itemFirstInCallback: null,
            itemFirstOutCallback: null,
            itemLastInCallback: null,
            itemLastOutCallback: null,
            itemVisibleInCallback: null,
            itemVisibleOutCallback: null,
            animationStepCallback: null,
            buttonNextHTML: '
    ', buttonPrevHTML: '
    ', buttonNextEvent: 'click', buttonPrevEvent: 'click', buttonNextCallback: null, buttonPrevCallback: null, moduleWidth: null, rows: null, itemFallbackDimension: null }, windowLoaded = false; this.clip.addClass(this.className('jcarousel-clip')).css({ position: 'relative', height: this.options.rows * this.options.moduleWidth }); this.container.addClass(this.className('jcarousel-container')).css({ position: 'relative', height: this.options.rows * this.options.moduleWidth }); if (li.size() > 0) { var moduleCount = li.size(); var wh = 0, j = this.options.offset; wh = this.options.moduleWidth * Math.ceil(moduleCount / this.options.rows); wh = wh + this.options.moduleWidth; li.each(function() { self.format(this, j++); //wh += self.dimension(this, di); }); 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); } }

    This is the call in using the static_sample.html of the code bundle in the download of jscarousel:

    
    

    In case you need to change the content of the carousel and reload the carousel you need to do this:

    // Destroy contents of wrapper
    $('.wrapper *').remove();
    // Create UL list
    $('.wrapper').append('
      ') // Load your items into the carousellist for (var i = 0; i < 10; i++) { $('#carouselist').append('
    • Item ' + i + '
    • '); } // Now apply carousel to list jQuery('#carousellist').jcarousel({ // your config });

      The carousel html definition needs to be like this:

        ...

      Thanks to Webcidentes

    提交回复
    热议问题