[CLOSED] window resize and center on Ext.EventManager.onWindowResize

  1. #1

    [CLOSED] window resize and center on Ext.EventManager.onWindowResize

    I would to be able to resize an center a window based on explorer page size every time the uses does a resize of the navigator page.

    Is it posible?

    I tried the following but it does not seems to be working when page size becomes too small.

    
    <%@ Page Language="VB" %>
    
    <!DOCTYPE html>
    
    <script runat="server">
    
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <extnet:ResourceManager ID="ResourceManager1" runat="server" />
        <extnet:Viewport runat="server">
            <Items>
                <extnet:Panel runat="server">
                    <Buttons>
                        <extnet:Button runat="server" Text="Zoom">
                            <Listeners>
                                <Click Handler="#{ZoomWindow}.show();" />
                            </Listeners>
                        </extnet:Button>
    
                    </Buttons>
                </extnet:Panel>
            </Items>
        </extnet:Viewport>
        <extnet:Window runat="server" ID="ZoomWindow" Title="Buscar Informacion" Hidden="true" Width="600" Height="450" Layout="BorderLayout" />
        <script type="text/javascript">
            function resize() {
                //return;
                var width = Ext.getBody().getViewSize().width - 20;
                var height = Ext.getBody().getViewSize().height - 20;
                var w1;
    
                w1 = eval("<%= ZoomWindow.ClientID%>");
                w1.setWidth(width - 20);
                 w1.center();
            }
    
            Ext.EventManager.onWindowResize(function () {
                resize();
            });
    
            Ext.onReady(function () {
                //alert("ready");
                resize();
            });
    
        </script>
    
    </body>
    
    </html>
    Last edited by fabricio.murta; May 24, 2016 at 7:49 PM. Reason: no user feedback for 7+ days
  2. #2
    Hello @jstifel!

    You probably want to add to your resize() function a condition to set the height of the window if the overall height gets below a given threshold. Something like:

    function resize() {
        var width = Ext.getBody().getViewSize().width - 20;
        var height = Ext.getBody().getViewSize().height - 20;
        var w1;
    
        w1 = eval("<%= ZoomWindow.ClientID%>");
        w1.setWidth(width - 20);
    
        // Check if the height fits the window!
        if (height < 500) {
         w1.setHeight(height - 20);
        } else if (height > 500 && w1.getHeight() != 450) {
         // If the window height is 500 pixels or more, fix the window to 450 pixels height.
         w1.setHeight(450);
        }
    
        w1.center();
    }
    Or, are your problem not really the height of the window? I didn't notice any problem other than the window not fitting the screen if I let it be too thin height-wise.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 0
    Last Post: Mar 06, 2016, 8:05 AM
  2. [CLOSED] Resize Content from Loader after Resize Window Container
    By Ujvari in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 27, 2014, 7:58 PM
  3. [CLOSED] ViewPort Center, Resize GridPanel
    By rthiney in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 31, 2013, 4:39 AM
  4. Replies: 2
    Last Post: Jun 23, 2012, 2:17 PM
  5. [CLOSED] Center window on window resize
    By CSG in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: May 29, 2009, 5:05 AM

Tags for this Thread

Posting Permissions