如何制作JCarousel垂直滚轮反向滚动?
问题描述:
我能够使用jQuery Jcarousel实例化一个工作滚动条,但是我需要它来反转滚动条。例如,我现在有:如何制作JCarousel垂直滚轮反向滚动?
jQuery(document).ready(function() {
jQuery('#mycarousel').jcarousel({
auto: 1,
vertical: true,
scroll: 1,
animation: "slow",
wrap: 'last',
initCallback: mycarousel_initCallback
});
});
我需要做些什么才能使项目向上而不是向下滚动?
预先感谢您
答
反向自动滚动尚未实现,虽然你可以很容易地编写它。
这是的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()
应的伎俩,如果你(现在不能测试,请张贴结果)。
祝你好运:)
答
只是把它添加到XaviEsteve答案(我无法找到一个地方加入注释,他的回答是这样)。
一旦我将self.next()更改为self.prev(),我必须将'wrap'选项更改为'both',以使其适用于我,就像这样。
jQuery('#mycarousel').jcarousel({
auto: 1,
wrap: 'both',
vertical: true,
scroll: 1,
start: 30,
initCallback: mycarousel_initCallback
});
答
实际上,它比这更简单。
scroll: -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
});
});
非常感谢你的快速反应。我特别将第705行更改为:this.timer = setTimeout(function(){self.prev();},this.options.auto * 1000); 现在滚动器不滚动,我没有在Firebug中得到任何错误。 – jini 2010-05-12 14:46:58
Ahhhhhhhh我不得不专门使用“开始”选项并手动设置我的索引,因为它从1开始,没有任何“前一个”可以返回。再次感谢! – jini 2010-05-12 15:00:30
酷!很高兴它工作斯科特:) – 2010-05-12 15:58:19