0

在使用 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.
}

提前致谢!

4

1 回答 1

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);
    }
}
于 2013-08-01T08:19:40.610 回答