Jer*_*emy 3 javascript jquery sitecore jquery-cycle2
对于最近的项目,我们正在使用Cycle2.我已升级到最新版本.我们使用Sitecore来呈现内容.无论我采取的方法(下面),我都无法使自动停止运行.我们每张幻灯片有2-3张幻灯片,我们希望它按以下方式移动:1-2-3-1.
我们是否将其渲染为以下规则中的自动播放:
<ul class="<%# Sitecore.Context.PageMode.IsPageEditor ? String.Empty : "cycle-slideshow" %> interior"
data-cycle-speed="3000"
data-cycle-autostop="true"
data-cycle-timeout="5000"
data-cycle-auto-height="container"
data-cycle-slides="> li" >
<sc:Placeholder runat="server" ID="SlidePlaceholder" Key="SlidePlaceholder" /></ul>
Run Code Online (Sandbox Code Playgroud)
或者,如果我们在没有"cycle-slideshow"类的JS中以编程方式播放:
$('#my-slideshow').cycle({
speed: 3000,
autostop: true,
timeout: 5000,
end: function() {
$('#my-slideshow').cycle('stop');
}
});
Run Code Online (Sandbox Code Playgroud)
任何帮助/建议表示赞赏.谢谢你的时间.
假设您正在使用Malsup的Cycle2插件,那么API的文档不包含名为的选项autostop.也许你的意思是loop选择?
环
整数
0
自动前进幻灯片应在终止前循环的次数.如果该值小于1,则幻灯片将连续循环.设置为1以循环一次,等等.
所以要么:
<ul ... data-cycle-loop="1" .. /></ul>
Run Code Online (Sandbox Code Playgroud)
要么
var $slideshow = $('#my-slideshow');
$slideshow.cycle({
speed: 3000,
loop: 1,
timeout: 5000
});
// jump back to the first slide when loop has finished
// you might have to use setTimeout() to delay the transition back to the first slide
$slideshow.on('cycle-finished', function(event, opts) {
$slideshow.cycle('goto', 0);
});
Run Code Online (Sandbox Code Playgroud)