Team:SYSU-China/animat.js

From 2013.igem.org

(Difference between revisions)
Line 1: Line 1:
-
$(document).ready(function(){
+
        img_left=new Image();
-
 
+
-
 
+
         img_left.src="https://static.igem.org/mediawiki/2013/3/32/WIKI-MASCOT-RUNNING-LEFT.gif" ;
         img_left.src="https://static.igem.org/mediawiki/2013/3/32/WIKI-MASCOT-RUNNING-LEFT.gif" ;
-
         img_right.src="https://static.igem.org/mediawiki/2013/6/6b/WIKI-MASCOT-RUNNING-RIGHT.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 plength=0;
var plength=0;
var target=$("li.column");
var target=$("li.column");
var img=$("#animat span");
var img=$("#animat span");
-
var mid=img.offset().left + img.width()/2 - parseInt(img.css("left"));
+
var mid=img.offset().left + img.width()/2 +img.css("left");
  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 02:35, 28 September 2013

       img_left=new Image();
       img_left.src="WIKI-MASCOT-RUNNING-LEFT.gif" ;
       img_right=new Image();
       img_right.src="WIKI-MASCOT-RUNNING-RIGHT.gif" ;	

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

	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"});} );

}); });