我有一个显示容器div的页面,它旁边是一个iframe,它显示了我使用"Three.js“创建的模型,它工作得很好。我遇到的问题是,当我将它切换到我的触摸设备并与模型交互(通过放大)时,整个页面都会放大,而不是模型本身。我一直在研究,我找到的所有解决方案都没有修复我的bug。基本上,我想要的是模型本身(在iframe中)在触摸设备上时放大/缩小,而不是整个屏幕。我认为问题在于模型本身,因为当我将模型从常规的gltf文件切换到pointmaterial时,它工作得很好。以下是我的代码
HTML
<div class="container-fluid">
<div class="row">
<nav class="col-md-2 d-none d-md-block bg-light sidebar">
<div class="sidebar-sticky">
<h1>text</h1>
<p>text </p>
</div>
<!--sticky footer-->
<footer class="footer">
<div >
<p align="center"><a href="index.html">Home</a> | <a href="es/test.html">spanish</a><br>
<!--<p>This interactive was made possible through the support of</p>-->
<a href="index.html"><img src="images/logo.png" alt="logo" style="width:100%" /></a></p>
</div>
</footer>
</nav>
</div>
<main role="main" class="col-md-9 ml-sm-auto col-lg-12 px-0">
<!-- Featured Content -->
<div class="embed-responsive embed-responsive-16by9" onload="onload="redirect();">
<iframe style="position:fixed; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%; border:none;
margin:0; padding:0; overflow:hidden; z-index:1;" class="embed-responsive-item" src="models/page.html" allowfullscreen></iframe>
</div>
</main>
</div>
CSS
#width{
width: 600px;
}
body{
overflow: hidden;
}
body p {
font-size: .875em;
font-family: 'Open Sans';
}
h1,h2,h3,h4 {
font-family:'Marcellus';
font-size: 1.5em;
}
.feather {
width: 16px;
height: 16px;
vertical-align: text-bottom;
}
/*sticky-footer*/
.footer {
position: absolute;
bottom:0%;
margin-bottom:3%;
width: calc(100% - 20px);
height: 100px; /* Set the fixed height of the footer here */
/*line-height: 60px; /* Vertically center the text there */
/*padding: 20px;*/
background-color: #F8F9FA;
}
/*
* Sidebar
*/
.sidebar {
position: fixed;
top: 0;
bottom: 0;
left: 0;
z-index: 100; /* Behind the navbar */
padding-top: 10px;
padding-right: 10px;
padding-left: 10px;
padding-bottom: 10px; /* Height of navbar */
box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
}
.sidebar-sticky {
position: relative;
top: 0;
padding-bottom: 0px;
height: calc(100% - 200px);
/* height: 90%; */
padding-top: .5rem;
overflow-x: hidden;
overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
}
发布于 2018-05-30 08:23:25
这不是一个真正的ThreeJS问题。您正在寻找的是CSS touch-action
属性,它可以防止触摸设备上的收缩缩放。尝试将touch-action: none;
添加到您的iframe,它将阻止用户在收缩此iframe时放大。
有关更多信息,请参阅MDN documentation。
https://stackoverflow.com/questions/50592553
复制相似问题