openseadragon更新属性showReferenceStrip在运行时

时间:2017-04-10 11:14:34

标签: javascript openseadragon

我想为ReferenceStrip设置一个切换按钮(属性:showReferenceStrip)。即使变量在运行时更新,也不会在视觉上更新。 是否有某种方式来更新它?

<html>
<button id="toggleRefStrip">Toggle Preview</button>

    <div id="osd-container" style="width: 950px; height: 1200px;"></div>
        <script src="openseadragon/openseadragon.min.js"></script>
        <script type="text/javascript">
        var toggleRefStripBtn = document.getElementById("toggleRefStrip");
        toggleRefStripBtn.addEventListener("click",function(e){
            if(viewer.showReferenceStrip === true) { viewer.showReferenceStrip = false;}
            else {viewer.showReferenceStrip = true;}
            console.log("viewer.showReferenceStrip: " + viewer.showReferenceStrip);
        });
            var viewer = OpenSeadragon({
                crossOriginPolicy: 'Anonymous',
                visibilityRatio: 1.0,
                showRotationControl: true,
                defaultZoomLevel: 1.6,
                minZoomImageRatio: 0.4,
                //zoomPerScroll: 1, //deactivate mouse/finger zooming
                id: "osd-container",
                tileSources: ["images/T/1.dzi", "images/T/2.dzi", "images/T/3.dzi", "images/T/4.dzi"],
                sequenceMode: true,
                showReferenceStrip: false,
            });
        </script>    
</html>

1 个答案:

答案 0 :(得分:1)

看起来直接在OSD中没有设施(尽管你肯定可以提出问题或制作补丁来添加这样的东西)。看起来你可以用这样的东西隐藏referenceStrip:

viewer.referenceStrip.element.style.display = 'none';

...并显示:

viewer.referenceStrip.element.style.display = 'block';