[英]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.