Ensuring minimum minimum window top position

2 posts, 0 answers
  1. Rene
    Rene avatar
    65 posts
    Member since:
    Nov 2010

    Posted 21 Mar 2014 Link to this post

    I'm not sure how to do this but here is the scenario:

    I have a page with a header bar that is fixed to the top of the viewport and has a high z-index so that when the page is scrolled vertically, any page content scrolls under the page header bar.

    When a window is displayed and centered - there is the chance that the window caption/titlebar appear underneath the header bar where it is now no longer possible to drag the window or close it via the "x" button.

    What I am trying to achieve is to set a min-top position for the window where no matter if the window is centered or dragged it will never go less than 100 pixels from the top of the client area (not to be confused with the viewport).

    Similar to windows dev where you subclass a window and handle the WM_WINDOWMOVE type message and adjust the window position after the fact.

    Any idea?
  2. Rene
    Rene avatar
    65 posts
    Member since:
    Nov 2010

    Posted 21 Mar 2014 in reply to Rene Link to this post

    Figured it out.

    var myPopupWindow = $("#myPopupWindowId");

    $(document).ready( function() {
      window.setInterval( function() {
          if( $(myPopupWindow).is(":visible"))
            ensureMinTopMargin();
      }, 1500 );
    });


    function ensureMinTopMargin(){
       if( $( myPopupWindow ).parent().position().top < 90 )
          $( myPopupWindow ).parent().css('top',90);
       return false;
    }
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top