Team:SYSU-China/animat.js

From 2013.igem.org

(Difference between revisions)
Line 14: Line 14:
  img.stop();
  img.stop();
  if(length > plength) {
  if(length > plength) {
-
  $("#animat span img").attr({"src" : "https://static.igem.org/mediawiki/2013/6/6b/WIKI-MASCOT-RUNNING-RIGHT.gif"});    
+
  $("#animat span img").attr({"src" : img-right.src});    
  } else {
  } else {
-
  $("#animat span img").attr({"src" : "https://static.igem.org/mediawiki/2013/3/32/WIKI-MASCOT-RUNNING-LEFT.gif"});   
+
  $("#animat span img").attr({"src" : img-left.src});   
  }
  }
  plength=length;
  plength=length;

Revision as of 13:01, 12 September 2013

$(document).ready(function(){

       img-left=new Image()
       img-left.src="WIKI-MASCOT-RUNNING-LEFT.gif" 
       img-right=new Image()
       img-right.src="WIKI-MASCOT-RUNNING-RIGHT.gif" 

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

	target.mouseenter(function(){

var length=$(this).offset().left + $(this).width()/2 - mid; img.stop(); if(length > plength) { $("#animat span img").attr({"src" : img-right.src}); } else { $("#animat span img").attr({"src" : img-left.src}); } 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); });