[jQuery] Thickbox: Smoooooth scrolling with fixed positioning

[jQuery] Thickbox: Smoooooth scrolling with fixed positioning

Hi all,
I worked a bit on the thickbox script to improve it. What bothered me,
was that when scrolling the window the thickbox window is moved to stay
in the center, but that happens not smooth at all.
So I changed it to use fixed positioning.
1. Changed CSS:
#TB_window {
position: fixed;
top: 50%;
left: 50%;
}
2. Removed the scroll event handler:
$(window).scroll(TB_position);
3. Changed the function TB_position:
function TB_position() {
$("#TB_window").css({marginLeft: '-' + parseInt(TB_WIDTH / 2) +
'px', width: TB_WIDTH + 'px'});
if ( !(jQuery.browser.msie && typeof XMLHttpRequest == 'function')
) { // take away IE6
$("#TB_window").css({marginTop: '-' + parseInt(TB_HEIGHT / 2) +
'px'});
}
TB_overlaySize();
}
It now pushes itself half of its width/height to the left/top from the
middle so that it is exactly centered.
(It seemed to me that calling TB_overlaySize here is unnecessary, but I
left it in for now.)
4. Fixed our special friend IE6 to emulate a fixed positioning:
* html #TB_window {
position: absolute;
margin-top: expression(0 - parseInt(this.offsetHeight / 2) +
(TBWindowMargin = document.documentElement &&
document.documentElement.scrollTop || document.body.scrollTop) + 'px');
}
Based on http://www.howtocreate.co.uk/fixedPosition.html
I use the Star Selector hack to filter IE7, which supports fixed
positioning. Because this is invalid CSS I would put that in a
Conditional Commented extra style sheet.
5. Smoooooth.
I hope, this will go into the next Thickbox version. Have fun!
Klaus
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/