Div bougeable en fonction du scroll... problème le navigateur panique... Script

cs_MeTh Messages postés 22 Date d'inscription lundi 20 janvier 2003 Statut Membre Dernière intervention 14 janvier 2005 - 28 mai 2004 à 11:16
Zenor Messages postés 2 Date d'inscription vendredi 12 mars 2004 Statut Membre Dernière intervention 29 mai 2006 - 26 mai 2005 à 14:08
Bonjour,
J'essai de réalisé un script qui déplace les div verticalement ou horizontalement en fonction du scroll de la fenetre pour que les div reste tjrs visible....

tous marche plus au moins normalement les div bouge en fonction du scroll
Mais si on commence à faire paniquer le scroll... mouvement répété rapide haut bas droite gauche de la barre de défilement... et même un tout ptit peu faut pas grand chose

la charge du CPU s'emballe 100% le script doit tourné en boucle et bien sur le navigateur ne répond plus... et bonjours CTRL ALT DELETE

je n'arrive pas à trouver pkoi je suis sur que c'est du à mes setIntervall mais j'arrive pas à trouvé quand est ce qu'il s'emballe...
Merci de toute réponse...

<html>
<head>
<title>Document sans titre</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="./structv2.css">
<style type="text/css">
<!--

-->
</style>
<SCRIPT LANGUAGE="javascript1.2" SRC="LibV1.js"></SCRIPT>
<script language="javascript">
<!--
var timecheckscroll = 800; // intérval de temps ou on check le changement de position de la scroll
var timeintmoving = 300; // intérval de temps ou l'on effectue un déplacement de la div position par position

var intervalscroll = setInterval("checkscroll()",timecheckscroll);

function checkscroll(){
//alert("check");
pagesize = document.body.clientHeight;

//DECLARATION DES DIV
divheading = heading.style;
divfooter = footer.style;

// VALEUR DES SCROLL TOP ET LEFTvar topScroll document.body.scrollTop + 5; // 5 valeur de la marge supérieur au dessus de heading
var leftScroll = document.body.scrollLeft;

// VALEUR DES POSITIONS TOP ET LEFT DES DIV HEADING ET PAGGING
var topHeading = getTop(heading);
var topFooter = getTop(footer);
var leftFooter = getLeft(footer);

// VERIFI SI LA SCROLL A BOUGE PAR RAPPORT A LA POSITION DE LA DIV HEADING axe vertical
if(topHeading != topScroll){
//alert("moververti");

// SI OUI LES DIV SONT DEPLACER axe vertical
window.clearInterval(intervalscroll);
intervalmovingvertic = setInterval("movevertic()",timeintmoving);
//movevertic();
}

// VERIFI SI LA SCROLL A BOUGE PAR RAPPORT A LA POSITION DE LA DIV HEADING axe horizontal
if(leftFooter != (leftScroll + 5)){
// SI OUI LES DIV SONT DEPLACER axe horizontal
window.clearInterval(intervalscroll);
intervalmovinghorizon = setInterval("movehorizon()",timeintmoving);
}
}

// FONCTION BOUGE à LA VERTICAL LES DIV
function movevertic(){
//DECLARATION DES DIV
divheading = heading.style;
divfooter = footer.style;

// VALEUR DES SCROLL TOP ET LEFTvar topScroll document.body.scrollTop + 5; // 5 valeur de la marge supérieur au dessus de heading
var leftScroll = document.body.scrollLeft;

// VALEUR DES POSITIONS TOP ET LEFT DES DIV HEADING ET PAGGING
var topHeading = getTop(heading);
var topFooter = getTop(footer);
var leftFooter = getLeft(footer);

var diffvertic = topHeading - topScroll;

if(topHeading == topScroll){
//alert("okay");

window.clearInterval(intervalmovingvertic);
intervalscroll = setInterval("checkscroll()",timecheckscroll);
}
else{
if(diffvertic <= 8 && diffvertic >= 1){
var movevalue = 1;
}
else{
var movevalue = Math.floor(diffvertic / 8);
}
//alert(diffvertic+" => "+movevalue);

divheading.top = topHeading - movevalue;
divfooter.top = topFooter - movevalue
;

if(topHeading == topScroll){
alert("okayaaaaaaaaaaa");

window.clearInterval(intervalmovingvertic);
intervalscroll = setInterval("checkscroll()",timecheckscroll);
}
}
}

// FONCTION BOUGE à L'HORIZONTAL LES DIV
function movehorizon(){
//DECLARATION DES DIV
divheading = heading.style;
divfooter = footer.style;

// VALEUR DES SCROLL TOP ET LEFTvar topScroll document.body.scrollTop + 5; // 5 valeur de la marge supérieur au dessus de heading
var leftScroll = document.body.scrollLeft;

// VALEUR DES POSITIONS TOP ET LEFT DES DIV HEADING ET PAGGING
var topHeading = getTop(heading);
var topFooter = getTop(footer);
var leftFooter = getLeft(footer);

var diffhorizon = leftFooter - (leftScroll + 5);

if(leftFooter != leftScroll + 5){
divfooter.left = leftScroll + 5;

window.clearInterval(intervalmovinghorizon);
intervalscroll = setInterval("checkscroll()",timecheckscroll);
}
else{
window.clearInterval(intervalmovinghorizon);
intervalscroll = setInterval("checkscroll()",timecheckscroll);
}
}
//-->
</script>

</head>

Entete_______________________________________________________________________________________________________________________________________________________________________

ne pas utiliser de div scrollable mais
plustot la fenetre mettre en place des menu qui se déplacerons en vertical et
en horizontal selon le scrollLeft de l'utilisateur voir testscroll.php pour
plus de source mettre en place une entete pour le tablo qui se déplace en vertical
mais pas en horizontal pour toujours gardé l'alignement par rapport au tablo




__________________________________________________________________________________________________________________________________________________________________









ads





























adsgf

























asdg





















asdg





adsg

Paggin < 1 2 3 4 5 6... >

</html>

3 réponses

cs_MeTh Messages postés 22 Date d'inscription lundi 20 janvier 2003 Statut Membre Dernière intervention 14 janvier 2005
28 mai 2004 à 11:17
Désolé pour la mise en page.... %-6
0
cs_MeTh Messages postés 22 Date d'inscription lundi 20 janvier 2003 Statut Membre Dernière intervention 14 janvier 2005
28 mai 2004 à 11:19
0
Zenor Messages postés 2 Date d'inscription vendredi 12 mars 2004 Statut Membre Dernière intervention 29 mai 2006
26 mai 2005 à 14:08
Le newbie de la programmation
0
Rejoignez-nous