Team:SYSU-China/animat.js

From 2013.igem.org

(Difference between revisions)
Line 4: Line 4:
var img=$("#animat span");
var img=$("#animat span");
var mid=img.offset().left + img.width()/2;
var mid=img.offset().left + img.width()/2;
-
         $("#animat span img").attr({"src" : "https://static.igem.org/mediawiki/2013/4/44/WIKI-MASCOT-STAND.png"});
+
         $("#animat span img").attr({"src" : "https://static.igem.org/mediawiki/2013/4/44/WIKI-MASCOT-RUNNING-RIGHT.gif"});
target.mouseenter(function(){
target.mouseenter(function(){
var length=$(this).offset().left + $(this).width()/2 - mid;
var length=$(this).offset().left + $(this).width()/2 - mid;

Revision as of 12:41, 12 September 2013

$(document).ready(function(){ var plength=0; var target=$("li.column"); var img=$("#animat span"); var mid=img.offset().left + img.width()/2;

       $("#animat span img").attr({"src" : "WIKI-MASCOT-RUNNING-RIGHT.gif"});	

target.mouseenter(function(){ var length=$(this).offset().left + $(this).width()/2 - mid; img.stop(); if(length > plength) { $("#animat span img").attr({"src" : "WIKI-MASCOT-RUNNING-RIGHT.gif"}); } else { $("#animat span img").attr({"src" : "WIKI-MASCOT-RUNNING-LEFT.gif"}); } plength=length; img.animate( {left:length}, 500, function(){ $("#animat span img").attr({"src" : "WIKI-MASCOT-STAND.png"});} );

}); var win_width = $(window).width()/2 - $("#address").width()/2; $("#address").css("left",win_width); });