javascript
  • dojo
  • maximize
  • dijit.layout
  • 2017-05-03 9 views 1 likes 
    1

    このリンクされた例では、内容ペインのdijitレイアウトがあります。dijitレイアウトを最大化するBorderContainer

    Example Link

    レイアウト全体をカバーするために中央のペインを最大化する方法はあります。

    私は(id="center")、あなたはこの最後のidを設定していたことを知って、中央のレイアウトのサイズを変更するにはid="center"

    dijit.ById("center").domNode.style.width='100%' 
    //and 
    dijit.ById("center").resize({w:1000,h:1000}); 
    
    +0

    をあなたが唯一のセンターを持っているか、あなたはそれで他のレイアウトを持っている、また、国境コンテナがあります100%幅と高さ??あなたはもっと説明することができます –

    +0

    最初の例をクリックするとリンクに、上端と下端が後ろに上端があります。私はid = "center"を中央の領域に与える。それが私がフルスクリーンに拡大したいものです。私の例のバージョンでは、センターは約500ピクセルまたは50%で、開始するには100パーセント幅ではありません。私が100%の幅にすると、変化しないように見えます。 – techdog

    +0

    多分[dojo/dom-style](https://dojotoolkit.org/reference-guide/1.10/dojo/dom-style.html#set)が役に立ちますか? – barbsan

    答えて

    1

    センターパネルとidを与えた後、次を使用してみましたが、あなたはdojo/dom-styleを使用することができます

    ペインのレイアウトの新しい幅と高さを設定するには親の幅と高さを計算して中央の枠にスタイルを適用してください。また、すべてのウィンドウのサイズを変更すると、ペインは最初のスタイルを取得する必要があります、あなたがしなければならないことは、resiをexcuteですイベントのサイズを変更するすべてのウィンドウをシュッ..

    あなたが怒鳴る説明の例を見ることができます:

    require([ "dojo/on","dojo/dom-style", "dojo/ready", "dijit/registry", "dijit/layout/BorderContainer", "dijit/layout/ContentPane"],function(On, domStyle,ready,registry,BorderContainer,ContentPane){ 
     
    \t ready(function(){ 
     
        // apply resize after 3 seconde 
     
        window.setTimeout(resizeCenter,3000); 
     
        On(window,"resize",function(e){ 
     
         console.log(e) 
     
        \t resizeCenter(); 
     
        }) 
     
        }) 
     
        
     
        function resizeCenter(){ 
     
        \t var centerPane = registry.byId("center").domNode; 
     
        parentWidth = domStyle.get(centerPane.parentNode,"width"); 
     
        parentWidth -=28; 
     
        parentHeight = domStyle.get(centerPane.parentNode,"height"); 
     
        parentHeight -=28; 
     
        ///why removing 28 because 5*2 margin + 8*2 padding +2*1 borders = 28 
     
        
     
        //set top left right bottom if all regions are set 
     
        domStyle.set(centerPane,"top","5px"); 
     
        domStyle.set(centerPane,"bottom","5px"); 
     
        domStyle.set(centerPane,"left","5px"); 
     
        domStyle.set(centerPane,"right","5px"); 
     
        
     
        domStyle.set(centerPane,"z-index",10); 
     
        domStyle.set(centerPane,"width",parentWidth+"px"); 
     
        domStyle.set(centerPane,"height",parentHeight+"px") 
     
        } 
     
    });
    html, body { 
     
        width: 100%; 
     
        height: 100%; 
     
        margin: 0; 
     
    }
    <link href="//ajax.googleapis.com/ajax/libs/dojo/1.10.0/dijit/themes/claro/claro.css" rel="stylesheet"/> 
     
    <script> 
     
        dojoConfig= { 
     
         parseOnLoad: true, 
     
         async: true 
     
        }; 
     
    </script> 
     
    <script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.0/dojo/dojo.js"></script> 
     
    
     
    <body class="claro"> 
     
        <div data-dojo-type="dijit/layout/BorderContainer" style="width: 100%; height: 100%;"> 
     
         <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">Top pane</div> 
     
         <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'" id="center">center</div> 
     
    
     
         <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'trailing'">Trailing pane</div> 
     
        </div> 
     
    </body>

    +0

    スニペットは完全に機能しているようです。 Dojoは、このような機能をレイアウトに追加して、どのペインも最大化および最小化する必要があります。 – techdog

    +0

    @techdogおそらくはい、あなたはjsを拡張することができ、自分の必要性を甘くするあなた自身のcustumized contentepaneを作成することができます。 (usinf define()) –

    +0

    これは、ContentPaneの場合は中央で動作しますが、両方が異なる動作を与えるBorderContainerまたはTabContainerの場合は動作しません。 – techdog

    関連する問題