2010-05-12 63 views
0

我能夠使用jQuery Jcarousel實例化一個工作滾動條,但是我需要它來反轉滾動條。例如,我現在有:如何製作JCarousel垂直滾輪反向滾動?

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

我需要做些什麼才能使項目向上而不是向下滾動?

預先感謝您

回答

1

反向自動滾動尚未實現,雖然你可以很容易地編寫它。

這是的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); 
    }, 

(線687至706 jquery.carousel.js

更改self.next();self.prev()應的伎倆,如果你(現在不能測試,請張貼結果)。

祝你好運:)

+0

非常感謝你的快速反應。我特別將第705行更改爲:this.timer = setTimeout(function(){self.prev();},this.options.auto * 1000); 現在滾動器不滾動,我沒有在Firebug中得到任何錯誤。 – jini 2010-05-12 14:46:58

+0

Ahhhhhhhh我不得不專門使用「開始」選項並手動設置我的索引,因爲它從1開始,沒有任何「前一個」可以返回。再次感謝! – jini 2010-05-12 15:00:30

+0

酷!很高興它工作斯科特:) – 2010-05-12 15:58:19

0

只是把它添加到XaviEsteve答案(我無法找到一個地方加入註釋,他的回答是這樣)。

一旦我將self.next()更改爲self.prev(),我必須將'wrap'選項更改爲'both',以使其適用於我,就像這樣。

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

實際上,它比這更簡單。

scroll: -1 

乾杯!

-1

試試這個,它應該工作

$(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 
    }); 
});