1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
| var interval_zero = setInterval(mouvSphere_centrale,80);
var autreInterval = setInterval(imgCercle_sphereUn, 30);
// Récupération de la position du body
var pBody = $('body').offset();
// =================================================================================================================================
// ================================================= SPHERE CENTRALE ========================================================
// =================================================================================================================================
// Définition des variables utilies pour le mouvement de la sphere centrale
var x0,y0,direction0;
// Récupération de la position de la sphère centrale
x0 = $('#sphere_centrale').offset();
// Initialisation de la variable top_centrale avec la valeur de l'offset TOP de la sphere centrale
top_centrale = x0.top;
// Initialition de la variable direction0 permettant de faire bouger la sphere ou vers le haut ou vers le bas
direction0 = 1;
// Appel de la fonction mouvSphere_centrale() permettant le mouvement de la sphere centrale
function mouvSphere_centrale(){
var c;
// Si la mouvement varie de +2 à +5 ou de -2 à -5, alors le mouvement se fait plus lementement
if(x0.top >= (top_centrale+2) && x0.top <= (top_centrale+5) || x0.top >= (top_centrale-5) && x0.top <= (top_centrale-2)){
c = 0.5;
} else {
c = 1;
}
// Si la position atteint position+5 ou position-5, alors on change la direction du mouvement
if(x0.top >= (top_centrale+5) && direction0 == 1){
direction0 = -1;
} else if(x0.top == (top_centrale-5) && direction0 == -1){
direction0 = 1;
}
// On attribue la nouvelle position suivant le mouvement à la variable x0.top
x0.top = parseFloat(x0.top)+(c*direction0);
// On envoi au CSS la nouvelle position de la sphere
$('.sphere_centrale').css('top', x0.top);
}
// ================================================================================================
// ===================================== SPHERE UN ===========================================
// ================================================================================================
var p1,top_un,left_un,direction1;
p1 = $('#sphere_un').offset();
top_un = p1.top;
left_un = p1.left-pBody.left;
direction1 = 1;
function mouvSphere_un(){
var i;
if(p1.top >= (top_un+6) && p1.top <= (top_un+9) || p1.top >= (top_un-9) && p1.top <= (top_un-6)){
i = 0.5;
} else {
i = 1;
}
if(p1.top >= (top_un+9) && direction1 == 1){
direction1 = -1;
} else if(p1.top == (top_un-9) && direction1 == -1){
direction1 = 1;
}
p1.top = parseFloat(p1.top)+(i*direction1);
p1.left = parseFloat(left_un)+(i*direction1);
$('#sphere_un').css('top', p1.top);
$('#sphere_un').css('left',p1.left);
}
// ================================================================================================
var angleIMG_un = 0;
s1_width = $('#sphere_un').width();
s1_height = $('#sphere_un').height();
s0_width = $('#sphere_centrale').width();
s0_height = $('#sphere_centrale').height();
pos_rel_s1 = $('#sphere_un').offset();
var pos_temp = pos_rel_s1.left;
var flag = true;
function imgCercle_sphereUn(){
s1_pos = $('#sphere_un').offset();
s0_pos = $('#sphere_centrale').offset();
$("#sphere_un").css({
// left:parseInt(330 + (s1_width/20) * Math.cos(angleIMG_un)),
left:pos_temp,
top:parseInt((top_un-70) + ((s0_height/2)-80) * Math.sin(angleIMG_un))
});
if(s1_pos.top > 250){
$('#sphere_un').css('width',(s1_width-=0.6)+'px');
$('#sphere_un').css('height',(s1_height-= 0.6)+'px');
} else if(s1_pos.top <= 250){
$('#sphere_un').css('width',(s1_width+=0.6)+'px');
$('#sphere_un').css('height',(s1_height+= 0.6)+'px');
}
if(s1_pos.top >= parseInt(top_un+190)){
$("#sphere_un").css('z-index',0);
} else if(s1_pos.top <= parseInt(top_un-330)){
$("#sphere_un").css('z-index',10);
}
if(s1_pos.top >= 280 && s1_pos.top <= 320 && $("#sphere_un").css('z-index') == 0){
$("#sphere_un").css('width','70px');
$("#sphere_un").css('height','70px');
s1_width = 70;
s1_height = 70;
}
angleIMG_un += 0.015;
if(flag){ pos_temp+=2 } else { pos_temp-=2; }
if(pos_temp >= 700){ flag = false; } else if(pos_temp <= 0){ flag = true; }
}
$(window).load(function(){
setTimeout("clearInterval(" + autreInterval + ")", 1000000);
}); |
Partager