最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to make JCarousel Vertical Scroller reverse scroll? - Stack Overflow

programmeradmin1浏览0评论

I was able to instantiate a working scroller using jQuery Jcarousel however I need it to reverse scroll. For example right now I have:

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 1,
        vertical: true,
        scroll: 1,
        animation: "slow",
        wrap: 'last',
        initCallback: mycarousel_initCallback
    }); 
});

What do I need to do to make the items scroll upwards instead of downwards?

Thank You in advance

I was able to instantiate a working scroller using jQuery Jcarousel however I need it to reverse scroll. For example right now I have:

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 1,
        vertical: true,
        scroll: 1,
        animation: "slow",
        wrap: 'last',
        initCallback: mycarousel_initCallback
    }); 
});

What do I need to do to make the items scroll upwards instead of downwards?

Thank You in advance

Share edited Dec 13, 2012 at 11:30 tbraun89 2,2343 gold badges25 silver badges46 bronze badges asked May 12, 2010 at 13:58 Strong Like BullStrong Like Bull 11.3k37 gold badges101 silver badges169 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 5

actually, it's more simple than that.

scroll: -1

cheers!

Reverse autoscrolling is not implemented yet although you can code it quite easily.

This is the autoscrolling function in jCarousel:

/**
 * Starts autoscrolling.
 *
 * @method auto
 * @return undefined
 * @param s {Number} Seconds to periodically autoscroll the content.
 */
    startAuto: function(s) {
        if (s != undefined)
            this.options.auto = s;

        if (this.options.auto == 0)
            return this.stopAuto();

        if (this.timer != null)
            return;

        var self = this;
        this.timer = setTimeout(function() { self.next(); }, this.options.auto * 1000);
    },

(Lines 687 to 706 in jquery.carousel.js )

Changing self.next(); to self.prev() should to the trick (can't test it right now, if you do please post the results).

Good luck :)

Just to add this to XaviEsteve answer (I can't find a place to add ment to his answer anyway).

Once I've changed self.next() to self.prev(), I have to change 'wrap' option to 'both' to make it work for me, like this.

jQuery('#mycarousel').jcarousel({
        auto: 1,
        wrap: 'both',
        vertical: true, 
        scroll: 1,
        start: 30,
        initCallback: mycarousel_initCallback
    });

Try this, it should work

$(document).ready(function() {
    $('#mycarousel').jcarousel({
      vertical: true,
      wrap: 'circular',
      animate: 'slow',
    });  
    $('#mycarousel').jcarouselAutoscroll({
      interval: 3000,
      target: '-=1', /*if you change - on + it will scroll up*/
      autostart: true
  });
});
发布评论

评论列表(0)

  1. 暂无评论