简体   繁体   English

ios iframe只有在方向从纵向更改为横向后才能展开

[英]ios iframe unscrollable only after orientation change from portrait -> landscape

I have a scrollable iframe on ios set up with 我在ios上设置了可滚动的iframe

<div style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; overflow: scroll; -webkit-overflow-scroll: touch; ...">
  <iframe style="height: 600px, ...">
  </iframe>
</div>

The height of the iframe is actually set to screen.availHeight , and doesn't change when the orientation changes. iframe的高度实际上设置为screen.availHeight ,并且方向改变时不会改变。

Now, if the modal is opened when the phone is in portrait mode, it works fine. 现在,如果在手机处于纵向模式时打开了模式,则可以正常工作。 And if the modal is opened when the phone is in landscape mode, it works fine. 而且,如果手机处于横向模式时打开了模式,则可以正常工作。 And if it's opened in landscape mode and rotated into portrait, that works fine too. 如果将其以横向模式打开并旋转为纵向,那也可以正常工作。

BUT, if it's opened in portrait mode and rotated into landscape mode, then the scrolling does not work; 但是,如果以纵向模式打开并旋转为横向模式,则无法进行滚动; you end up sort of scrolling the underlying page, not the modal itself. 您最终会滚动底层页面,而不是模式本身。

This despite the fact that the styling is exactly the same no matter the orientation. 尽管事实上无论方向如何,样式都完全相同。

Has this happened to anyone before? 以前有人发生过这种事吗? Workarounds? 解决方法? What's going on? 这是怎么回事? I am a n00b here, any advice appreciated. 我在这里n00b,任何建议表示赞赏。

var doOnOrientationChange = function() {
    switch (window.orientation) {
        case -90:
        case 90:
            console.log('landscape');
            if ($('.modal').length && $('.modal').hasClass('in')) {
                $('.modal').scrollTop(1);
            }
            break;
        default:
            console.log('portrait');
            if ($('.modal').length && $('.modal').hasClass('in')) {
                $('.modal.in').css('overflow', 'hidden');
                setTimeout(function() {
                    $('.modal.in').css('overflow-x', 'hidden').css('overflow-y', 'auto');
                }, 10);
            }
            break;
    }
};

window.addEventListener('orientationchange', doOnOrientationChange);

doOnOrientationChange();

I resolve this problem in this way 我以这种方式解决了这个问题

暂无
暂无

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

相关问题 如何在手机设备上仅针对平板电脑实现纵向显示和纵向显示? - How implement only landscape orientation for tablet and portrait orientation on phone devices? AngularJS-如何检测窗口调整大小+横向/纵向改变事件 - AngularJS - How to detect window resize + landscape / portrait orientation change event Android / Web App-将横向设置为纵向 - Android/ Web App - Setting orientation to portrait mode from landscape 仅适用于 ios 平板电脑的隐藏下载按钮纵向和横向模式 - Hide Download button for ios Tablet only Portrait and landscape mode 如何根据纵向或横向模式(以及方向更改)更改“初始比例”? - How do I change “initial-scale” based on portrait or landscape mode (and orientation change)? Cordova iOS 在单页上将屏幕方向更改为横向 - Cordova iOS Change Screen Orientation To Landscape on a Single Page 当方向从纵向更改为横向模式时,ESRI地图未正确居中 - ESRI Map is not centered properly when orientation changes from Portrait to Landscape mode 当移动方向从横向更改为纵向时,窗口元素是否不适合窗口? - window elements not fit in window when mobile orientation changes from landscape to portrait? 当iPad中方向从横向更改为纵向时,页面会缩小 - Page zooms out when orientation changes from landscape to portrait mode in iPad 当ipad方向从横向更改为纵向时如何使用javascript将变量设置为false,反之亦然并做出反应? - How to set a variable to false when ipad orientation is changed from landscape to portrait and vice versa using javascript and react?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM