jackmoore/colorbox — pull request #156 by mkurz (2012-02-09 20:50:10+00:00)
Title: Bugfix: Large content and small browser window

Version of colorbox: 1.3.19
Affected Browsers: Firefox 3.6+, Chrome 5+, IE7+ (didn't test IE6), Opera

Reproduction steps:
1. Open example3/index.html from the github repository in a browser
2. Resize your browser window to a height of around 500px
3. Open the demo under "Elastic Transition" -> "Grouped Photo 1"
4. A vertical scrollbar of your browser should appear (if not make the window smaller)
5. Scroll all the way down till the end of the browser
6. Click on the image (depending on how small you made the window there should still a small part visible) to switch to the next one
7. Repeat step 5 and 6 (don't forget to always again scroll down to the very end of the page)

Result:
After a few times repeating step 5 and 6 the colorbox jumps down vertically out of the visible area of your browser window (or at least down to the half an more, depending how small you made the window and how often you repeat the steps)

This bug specially occurs when you have a link at the very end of a website which opens colorbox plus when the image is very big (high) (and maybe you have a small resolution). Which was my case ;) Then the image does not fit in the browser window anymore an the browser window increases it's document height.
When colorbox calculates it's "top" variable to place the box it also includes this new document area which ruins the calculations.

If you have a look at my fix you will see the only change I made was that scrollTop and scrollLeft is now calculated after the box is removed, so it does not include the unnecessary "new height".

Greetings