
Ajout d'un script javascript pour faire du scrollage asynchrone avec la barre de droite du wiki darcs-hash:20070106220113-f46e9-3ccd3a5298fe9741dc0b58f422f2e6d81a2baed7.gz
69 lines
4.2 KiB
JavaScript
69 lines
4.2 KiB
JavaScript
scroller =
|
|
{
|
|
}
|
|
;
|
|
|
|
scroller.element_id = "column-one";
|
|
scroller.min_top = 41;
|
|
|
|
|
|
|
|
scroller.setMenuOffset = function()
|
|
{
|
|
|
|
|
|
var element = document.getElementById(scroller.element_id);
|
|
if (!element) return;
|
|
element.style.position = "fixed";
|
|
var currentWindowHeight = document.documentElement.clientHeight;
|
|
var currentScroll = document.documentElement.scrollTop || document.body.scrollTop; // body for Safari
|
|
var currentElementHeight = element.clientHeight;
|
|
|
|
var startPosition = scroller.min_top;
|
|
|
|
if (currentWindowHeight > currentElementHeight + startPosition)
|
|
{
|
|
|
|
element.style.top = startPosition + 'px';
|
|
return;
|
|
}
|
|
|
|
|
|
var desiredPosition = startPosition - currentScroll ;
|
|
if (desiredPosition < currentWindowHeight - currentElementHeight)
|
|
desiredPosition = currentWindowHeight - currentElementHeight;
|
|
element.style.top = desiredPosition + 'px';
|
|
|
|
}
|
|
|
|
|
|
scroller.init = function ()
|
|
{
|
|
|
|
|
|
/* See if browser supports advanced interface */
|
|
|
|
//var advancedJavaScriptSupport = document.createElement && document.getElementsByTagName && createXMLHTTPObject();
|
|
//if (!advancedJavaScriptSupport) return;
|
|
|
|
/* Load advanced interface */
|
|
window.onscroll = document.documentElement.onscroll = scroller.setMenuOffset;
|
|
scroller.setMenuOffset();
|
|
}
|
|
|
|
|
|
// use this instead of assigning to window.onload directly:
|
|
function addLoadEvent(func) {
|
|
// alert("addLoadEvent " + func)
|
|
var oldonload = window.onload;
|
|
if (typeof window.onload != 'function') {
|
|
window.onload = func;
|
|
} else {
|
|
window.onload = function() {
|
|
oldonload();
|
|
func();
|
|
}
|
|
}
|
|
}
|
|
|
|
addLoadEvent(scroller.init);
|