jssor全高或全屏滑块/可能吗?

时间:2014-04-28 20:44:09

标签: jssor

是否可以将此演示版http://www.jssor.com/demos/full-width-slider.html设为全屏高度?喜欢超大轮播http://buildinternet.com/project/supersized/slideshow/3.2/demo.html

由于

3 个答案:

答案 0 :(得分:16)

请使用以下代码将滑块缩放到全屏,

//responsive code begin
//you can remove responsive code if you don't want the slider scales while window resizes
function ScaleSlider() {
    var windowWidth = $(window).width();

    if (windowWidth) {
        var windowHeight = $(window).height();
        var originalWidth = jssor_slider1.$OriginalWidth();
        var originalHeight = jssor_slider1.$OriginalHeight();

        var scaleWidth = windowWidth;
        if (originalWidth / windowWidth > originalHeight / windowHeight) {
            scaleWidth = Math.ceil(windowHeight / originalHeight * originalWidth);
        }

        jssor_slider1.$ScaleWidth(scaleWidth);
    }
    else
        window.setTimeout(ScaleSlider, 30);
}

ScaleSlider();

$(window).bind("load", ScaleSlider);
$(window).bind("resize", ScaleSlider);
$(window).bind("orientationchange", ScaleSlider);
//responsive code end

并包装滑块容器

<div style="position: relative; width: 100%; overflow: hidden;">
    <div style="position: relative; left: 50%; width: 5000px; text-align: center; margin-left: -2500px;">

        <!-- use 'margin: 0 auto;' to auto center element in parent container -->
        <div id="slider1_container" style="...margin: 0 auto;..." ...>
        </div>

    </div>
</div>

请使用源代码访问Full Screen Slider

答案 1 :(得分:3)

有一个新的api $ ScaheHeight与Jssor Slider 17.0或更高版本。

//responsive code begin
//you can remove responsive code if you don't want the slider to scale along with window
function ScaleSlider() {
    var windowWidth = $(window).width();

    if (windowWidth) {
        var windowHeight = $(window).height();
        var originalWidth = jssor_slider1.$OriginalWidth();
        var originalHeight = jssor_slider1.$OriginalHeight();

        if (originalWidth / windowWidth > originalHeight / windowHeight) {
            jssor_slider1.$ScaleHeight(windowHeight);
        }
        else {
            jssor_slider1.$ScaleWidth(windowWidth);
        }
    }
    else
        window.setTimeout(ScaleSlider, 30);
}

ScaleSlider();

$(window).bind("load", ScaleSlider);
$(window).bind("resize", ScaleSlider);
$(window).bind("orientationchange", ScaleSlider);
//responsive code end

参考:http://www.jssor.com/testcase/full-screen-slider-new-api.source.html

答案 2 :(得分:1)

基于上面的答案,我得到了它的工作,但“slider1_container”div应该像这样包装:

<div style="position: relative; width: 100%; overflow: hidden;">

    <div style="position: relative; left: 50%; width: 5000px; text-align: center; margin-left: -2500px;">


 <div id="slider1_container"> 
 ... 
 ... 
 </div>


 </div>
</div>