在使用Jquery循环插件时,我希望能够在现有幻灯片之间动态插入幻灯片,而不仅仅是在最后。
这是我正在使用的代码
function onBefore(curr, next, opts) {
//Adding new slide
opts.addSlide(item);
//item has dynamic slide data which is going to added to the existing slides.
}
提前致谢!
答案 0 :(得分:1)
您可以在任何位置添加幻灯片,您只需要在您需要的那个之前等待幻灯片放在幻灯片上。这非常有效,因为您只需在需要显示幻灯片时将幻灯片添加到所需位置。
function onBefore(curr, next, opts) {
// on the first pass, addSlide is undefined (plugin hasn't yet created the fn);
// when we're finshed adding slides we'll null it out again
if (!opts.addSlide)
return;
//add any type of logic here to make sure that you are in the position
//where you want to add your slide
if ($(curr).index() === 8 && $(next).index() === 9) {
//Adding new slide
opts.addSlide(item);
}
}