This is a migrated thread and some comments may be shown as answers.

Ensuring minimum minimum window top position

1 Answer 71 Views
Window
This is a migrated thread and some comments may be shown as answers.
Rene
Top achievements
Rank 1
Rene asked on 21 Mar 2014, 02:54 PM
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?

1 Answer, 1 is accepted

Sort by
0
Rene
Top achievements
Rank 1
answered on 21 Mar 2014, 08:00 PM
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;
}
Tags
Window
Asked by
Rene
Top achievements
Rank 1
Answers by
Rene
Top achievements
Rank 1
Share this question
or