Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correcting issue in which Lightbox does not properly handle horizontal scrolling in wide windows #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions jquery.lightbox_me.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@

// set css of the overlay
if (opts.showOverlay) {
setOverlayHeight(); // pulled this into a function because it is called on window resize.
$overlay.css({ position: 'absolute', width: '100%', top: 0, left: 0, right: 0, bottom: 0, zIndex: (opts.zIndex + 2), display: 'none' });
setOverlayHeightAndWidth(); // pulled this into a function because it is called on window resize.
$overlay.css({ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, zIndex: (opts.zIndex + 2), display: 'none' });
if (!$overlay.hasClass('lb_overlay_clear')){
$overlay.css(opts.overlayCSS);
}
Expand All @@ -71,7 +71,7 @@
if (opts.showOverlay) {
$overlay.fadeIn(opts.overlaySpeed, function() {
setSelfPosition();
$self[opts.appearEffect](opts.lightboxSpeed, function() { setOverlayHeight(); setSelfPosition(); opts.onLoad()});
$self[opts.appearEffect](opts.lightboxSpeed, function() { setOverlayHeightAndWidth(); setSelfPosition(); opts.onLoad()});
});
} else {
setSelfPosition();
Expand All @@ -90,7 +90,7 @@
Bind Events
---------------------------------------------------- */

$(window).resize(setOverlayHeight)
$(window).resize(setOverlayHeightAndWidth)
.resize(setSelfPosition)
.scroll(setSelfPosition);

Expand Down Expand Up @@ -134,7 +134,7 @@
// clean up events.
$self.undelegate(opts.closeSelector, "click");

$(window).unbind('reposition', setOverlayHeight);
$(window).unbind('reposition', setOverlayHeightAndWidth);
$(window).unbind('reposition', setSelfPosition);
$(window).unbind('scroll', setSelfPosition);
$(window).unbind('keyup.lightbox_me');
Expand All @@ -150,11 +150,14 @@
}


/* Set the height of the overlay
/* Set the height and width of the overlay
: if the document height is taller than the window, then set the overlay height to the document height.
: otherwise, just set overlay height: 100%
:
: if the document width is wider than the window, then set the overlay width to the document width.
: otherwise, just set overlay width: 100%
*/
function setOverlayHeight() {
function setOverlayHeightAndWidth() {
if ($(window).height() < $(document).height()) {
$overlay.css({height: $(document).height() + 'px'});
$iframe.css({height: $(document).height() + 'px'});
Expand All @@ -165,6 +168,17 @@
$iframe.css('height', '100%');
} // ie6 hack for height: 100%; TODO: handle this in IE7
}

if ($(window).width() < $(document).width()) {
$overlay.css({ width: $(document).width() + 'px' });
$iframe.css({ width: $(document).width() + 'px' });
} else {
$overlay.css({ width: '100%' });
if (ie6) {
$('html,body').css('width', '100%');
$iframe.css('width', '100%');
} // ie6 hack for width: 100%; TODO: handle this in IE7
}
}


Expand Down