Team:Aix-Marseille/JS 2015/logo animation

   //PARAMETRAGE DES IMAGES A CHOISIR POUR TRAJECTOIRE SUIVANT LE SENS

addressUrl = window.location.href; img_left=new Image();

   img_left.src="Aix-Marseille_Mascotte-gauche.gif" ;

img_right=new Image(); img_right.src="Aix-Marseille_Mascotte-droite.gif";


$(document).ready(function(){ var logoLefteft = 0; var menuCibles = $("#menu_ul li a"); var img = $("#mascotte img"); //var mid = img.offset().left + img.width()/2 - parseInt(img.css("left")); var lastActivatedIndex = "null"; var mid = $("#mascotte").width/2 - img.width/2;

//Placement Logo img.attr({"left" : mid});

	//Lorsqu'un utilisateur survole un onglet, on déclenche l'animation

menuCibles.mouseenter(function() { animation($(this)); lastActivatedIndex = $(this); });

//Lorsqu'un utilisateur zoom ou dézoom, on déclenche l'animation pour mettre l'image gif à sa place $(window).resize(function() { if(lastActivatedIndex!="null") { animation(lastActivatedIndex); } });

//Fonction gérant l'animation du logo du système d'onglets function animation(e){ //Calculs pour situations var destinationLeftLogo = e.offset().left + e.width()/2 - img.width()/2; img.stop(); logoLeft = $("#mascotte img").offset().left; if(destinationLeftLogo > logoLeft) { img.attr({"src" : img_right.src}); } else if (destinationLeftLogo < logoLeft){ img.attr({"src" : img_left.src}); } logoLeft = destinationLeftLogo;

//Animation du logo img.animate({left:destinationLeftLogo},500, function(){ img.attr({"src" : "Aix-Marseille_Mascotte-statique.png" }); }); }

});