简体   繁体   English

旋转设备方向时,iOS中的JSSOR滑块无法正确调整大小

[英]JSSOR slider not resizing properly in iOS when rotating device orientation

I'm designing a responsive site and using a jssor slider. 我正在设计一个响应式网站并使用jssor滑块。 The slider is responsive and works well with the following in the head: 滑块反应灵敏,可与头部中的以下组件配合使用:

<meta name="viewport" content="width=device-width>

When I edit this snippet, as below, the slider does not resize properly in iOS when rotating the device from landscape to portrait (and vice versa): 当我编辑此代码段时,如下所示,当将设备从横向旋转到纵向(反之亦然)时,滑块在iOS中无法正确调整大小:

<meta name="viewport" content="width=device-width, initial-scale=1">

I'm trying to prevent iOS from zooming in while in landscape. 我正在尝试防止iOS在横向环境中放大。

You can see an example of this problem when opening this page on an iOS device or simulator and changing the device orientation back and forth. 在iOS设备或模拟器上打开此页面并来回更改设备方向时,可以看到此问题的示例。 The slider opens/loads properly in both landscape and portrait. 滑块可以横向和纵向正确打开/加载。 The problem is only when the device is rotated. 问题仅在设备旋转时出现。

This is the portion of the script that controls the resize/responsiveness: 这是脚本中控制调整大小/响应性的部分:

$JssorSlider$("slider2_container", options);
        function ScaleSlider() {
            var parentWidth = jssor_slider2.$Elmt.parentNode.clientWidth;
            if (parentWidth)
                jssor_slider2.$ScaleWidth(Math.min(parentWidth, 1024));
            else
                window.setTimeout(ScaleSlider, 30);
        }

        ScaleSlider();
        $(window).bind("load", ScaleSlider);
        $(window).bind("resize", ScaleSlider);
        $(window).bind("orientationchange", ScaleSlider);
    });

Please handle orientationchange event 请处理方向变更事件

    function ScaleSlider() {
        var parentWidth = jssor_slider2.$Elmt.parentNode.clientWidth;
        if (parentWidth)
            jssor_slider2.$ScaleWidth(Math.min(parentWidth, 1024));
        else
            window.setTimeout(ScaleSlider, 30);
    }

    ScaleSlider();
    $(window).bind("load", ScaleSlider);
    $(window).bind("resize", ScaleSlider);
    $(window).bind("orientationchange", ScaleSlider);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM