oversized modal is not centered properly

I'm using Control.Modal for a centered lightbox-style effect. Sometimes the lightbox is too tall to fit in my browser window. When this happens, Control.Modal.center sets 'top' to 0. Since 0 is the top of the document, this means that if I'm scrolled down the page, the lightbox may be entirely offscreen.

I'm not sure what considerations the current code is meant to take into account, but for my purposes it worked to replace line 98:

top: ((dimensions.height <= Control.Modal.getDocumentHeight()) ? ((offset_top != null && offset_top > 0) ? offset_top : '0') + 'px' : 0),

with this:

top: Math.max(offset_top || 0, 0) + 'px',

I.e., place the lightbox where it wants to go, as long as it isn't off the top of the page.

A similar fix might apply to the horizontal dimension, but I haven't had that problem, so I haven't tested a fix.

Posted December 6th, 2007 at 3:42pm by eostrom

Try again. Before:


    top: ((dimensions.height  0) ? offset_top : '0') + 'px' : 0),

After:


    top: Math.max(offset_top || 0, 0) + 'px',

Posted December 6th, 2007 at 4:08pm by eostrom

Login or Register to Post