Difference between revisions of "Team:Aix-Marseille/JS 2015/logo animation"
Line 1: | Line 1: | ||
− | + | //PARAMETRAGE DES IMAGES A CHOISIR POUR TRAJECTOIRE SUIVANT LE SENS | |
− | + | addressUrl = window.location.href; | |
− | + | img_left=new Image(); | |
− | + | img_left.src="http://localhost/Wiki/CSS_2015Aix-Marseille/images_2015Aix-Marseille/mascotte-gauche.gif" ; | |
+ | img_right=new Image(); | ||
+ | img_right.src="http://localhost/Wiki/CSS_2015Aix-Marseille/images_2015Aix-Marseille/mascotte-droite.gif" ; | ||
− | + | /*if (addressUrl.indexOf("Onglet 1") > 0 ) { | |
+ | img_left=new Image(); | ||
+ | img_left.src="https://static.igem.org/mediawiki/2013/e/e1/WIKI-MASCOT-RUNNING-LEFT-GREEN.gif" ; | ||
+ | img_right=new Image(); | ||
+ | img_right.src="https://static.igem.org/mediawiki/2013/7/78/WIKI-MASCOT-RUNNING-RIGHT-GREEN.gif" ; | ||
+ | } | ||
+ | else if (addressUrl.indexOf("Onglet 2") > 0 ){ | ||
+ | img_left=new Image(); | ||
+ | img_left.src="https://static.igem.org/mediawiki/2013/d/dd/WIKI-MASCOT-RUNNING-LEFT-RED.gif" ; | ||
+ | img_right=new Image(); | ||
+ | img_right.src="https://static.igem.org/mediawiki/2013/4/41/WIKI-MASCOT-RUNNING-RIGHT-RED.gif" ; | ||
+ | } else if (addressUrl.indexOf("Onglet 3") > 0 ){ | ||
+ | img_left=new Image(); | ||
+ | img_left.src="https://static.igem.org/mediawiki/2013/8/84/WIKI-MASCOT-RUNNING-LEFT-BLUE.gif" ; | ||
+ | img_right=new Image(); | ||
+ | img_right.src="https://static.igem.org/mediawiki/2013/5/54/WIKI-MASCOT-RUNNING-RIGHT-BLUE.gif" ; | ||
+ | } else if (addressUrl.indexOf("Onglet 4") > 0 ){ | ||
+ | img_left=new Image(); | ||
+ | img_left.src="https://static.igem.org/mediawiki/2013/9/9d/WIKI-MASCOT-RUNNING-LEFT-BRONE.gif" ; | ||
+ | img_right=new Image(); | ||
+ | img_right.src="https://static.igem.org/mediawiki/2013/a/a2/WIKI-MASCOT-RUNNING-RIGHT-BRONE.gif" ; | ||
+ | } else if (addressUrl.indexOf("Onglet 5") > 0 ){ | ||
+ | img_left=new Image(); | ||
+ | img_left.src="https://static.igem.org/mediawiki/2013/1/17/WIKI-MASCOT-RUNNING-LEFT-ORANGE.gif" ; | ||
+ | img_right=new Image(); | ||
+ | img_right.src="https://static.igem.org/mediawiki/2013/f/f7/WIKI-MASCOT-RUNNING-RIGHT-ORANGE.gif" ; | ||
+ | } else { | ||
+ | img_left=new Image(); | ||
+ | img_left.src="https://static.igem.org/mediawiki/2013/3/32/WIKI-MASCOT-RUNNING-LEFT.gif" ; | ||
+ | img_right=new Image(); | ||
+ | img_right.src="https://static.igem.org/mediawiki/2013/6/6b/WIKI-MASCOT-RUNNING-RIGHT.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 | |
− | function | + | $(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" : "http://localhost/Wiki/CSS_2015Aix-Marseille/images_2015Aix-Marseille/mascotte-statique.png" | |
− | + | }); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
}); | }); | ||
} | } | ||
− | + | ||
− | + | }); | |
− | + |
Revision as of 16:46, 26 July 2015
//PARAMETRAGE DES IMAGES A CHOISIR POUR TRAJECTOIRE SUIVANT LE SENS
addressUrl = window.location.href; img_left=new Image();
img_left.src="http://localhost/Wiki/CSS_2015Aix-Marseille/images_2015Aix-Marseille/mascotte-gauche.gif" ;
img_right=new Image(); img_right.src="http://localhost/Wiki/CSS_2015Aix-Marseille/images_2015Aix-Marseille/mascotte-droite.gif" ;
/*if (addressUrl.indexOf("Onglet 1") > 0 ) { img_left=new Image(); img_left.src="" ; img_right=new Image(); img_right.src="" ;
}
else if (addressUrl.indexOf("Onglet 2") > 0 ){ img_left=new Image(); img_left.src="" ; img_right=new Image(); img_right.src="" ;
} else if (addressUrl.indexOf("Onglet 3") > 0 ){
img_left=new Image(); img_left.src="" ; img_right=new Image(); img_right.src="" ;
} else if (addressUrl.indexOf("Onglet 4") > 0 ){
img_left=new Image(); img_left.src="" ; img_right=new Image(); img_right.src="" ;
} else if (addressUrl.indexOf("Onglet 5") > 0 ){
img_left=new Image(); img_left.src="" ; img_right=new Image(); img_right.src="" ;
} else {
img_left=new Image(); img_left.src="" ; img_right=new Image(); img_right.src="" ; };
- /
$(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" : "http://localhost/Wiki/CSS_2015Aix-Marseille/images_2015Aix-Marseille/mascotte-statique.png" }); }); }
});