如何删除.init并为较小的屏幕案例(shadowbox)提供新的init选项

时间:2014-10-28 20:44:00

标签: jquery wordpress responsive-design initialization shadowbox

我已经在我的页脚(wordpress网站)中初始化了文档,但是当窗口小于480px时,我希望那个shadowbox只显示5个照片链接而不是10个。我添加了一个窗口大小的脚本但是它不适用于此,在调整浏览器屏幕大小后仍有10个计数:

    Shadowbox.init({
        animate: true,
        animateFade: true,
        animSequence: "wh",
        modal: false,
        showOverlay: true,
        overlayColor: "#000",
        overlayOpacity: "1",
        flashBgColor: "#000000",
        autoplayMovies: false,
        showMovieControls: true,
        slideshowDelay: 0,
        resizeDuration: "0.35",
        fadeDuration: "0.35",
        displayNav: true,
        continuous: true,
        displayCounter: true,
        counterType: "skip",
        counterLimit: "10",
        viewportPadding: "20",
        handleOversize: "resize",
        handleUnsupported: "link",
        autoDimensions: true,
        initialHeight: "5",
        initialWidth: "320",
        enableKeys: true,
        skipSetup: false,
        useSizzle: false,
        flashParams: {bgcolor:"#000000", allowFullScreen:true},
        flashVars: {},
        flashVersion: "9.0.0",
    }); 
    if(jQuery(window).width() <= 480){
        Shadowbox.init({
            counterLimit: "5"
        });
    }

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

Shadowbox.init函数只应调用一次,但您可以尝试类似:

var shadowbox_options = {
    // init default options
}

if( jQuery(window).width() <= 480 ) {
    shadowbox_options.counterLimit = 5;
}

Shadowbox.init( shadowbox_options );

或者,如果您不喜欢这种方法,请使用Shadowbox.setup();方法检查here解决方案。