[英]How to use Photo Sphere Viewer plugin in multiple places?
我正在使用Photo Sphere全景照片插件。 我想在多個地方使用腳本。
<div class="container bs-docs-container">
<div class="row">
<div class="col-md-6" role="main">
<section class="bs-docs-section">
<div id="photosphere"></div>
</section>
</div>
<div class="col-md-6" role="main">
<section class="bs-docs-section">
<div id="photosphere1"></div>
</section>
</div>
</div>
var PSV = new PhotoSphereViewer({
panorama: 'img/Bryce-Canyon-National-Park-Mark-Doliner.jpg',
container: 'photosphere',
caption: 'Photo',
loading_img: 'img/photosphere-logo.gif',
navbar: 'autorotate zoom download caption fullscreen',
default_fov: 70,
mousewheel: true,
size: {
height: 500
}
});
var PSV = new PhotoSphereViewer({
panorama: 'img/Bryce-Canyon-National-Park-Mark-Doliner.jpg',
container: 'photosphere1',
caption: 'Photo',
loading_img: 'img/photosphere-logo.gif',
navbar: 'autorotate zoom download caption fullscreen',
default_fov: 70,
mousewheel: true,
size: {
height: 500
}
});
我不想在多個地方使用的一個腳本中添加容器:“ photosphere”,容器:“ photosphere1” 。 我在下面提到了演示網址。
使PhotoSphereViewer分離函數,然后將div id作為參數傳遞給該函數。 使用div id(container id)在任何需要的地方調用this函數。
function psvDivFun(idname)
{
var PSV = new PhotoSphereViewer({
panorama: 'img/Bryce-Canyon-National-Park-Mark-Doliner.jpg',
container: idname,
caption: 'Photo',
loading_img: 'img/photosphere-logo.gif',
navbar: 'autorotate zoom download caption fullscreen',
default_fov: 70,
mousewheel: true,
size: {
height: 500
}
});
}
psvDivFun('photosphere');
psvDivFun('photosphere1');
不要忘記為容器分配“ idname”。
container: idname,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.