Nol c'est fini...
Ajout d'un script javascript pour faire du scrollage asynchrone avec la barre de droite du wiki darcs-hash:20070106220113-f46e9-3ccd3a5298fe9741dc0b58f422f2e6d81a2baed7.gz
This commit is contained in:
parent
e638a678b3
commit
8daf0a25c7
3 changed files with 382 additions and 18 deletions
69
wiki/static/crans/js/scroller.js
Normal file
69
wiki/static/crans/js/scroller.js
Normal file
|
@ -0,0 +1,69 @@
|
|||
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);
|
Loading…
Add table
Add a link
Reference in a new issue