dinbror / bpopup

bPopup is a lightweight jQuery modal popup plugin (only 1.34KB gzipped). It doesn't create or style your popup but provides you with all the logic like centering, modal overlay, events and more. It gives you a lot of opportunities to customize so it will fit your needs.
http://dinbror.dk/bPopup
427 stars 260 forks source link

recenter incorrect height and width with padding #38

Open ultimate-tester opened 9 years ago

ultimate-tester commented 9 years ago

Hello,

I just discovered that the recenter function uses the incorrect height and width (the ones used in css.height and css.width). If you have a padding or margin on the popupBox div, then the padding will be subtracted from the real size resulting in the box being the amount of left and right padding smaller in width and the amount of top and bottom padding smaller in height.

To fix this, please change the recenter function to the following:

if (_height >= $popup.outerHeight(true)){ css.height = $popup.outerHeight(true); } if(_width >= $popup.outerWidth(true)){ css.width = $popup.outerWidth(true); } height = $popup.outerHeight(true) , width = $popup.outerWidth(true);

Thanks in advance!

shedy2 commented 9 years ago

thanks

dinbror commented 9 years ago

Hey ultimate-tester. I'm not sure that's right. If you only load an image the current release works fine, see example 5b on my demo page: http://dinbror.dk/bpopup. But if I add text or other content there is a bug. I'll look into it, thanks