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

Fixed positioning of the Box #684

Open
wants to merge 2 commits 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
14 changes: 8 additions & 6 deletions jquery.colorbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,17 +617,17 @@

// remove the modal so that it doesn't influence the document width/height
$box.css({top: -9e4, left: -9e4});

scrollTop = $window.scrollTop();
scrollLeft = $window.scrollLeft();

if (settings.get('fixed')) {
offset.top -= scrollTop;
offset.left -= scrollLeft;
top = 0;
left = 0;
$box.css({position: 'fixed'});
} else {
top = scrollTop;
left = scrollLeft;
top = 0;
left = 0;
$box.css({position: 'absolute'});
}

Expand All @@ -637,6 +637,7 @@
} else if (settings.get('left') !== false) {
left += setSize(settings.get('left'), 'x');
} else {
left = scrollLeft;
left += Math.round(Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2);
}

Expand All @@ -645,10 +646,11 @@
} else if (settings.get('top') !== false) {
top += setSize(settings.get('top'), 'y');
} else {
top = scrollTop;
top += Math.round(Math.max(winheight() - settings.h - loadedHeight - interfaceHeight, 0) / 2);
}

$box.css({top: offset.top, left: offset.left, visibility:'visible'});
$box.css({top: top, left: left, visibility:'visible'});

// this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
// but it has to be shrank down around the size of div#colorbox when it's done. If not,
Expand Down