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

window width #21

Closed pavdro closed 9 years ago

pavdro commented 11 years ago

Hi, in the code you are using 'y.innerWidth || d.width()' which return different values when scrollbar is on the page.

so popup doesn't end up perfectly centered.

Tested with: jQuery 1.10.2 FF - 24.0

Joshdw commented 9 years ago

Same Issue as #7 . Anyone managed to find a fix?

pavdro commented 9 years ago

I've changed some code in the script and works for me.

find reposition funciton function reposition(animateSpeed) { wH = windowHeight(); wW = windowWidth(); inside = insideWindow(); //if (inside) { clearTimeout(debounce); debounce = setTimeout(function () { calcPosition(); animateSpeed = animateSpeed || o.followSpeed; $popup .dequeue() .each(function () { $(this).css({ left: getLeftPos(!(!o.follow[0] && fixedHPos || fixedPosStyle)), top: getTopPos(!(!o.follow[1] && fixedVPos || fixedPosStyle)) });

//// if (fixedPosStyle) { //// $(this).css({ 'left': hPos, 'top': vPos }); //// } //// else { //// $(this).animate({ 'left': o.follow[0] ? getLeftPos(true) : 'auto', 'top': o.follow[1] ? getTopPos(true) : 'auto' }, animateSpeed, o.followEasing); //// } }); }, 50); //} };

Joshdw commented 9 years ago

Hey pavdro,

seems to not work for me. The popup is still slightly off to the right when the scrollbar is visible.

pavdro commented 9 years ago

Hmm, actually I think that's another bug I've tried to fix. Apologies.

I think the way I have worked around the center issue is this: I've attached it to a centered container, so it stays within it and never moves.

Joshdw commented 9 years ago

For anyone else interested, I have a temporary (yet somewhat ugly) solution which is adding this event to the popup's onOpen event:

onOpen: function() { $(this).bPopup().reposition(0); }

That and the code from pavdro seems to fix positioning errors on load. It's a shame this script isn't getting updated much anymore.

pavdro commented 9 years ago

GJ! hopefully we will get an update sometime.

dinbror commented 9 years ago

Try to change the windowWidth and windowHeight funtions to return the fallback value everytime:

function windowWidth(){ return $w.width(); };

I'll be sending out an update in near future.

dinbror commented 9 years ago

Fixed in v. 0.11.0