0

有谁知道我如何跳过NivoSlider 3.1安装中的第一张最后一张幻灯片?

背景:我使用WordPress自定义字段动态地将我的图像添加到幻灯片中,并且由于 a strange quirk,它不会显示幻灯片,除非我已经有至少 1 张图像。

是否可以告诉 NivoSlider 忽略第一张或最后一张幻灯片?

所以,我的标记可能是:

<div id="slider" class="slider nivoSlider">
<img src="1.jpg" /> <!-- Ignore this ALWAYS -->
<img src="wp-img-1.jpg" />
<img src="another-wp-img-2.jpg" />
<img src="yet-another-wp-img-3.jpg" />
</div>

因此,例如在这里,它会跳过Wall-EFinding Nemo完全不显示它。

非常感谢您对此提供的任何帮助-我已经绞尽脑汁几天了:-)

4

1 回答 1

1

应该能帮到你一点。

$(document).ready(function () {
    //set up vars
    var slider = $('#slider');
    var firstImage = $('#slider img:first');
    var lastImage = $('#slider img:last');

    //Take them out of the gallery
    firstImage.remove();
    lastImage.remove();

    //run photo gallery stuff

    //Now add images back in
    slider.prepend(firstImage);
    slider.append(lastImage);
});

编辑

    $(window).load(function() {

//set up vars
var slider = $('#slider');
var firstImage = $('#slider img:first');
var lastImage = $('#slider img:last');

//Take them out of the gallery
firstImage.remove();
lastImage.remove();

    $('.slider').nivoSlider({
        effect: 'slideInLeft', // Specify sets like: 'fold,fade,sliceDown'
        slices: 15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed: 500, // Slide transition speed
        pauseTime: 3000, // How long each slide will show
        startSlide: 1, // Set starting Slide (0 index)    
        controlNav: false, // 1,2,3... navigation
        controlNavThumbs: false, // Use thumbnails for Control Nav
        pauseOnHover: true, // Stop animation while hovering
        manualAdvance: true, // Force manual transitions
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        randomStart: false, // Start on a random slide   
        directionNav:true,
        directionNavHide:false,
        afterLoad: function(){
            //Now add images back in
            slider.prepend(firstImage);
            slider.append(lastImage);
        } // Triggers when slider has loaded
    });
});
于 2012-12-14T16:09:02.307 回答